Skip to content

Commit 721c1f0

Browse files
committed
---
yaml --- r: 6791 b: refs/heads/tswast-patch-1 c: 9b4ff48 h: refs/heads/master i: 6789: 4630737 6787: c3e5c90 6783: 2e110e9
1 parent 5d45158 commit 721c1f0

3 files changed

Lines changed: 403 additions & 1 deletion

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 438c05a53c7aba8b399f5e1e701ff108aa900478
60+
refs/heads/tswast-patch-1: 9b4ff48b64c2192a42d914a672d9004e59a4b822
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
/*
2+
* Copyright 2016 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.gcloud.dns;
18+
19+
import static com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull;
20+
21+
import com.google.common.base.MoreObjects;
22+
23+
import java.io.Serializable;
24+
import java.math.BigInteger;
25+
import java.util.Objects;
26+
27+
/**
28+
* The class that encapsulates information about a project in Google Cloud DNS. A project is a top
29+
* level container for resources including {@link ManagedZone}s. Projects can be created only in the
30+
* APIs console.
31+
*
32+
* @see <a href="https://cloud.google.com/dns/api/v1/projects">Google Cloud DNS documentation</a>
33+
*/
34+
public class ProjectInfo implements Serializable {
35+
36+
private static final long serialVersionUID = 201601251420L;
37+
private final String id;
38+
private final BigInteger number;
39+
private final Quota quota;
40+
41+
/**
42+
* This class represents quotas assigned to the {@code ProjectInfo}.
43+
*
44+
* @see <a href="https://cloud.google.com/dns/api/v1/projects">Google Cloud DNS documentation</a>
45+
*/
46+
public static class Quota {
47+
48+
private Integer zones;
49+
private Integer resourceRecordsPerRrset;
50+
private Integer rrsetAdditionsPerChange;
51+
private Integer rrsetDeletionsPerChange;
52+
private Integer rrsetsPerManagedZone;
53+
private Integer totalRrdataSizePerChange;
54+
55+
/**
56+
* Creates an instance of {@code Quota}.
57+
*
58+
* This is the only way of creating an instance of {@code Quota}. As the service does not allow
59+
* for specifying options, quota is an "all-or-nothing object" and we do not need a builder.
60+
*/
61+
Quota(Integer zones,
62+
Integer resourceRecordsPerRrset,
63+
Integer rrsetAdditionsPerChange,
64+
Integer rrsetDeletionsPerChange,
65+
Integer rrsetsPerManagedZone,
66+
Integer totalRrdataSizePerChange) {
67+
this.zones = checkNotNull(zones);
68+
this.resourceRecordsPerRrset = checkNotNull(resourceRecordsPerRrset);
69+
this.rrsetAdditionsPerChange = checkNotNull(rrsetAdditionsPerChange);
70+
this.rrsetDeletionsPerChange = checkNotNull(rrsetDeletionsPerChange);
71+
this.rrsetsPerManagedZone = checkNotNull(rrsetsPerManagedZone);
72+
this.totalRrdataSizePerChange = checkNotNull(totalRrdataSizePerChange);
73+
}
74+
75+
/**
76+
* Returns the maximum allowed number of managed zones in the project.
77+
*/
78+
public Integer zones() {
79+
return zones;
80+
}
81+
82+
/**
83+
* Returns the maximum allowed number of records per {@link DnsRecord}.
84+
*/
85+
public Integer resourceRecordsPerRrset() {
86+
return resourceRecordsPerRrset;
87+
}
88+
89+
/**
90+
* Returns the maximum allowed number of {@link DnsRecord}s to add per {@code ChangesRequest}.
91+
*/
92+
public Integer rrsetAdditionsPerChange() {
93+
return rrsetAdditionsPerChange;
94+
}
95+
96+
/**
97+
* Returns the maximum allowed number of {@link DnsRecord}s to delete per {@code
98+
* ChangesRequest}.
99+
*/
100+
public Integer rrsetDeletionsPerChange() {
101+
return rrsetDeletionsPerChange;
102+
}
103+
104+
/**
105+
* Returns the maximum allowed number of {@link DnsRecord}s per {@link ManagedZone} in the
106+
* project.
107+
*/
108+
public Integer rrsetsPerManagedZone() {
109+
return rrsetsPerManagedZone;
110+
}
111+
112+
/**
113+
* Returns the maximum allowed size for total records in one ChangesRequest in bytes.
114+
*/
115+
public Integer totalRrdataSizePerChange() {
116+
return totalRrdataSizePerChange;
117+
}
118+
119+
@Override
120+
public boolean equals(Object o) {
121+
return (o instanceof Quota) && this.toPb().equals(((Quota) o).toPb());
122+
}
123+
124+
@Override
125+
public int hashCode() {
126+
return Objects.hash(zones, resourceRecordsPerRrset, rrsetAdditionsPerChange,
127+
rrsetDeletionsPerChange, rrsetsPerManagedZone, totalRrdataSizePerChange);
128+
}
129+
130+
com.google.api.services.dns.model.Quota toPb() {
131+
com.google.api.services.dns.model.Quota pb = new com.google.api.services.dns.model.Quota();
132+
pb.setManagedZones(zones);
133+
pb.setResourceRecordsPerRrset(resourceRecordsPerRrset);
134+
pb.setRrsetAdditionsPerChange(rrsetAdditionsPerChange);
135+
pb.setRrsetDeletionsPerChange(rrsetDeletionsPerChange);
136+
pb.setRrsetsPerManagedZone(rrsetsPerManagedZone);
137+
pb.setTotalRrdataSizePerChange(totalRrdataSizePerChange);
138+
return pb;
139+
}
140+
141+
static Quota fromPb(com.google.api.services.dns.model.Quota pb) {
142+
Quota q = new Quota(pb.getManagedZones(),
143+
pb.getResourceRecordsPerRrset(),
144+
pb.getRrsetAdditionsPerChange(),
145+
pb.getRrsetDeletionsPerChange(),
146+
pb.getRrsetsPerManagedZone(),
147+
pb.getTotalRrdataSizePerChange()
148+
);
149+
return q;
150+
}
151+
152+
@Override
153+
public String toString() {
154+
return MoreObjects.toStringHelper(this)
155+
.add("zones", zones)
156+
.add("resourceRecordsPerRrset", resourceRecordsPerRrset)
157+
.add("rrsetAdditionsPerChange", rrsetAdditionsPerChange)
158+
.add("rrsetDeletionsPerChange", rrsetDeletionsPerChange)
159+
.add("rrsetsPerManagedZone", rrsetsPerManagedZone)
160+
.add("totalRrdataSizePerChange", totalRrdataSizePerChange)
161+
.toString();
162+
}
163+
}
164+
165+
/**
166+
* A builder for {@code ProjectInfo}.
167+
*/
168+
static class Builder {
169+
private String id;
170+
private BigInteger number;
171+
private Quota quota;
172+
173+
private Builder() {
174+
}
175+
176+
/**
177+
* Sets an id of the project.
178+
*/
179+
Builder id(String id) {
180+
this.id = checkNotNull(id);
181+
return this;
182+
}
183+
184+
/**
185+
* Sets a number of the project.
186+
*/
187+
Builder number(BigInteger number) {
188+
this.number = checkNotNull(number);
189+
return this;
190+
}
191+
192+
/**
193+
* Sets quotas assigned to the project.
194+
*/
195+
Builder quota(Quota quota) {
196+
this.quota = checkNotNull(quota);
197+
return this;
198+
}
199+
200+
/**
201+
* Builds an instance of the {@code ProjectInfo}.
202+
*/
203+
ProjectInfo build() {
204+
return new ProjectInfo(this);
205+
}
206+
}
207+
208+
private ProjectInfo(Builder b) {
209+
this.id = b.id;
210+
this.number = b.number;
211+
this.quota = b.quota;
212+
}
213+
214+
/**
215+
* Returns a builder for {@code ProjectInfo}.
216+
*/
217+
static Builder builder() {
218+
return new Builder();
219+
}
220+
221+
/**
222+
* Returns the user-assigned unique identifier for the project.
223+
*/
224+
public String id() {
225+
return id;
226+
}
227+
228+
/**
229+
* Returns the unique numeric identifier for the project.
230+
*/
231+
public BigInteger number() {
232+
return number;
233+
}
234+
235+
/**
236+
* Returns the {@code Quota} object which contains quotas assigned to this project.
237+
*/
238+
public Quota quota() {
239+
return quota;
240+
}
241+
242+
com.google.api.services.dns.model.Project toPb() {
243+
com.google.api.services.dns.model.Project pb = new com.google.api.services.dns.model.Project();
244+
pb.setId(id());
245+
pb.setNumber(number());
246+
if (this.quota() != null) {
247+
pb.setQuota(quota().toPb());
248+
}
249+
return pb;
250+
}
251+
252+
static ProjectInfo fromPb(com.google.api.services.dns.model.Project pb) {
253+
Builder b = builder();
254+
if (pb.getId() != null) {
255+
b.id(pb.getId());
256+
}
257+
if (pb.getNumber() != null) {
258+
b.number(pb.getNumber());
259+
}
260+
if (pb.getQuota() != null) {
261+
b.quota(Quota.fromPb(pb.getQuota()));
262+
}
263+
return b.build();
264+
}
265+
266+
@Override
267+
public boolean equals(Object o) {
268+
return (o instanceof ProjectInfo) && this.toPb().equals(((ProjectInfo) o).toPb());
269+
}
270+
271+
@Override
272+
public int hashCode() {
273+
return Objects.hash(id, number, quota);
274+
}
275+
276+
@Override
277+
public String toString() {
278+
return MoreObjects.toStringHelper(this)
279+
.add("id", id)
280+
.add("number", number)
281+
.add("quota", quota)
282+
.toString();
283+
}
284+
}

0 commit comments

Comments
 (0)