Skip to content

Commit 72765a2

Browse files
committed
---
yaml --- r: 3911 b: refs/heads/pubsub-alpha c: d34490f h: refs/heads/master i: 3909: cccc28f 3907: d12c6d7 3903: 5d2ec58
1 parent 4bbf4c3 commit 72765a2

8 files changed

Lines changed: 114 additions & 6 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: 35fc77d4127abfdd6fe2d7c8121ae7df14449024
5+
refs/heads/pubsub-alpha: d34490f196965a6b71e7f84b3a43c17de98d30fd
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/gcloud-java-compute/src/main/java/com/google/gcloud/compute/DeprecationStatus.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ public final class DeprecationStatus<T extends ResourceId> implements Serializab
4040
*/
4141
public enum Status {
4242
/**
43-
* Operations that create Google Compute Engine entity using a deprecated resource will return
43+
* Operations that create a Google Compute Engine entity using a deprecated resource will return
4444
* successfully but with a warning indicating the deprecation and suggesting a replacement.
4545
*/
4646
DEPRECATED,
47+
4748
/**
48-
* Operations that create Google Compute Engine entity using an obsolete resource will be
49+
* Operations that create a Google Compute Engine entity using an obsolete resource will be
4950
* rejected and result in an error.
5051
*/
5152
OBSOLETE,
53+
5254
/**
53-
* Operations that create Google Compute Engine entity using a deleted resource will be
55+
* Operations that create a Google Compute Engine entity using a deleted resource will be
5456
* rejected and result in an error.
5557
*/
5658
DELETED

branches/pubsub-alpha/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Region.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public com.google.api.services.compute.model.Region apply(Region region) {
5858
private final Status status;
5959
private final List<ZoneId> zones;
6060
private final List<Quota> quotas;
61+
private final DeprecationStatus<RegionId> deprecationStatus;
6162

6263
/**
6364
* Status of the region.
@@ -160,6 +161,7 @@ static final class Builder {
160161
private Status status;
161162
private List<ZoneId> zones;
162163
private List<Quota> quotas;
164+
private DeprecationStatus<RegionId> deprecationStatus;
163165

164166
private Builder() {}
165167

@@ -203,6 +205,11 @@ Builder quotas(List<Quota> quotas) {
203205
return this;
204206
}
205207

208+
Builder deprecationStatus(DeprecationStatus<RegionId> deprecationStatus) {
209+
this.deprecationStatus = deprecationStatus;
210+
return this;
211+
}
212+
206213
Region build() {
207214
return new Region(this);
208215
}
@@ -217,40 +224,76 @@ private Region(Builder builder) {
217224
this.status = builder.status;
218225
this.zones = builder.zones;
219226
this.quotas = builder.quotas;
227+
this.deprecationStatus = builder.deprecationStatus;
220228
}
221229

230+
/**
231+
* Returns the region's identity.
232+
*/
222233
public RegionId regionId() {
223234
return regionId;
224235
}
225236

237+
/**
238+
* Returns an unique identifier for the region; defined by the service.
239+
*/
226240
public BigInteger id() {
227241
return id;
228242
}
229243

244+
/**
245+
* Returns the creation timestamp in RFC3339 text format.
246+
*
247+
* @see <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC3339</a>
248+
*/
230249
public String creationTimestamp() {
231250
return creationTimestamp;
232251
}
233252

253+
/**
254+
* Returns an optional textual description of the region.
255+
*/
234256
public String description() {
235257
return description;
236258
}
237259

260+
/**
261+
* Returns a service-defined URL for the region.
262+
*/
238263
public String selfLink() {
239264
return selfLink;
240265
}
241266

267+
/**
268+
* Returns the status of the status.
269+
*/
242270
public Status status() {
243271
return status;
244272
}
245273

274+
/**
275+
* Returns a list of identities of zones available in this region.
276+
*/
246277
public List<ZoneId> zones() {
247278
return zones;
248279
}
249280

281+
/**
282+
* Returns quotas assigned to this region.
283+
*/
250284
public List<Quota> quotas() {
251285
return quotas;
252286
}
253287

288+
/**
289+
* Returns the deprecation status of the region. If {@link DeprecationStatus#status()} is either
290+
* {@link DeprecationStatus.Status#DELETED} or {@link DeprecationStatus.Status#OBSOLETE} the
291+
* region should not be used. Returns {@code null} if the region is not deprecated.
292+
*/
293+
public DeprecationStatus<RegionId> deprecationStatus() {
294+
return deprecationStatus;
295+
}
296+
254297
@Override
255298
public String toString() {
256299
return MoreObjects.toStringHelper(this)
@@ -262,6 +305,7 @@ public String toString() {
262305
.add("status", status)
263306
.add("zones", zones)
264307
.add("quotas", quotas)
308+
.add("deprecationStatus", deprecationStatus)
265309
.toString();
266310
}
267311

@@ -290,6 +334,9 @@ com.google.api.services.compute.model.Region toPb() {
290334
if (quotas != null) {
291335
regionPb.setQuotas(Lists.transform(quotas, Quota.TO_PB_FUNCTION));
292336
}
337+
if (deprecationStatus != null) {
338+
regionPb.setDeprecated(deprecationStatus.toPb());
339+
}
293340
return regionPb;
294341
}
295342

@@ -313,6 +360,10 @@ static Region fromPb(com.google.api.services.compute.model.Region regionPb) {
313360
if (regionPb.getQuotas() != null) {
314361
builder.quotas(Lists.transform(regionPb.getQuotas(), Quota.FROM_PB_FUNCTION));
315362
}
363+
if (regionPb.getDeprecated() != null) {
364+
builder.deprecationStatus(
365+
DeprecationStatus.fromPb(regionPb.getDeprecated(), RegionId.FROM_URL_FUNCTION));
366+
}
316367
return builder.build();
317368
}
318369
}

branches/pubsub-alpha/gcloud-java-compute/src/main/java/com/google/gcloud/compute/RegionId.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21+
import com.google.common.base.Function;
2122
import com.google.common.base.MoreObjects.ToStringHelper;
2223

2324
import java.util.Objects;
@@ -27,6 +28,19 @@
2728
*/
2829
public final class RegionId extends ResourceId {
2930

31+
static final Function<String, RegionId> FROM_URL_FUNCTION = new Function<String, RegionId>() {
32+
@Override
33+
public RegionId apply(String pb) {
34+
return RegionId.fromUrl(pb);
35+
}
36+
};
37+
static final Function<RegionId, String> TO_URL_FUNCTION = new Function<RegionId, String>() {
38+
@Override
39+
public String apply(RegionId regionId) {
40+
return regionId.toUrl();
41+
}
42+
};
43+
3044
private static final long serialVersionUID = 5569092266957249294L;
3145

3246
private final String region;

branches/pubsub-alpha/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Zone.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public com.google.api.services.compute.model.Zone apply(Zone region) {
5858
private final Status status;
5959
private final List<MaintenanceWindow> maintenanceWindows;
6060
private final RegionId region;
61+
private final DeprecationStatus<ZoneId> deprecationStatus;
6162

6263
/**
6364
* Status of the region.
@@ -185,6 +186,7 @@ static final class Builder {
185186
private Status status;
186187
private List<MaintenanceWindow> maintenanceWindows;
187188
private RegionId region;
189+
private DeprecationStatus<ZoneId> deprecationStatus;
188190

189191
private Builder() {}
190192

@@ -228,6 +230,11 @@ Builder region(RegionId region) {
228230
return this;
229231
}
230232

233+
Builder deprecationStatus(DeprecationStatus<ZoneId> deprecationStatus) {
234+
this.deprecationStatus = deprecationStatus;
235+
return this;
236+
}
237+
231238
Zone build() {
232239
return new Zone(this);
233240
}
@@ -242,6 +249,7 @@ private Zone(Builder builder) {
242249
this.status = builder.status;
243250
this.maintenanceWindows = builder.maintenanceWindows;
244251
this.region = builder.region;
252+
this.deprecationStatus = builder.deprecationStatus;
245253
}
246254

247255
/**
@@ -306,6 +314,15 @@ public RegionId region() {
306314
return region;
307315
}
308316

317+
/**
318+
* Returns the deprecation status of the zone. If {@link DeprecationStatus#status()} is either
319+
* {@link DeprecationStatus.Status#DELETED} or {@link DeprecationStatus.Status#OBSOLETE} the zone
320+
* should not be used. Returns {@code null} if the zone is not deprecated.
321+
*/
322+
public DeprecationStatus<ZoneId> deprecationStatus() {
323+
return deprecationStatus;
324+
}
325+
309326
@Override
310327
public String toString() {
311328
return MoreObjects.toStringHelper(this)
@@ -317,6 +334,7 @@ public String toString() {
317334
.add("status", status)
318335
.add("maintenanceWindows", maintenanceWindows)
319336
.add("region", region)
337+
.add("deprecationStatus", deprecationStatus)
320338
.toString();
321339
}
322340

@@ -346,6 +364,9 @@ com.google.api.services.compute.model.Zone toPb() {
346364
if (region != null) {
347365
zonePb.setRegion(region.toUrl());
348366
}
367+
if (deprecationStatus != null) {
368+
zonePb.setDeprecated(deprecationStatus.toPb());
369+
}
349370
return zonePb;
350371
}
351372

@@ -370,6 +391,10 @@ static Zone fromPb(com.google.api.services.compute.model.Zone zonePb) {
370391
if (zonePb.getRegion() != null) {
371392
builder.region(RegionId.fromUrl(zonePb.getRegion()));
372393
}
394+
if (zonePb.getDeprecated() != null) {
395+
builder.deprecationStatus(
396+
DeprecationStatus.fromPb(zonePb.getDeprecated(), ZoneId.FROM_URL_FUNCTION));
397+
}
373398
return builder.build();
374399
}
375400
}

branches/pubsub-alpha/gcloud-java-compute/src/test/java/com/google/gcloud/compute/DeprecationStatusTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public class DeprecationStatusTest {
2727
private static final String DELETED = "2016-01-20T04:39:00.210-08:00";
2828
private static final String DEPRECATED = "2016-01-20T04:37:00.210-08:00";
2929
private static final String OBSOLETE = "2016-01-20T04:38:00.210-08:00";
30-
private static final DiskTypeId DISK_TYPE_ID = DiskTypeId.of("project", "zone","diskType");
30+
private static final DiskTypeId DISK_TYPE_ID = DiskTypeId.of("project", "zone", "diskType");
3131
private static final MachineTypeId MACHINE_TYPE_ID =
32-
MachineTypeId.of("project", "zone","machineType");
32+
MachineTypeId.of("project", "zone", "machineType");
3333
private static final Status STATUS = Status.DELETED;
3434
private static final DeprecationStatus<DiskTypeId> DISK_TYPE_STATUS =
3535
new DeprecationStatus<>(DELETED, DEPRECATED, OBSOLETE, DISK_TYPE_ID, STATUS);

branches/pubsub-alpha/gcloud-java-compute/src/test/java/com/google/gcloud/compute/RegionTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public class RegionTest {
4040
private static final Region.Quota QUOTA2 =
4141
new Region.Quota("METRIC2", 4, 3);
4242
private static final List<Region.Quota> QUOTAS = ImmutableList.of(QUOTA1, QUOTA2);
43+
private static final String DELETED = "2016-01-20T04:39:00.210-08:00";
44+
private static final String DEPRECATED = "2016-01-20T04:37:00.210-08:00";
45+
private static final String OBSOLETE = "2016-01-20T04:38:00.210-08:00";
46+
private static final DeprecationStatus<RegionId> DEPRECATION_STATUS = new DeprecationStatus<>(
47+
DELETED, DEPRECATED, OBSOLETE, REGION_ID, DeprecationStatus.Status.DELETED);
4348
private static final Region REGION = Region.builder()
4449
.regionId(REGION_ID)
4550
.id(ID)
@@ -49,6 +54,7 @@ public class RegionTest {
4954
.status(STATUS)
5055
.zones(ZONES)
5156
.quotas(QUOTAS)
57+
.deprecationStatus(DEPRECATION_STATUS)
5258
.build();
5359

5460
@Test
@@ -61,6 +67,7 @@ public void testBuilder() {
6167
assertEquals(STATUS, REGION.status());
6268
assertEquals(ZONES, REGION.zones());
6369
assertEquals(QUOTAS, REGION.quotas());
70+
assertEquals(DEPRECATION_STATUS, REGION.deprecationStatus());
6471
}
6572

6673
@Test
@@ -81,6 +88,7 @@ private void compareRegions(Region expected, Region value) {
8188
assertEquals(expected.status(), value.status());
8289
assertEquals(expected.zones(), value.zones());
8390
assertEquals(expected.quotas(), value.quotas());
91+
assertEquals(expected.deprecationStatus(), value.deprecationStatus());
8492
assertEquals(expected.hashCode(), value.hashCode());
8593
}
8694
}

branches/pubsub-alpha/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ZoneTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public class ZoneTest {
3939
private static final MaintenanceWindow WINDOW2 = new MaintenanceWindow("NAME2", "DESCRIPTION2",
4040
"2016-01-21T04:39:00.210-08:00", "2016-01-22T04:39:00.210-08:00");
4141
private static final List<MaintenanceWindow> WINDOWS = ImmutableList.of(WINDOW1, WINDOW2);
42+
private static final String DELETED = "2016-01-20T04:39:00.210-08:00";
43+
private static final String DEPRECATED = "2016-01-20T04:37:00.210-08:00";
44+
private static final String OBSOLETE = "2016-01-20T04:38:00.210-08:00";
45+
private static final DeprecationStatus<ZoneId> DEPRECATION_STATUS = new DeprecationStatus<>(
46+
DELETED, DEPRECATED, OBSOLETE, ZONE_ID, DeprecationStatus.Status.DELETED);
4247
private static final Zone ZONE = Zone.builder()
4348
.zoneId(ZONE_ID)
4449
.id(ID)
@@ -47,6 +52,7 @@ public class ZoneTest {
4752
.selfLink(ZONE_ID.toUrl())
4853
.status(STATUS)
4954
.maintenanceWindows(WINDOWS)
55+
.deprecationStatus(DEPRECATION_STATUS)
5056
.region(REGION_ID)
5157
.build();
5258

@@ -60,6 +66,7 @@ public void testBuilder() {
6066
assertEquals(STATUS, ZONE.status());
6167
assertEquals(WINDOWS, ZONE.maintenanceWindows());
6268
assertEquals(REGION_ID, ZONE.region());
69+
assertEquals(DEPRECATION_STATUS, ZONE.deprecationStatus());
6370
}
6471

6572
@Test
@@ -82,6 +89,7 @@ private void compareZones(Zone expected, Zone value) {
8289
assertEquals(expected.status(), value.status());
8390
assertEquals(expected.maintenanceWindows(), value.maintenanceWindows());
8491
assertEquals(expected.region(), value.region());
92+
assertEquals(expected.deprecationStatus(), value.deprecationStatus());
8593
assertEquals(expected.hashCode(), value.hashCode());
8694
}
8795
}

0 commit comments

Comments
 (0)