Skip to content

Commit cccc28f

Browse files
committed
---
yaml --- r: 3909 b: refs/heads/pubsub-alpha c: c9f028e h: refs/heads/master i: 3907: d12c6d7
1 parent 33c7f28 commit cccc28f

23 files changed

Lines changed: 416 additions & 52 deletions

[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: a566ef45e67da44a9d7c13c69ee3f5b3602f353a
5+
refs/heads/pubsub-alpha: c9f028e46c53e99dc7bace55874967a81284bca5
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/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Authentication
3333

3434
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README.
3535

36-
About Google Cloud BigQuery
36+
About Google Cloud Compute
3737
--------------------------
3838

3939
[Google Cloud Compute][cloud-compute] delivers virtual machines running in Google's innovative data
@@ -65,7 +65,7 @@ Java 7 or above is required for using this client.
6565
Testing
6666
-------
6767

68-
This library has tools to help make tests for code using Cloud BigQuery.
68+
This library has tools to help make tests for code using Cloud Compute.
6969

7070
See [TESTING] to read more about testing.
7171

branches/pubsub-alpha/gcloud-java-compute/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>com.google.apis</groupId>
2626
<artifactId>google-api-services-compute</artifactId>
27-
<version>v1-rev93-1.21.0</version>
27+
<version>v1-rev97-1.21.0</version>
2828
<scope>compile</scope>
2929
<exclusions>
3030
<exclusion>
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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.compute;
18+
19+
import com.google.common.base.Function;
20+
import com.google.common.base.MoreObjects;
21+
22+
import java.io.Serializable;
23+
import java.util.Objects;
24+
25+
/**
26+
* The deprecation status associated to a Google Compute Engine resource.
27+
*/
28+
public final class DeprecationStatus<T extends ResourceId> implements Serializable {
29+
30+
private static final long serialVersionUID = -2695077634793679794L;
31+
32+
private final String deleted;
33+
private final String deprecated;
34+
private final String obsolete;
35+
private final T replacement;
36+
private final Status status;
37+
38+
/**
39+
* The deprecation status of a Google Compute Engine resource.
40+
*/
41+
public enum Status {
42+
/**
43+
* Operations that create Google Compute Engine entity using a deprecated resource will return
44+
* successfully but with a warning indicating the deprecation and suggesting a replacement.
45+
*/
46+
DEPRECATED,
47+
/**
48+
* Operations that create Google Compute Engine entity using an obsolete resource will be
49+
* rejected and result in an error.
50+
*/
51+
OBSOLETE,
52+
/**
53+
* Operations that create Google Compute Engine entity using a deleted resource will be
54+
* rejected and result in an error.
55+
*/
56+
DELETED
57+
}
58+
59+
DeprecationStatus(String deleted, String deprecated, String obsolete, T replacement,
60+
Status status) {
61+
this.deleted = deleted;
62+
this.deprecated = deprecated;
63+
this.obsolete = obsolete;
64+
this.replacement = replacement;
65+
this.status = status;
66+
}
67+
68+
/**
69+
* Returns an optional RFC3339 timestamp on or after which the deprecation state of this resource
70+
* will be changed to {@link Status#DELETED}.
71+
*
72+
* @see <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC3339</a>
73+
*/
74+
public String deleted() {
75+
return deleted;
76+
}
77+
78+
/**
79+
* Returns an optional RFC3339 timestamp on or after which the deprecation state of this resource
80+
* will be changed to {@link Status#DEPRECATED}.
81+
*
82+
* @see <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC3339</a>
83+
*/
84+
public String deprecated() {
85+
return deprecated;
86+
}
87+
88+
/**
89+
* Returns an optional RFC3339 timestamp on or after which the deprecation state of this resource
90+
* will be changed to {@link Status#OBSOLETE}.
91+
*
92+
* @see <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC3339</a>
93+
*/
94+
public String obsolete() {
95+
return obsolete;
96+
}
97+
98+
/**
99+
* Returns the identity of the suggested replacement for a deprecated resource. The suggested
100+
* replacement resource must be the same kind of resource as the deprecated resource.
101+
*/
102+
public T replacement() {
103+
return replacement;
104+
}
105+
106+
/**
107+
* Returns the deprecation state of this resource.
108+
*/
109+
public Status status() {
110+
return status;
111+
}
112+
113+
@Override
114+
public String toString() {
115+
return MoreObjects.toStringHelper(this)
116+
.add("deleted", deleted)
117+
.add("deprecated", deprecated)
118+
.add("obsolete", obsolete)
119+
.add("replacement", replacement)
120+
.add("status", status)
121+
.toString();
122+
}
123+
124+
@Override
125+
public int hashCode() {
126+
return Objects.hash(deleted, deprecated, obsolete, replacement, status);
127+
}
128+
129+
@Override
130+
public boolean equals(Object obj) {
131+
return obj instanceof DeprecationStatus
132+
&& Objects.equals(toPb(), ((DeprecationStatus) obj).toPb());
133+
}
134+
135+
com.google.api.services.compute.model.DeprecationStatus toPb() {
136+
com.google.api.services.compute.model.DeprecationStatus deprecationStatusPb =
137+
new com.google.api.services.compute.model.DeprecationStatus();
138+
deprecationStatusPb.setDeleted(deleted);
139+
deprecationStatusPb.setDeprecated(deprecated);
140+
deprecationStatusPb.setObsolete(obsolete);
141+
if (replacement != null) {
142+
deprecationStatusPb.setReplacement(replacement.toUrl());
143+
}
144+
if (status() != null) {
145+
deprecationStatusPb.setState(status.name());
146+
}
147+
return deprecationStatusPb;
148+
}
149+
150+
static <T extends ResourceId> DeprecationStatus<T> fromPb(
151+
com.google.api.services.compute.model.DeprecationStatus deprecationStatusPb,
152+
Function<String, T> fromUrl) {
153+
return new DeprecationStatus<T>(
154+
deprecationStatusPb.getDeleted(),
155+
deprecationStatusPb.getDeprecated(),
156+
deprecationStatusPb.getObsolete(),
157+
deprecationStatusPb.getReplacement() != null
158+
? fromUrl.apply(deprecationStatusPb.getReplacement()) : null,
159+
deprecationStatusPb.getState() != null
160+
? Status.valueOf(deprecationStatusPb.getState()) : null);
161+
}
162+
}

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import java.util.Objects;
2525

2626
/**
27-
* Google Compute Engine Disk type. A disk type represents the type of disk to use, such as a
27+
* A Google Compute Engine disk type. A disk type represents the type of disk to use, such as
2828
* {@code pd-ssd} or {@code pd-standard}.
29+
*
30+
* @see <a href="https://cloud.google.com/compute/docs/reference/latest/diskTypes">Disk Types</a>
2931
*/
3032
public final class DiskType implements Serializable {
3133

@@ -53,6 +55,7 @@ public com.google.api.services.compute.model.DiskType apply(DiskType diskType) {
5355
private final String validDiskSize;
5456
private final String selfLink;
5557
private final Long defaultDiskSizeGb;
58+
private final DeprecationStatus<DiskTypeId> deprecationStatus;
5659

5760
static final class Builder {
5861

@@ -63,6 +66,7 @@ static final class Builder {
6366
private String validDiskSize;
6467
private String selfLink;
6568
private Long defaultDiskSizeGb;
69+
private DeprecationStatus<DiskTypeId> deprecationStatus;
6670

6771
private Builder() {}
6872

@@ -101,9 +105,11 @@ Builder defaultDiskSizeGb(Long defaultDiskSizeGb) {
101105
return this;
102106
}
103107

104-
/**
105-
* Creates a {@code DiskType} object.
106-
*/
108+
Builder deprecationStatus(DeprecationStatus<DiskTypeId> deprecationStatus) {
109+
this.deprecationStatus = deprecationStatus;
110+
return this;
111+
}
112+
107113
DiskType build() {
108114
return new DiskType(this);
109115
}
@@ -117,6 +123,7 @@ private DiskType(Builder builder) {
117123
this.validDiskSize = builder.validDiskSize;
118124
this.selfLink = builder.selfLink;
119125
this.defaultDiskSizeGb = builder.defaultDiskSizeGb;
126+
this.deprecationStatus = builder.deprecationStatus;
120127
}
121128

122129
/**
@@ -170,6 +177,15 @@ public Long defaultDiskSizeGb() {
170177
return defaultDiskSizeGb;
171178
}
172179

180+
/**
181+
* Returns the deprecation status of the disk type. If {@link DeprecationStatus#status()} is
182+
* either {@link DeprecationStatus.Status#DELETED} or {@link DeprecationStatus.Status#OBSOLETE}
183+
* the disk type should not be used. Returns {@code null} if the disk type is not deprecated.
184+
*/
185+
public DeprecationStatus<DiskTypeId> deprecationStatus() {
186+
return deprecationStatus;
187+
}
188+
173189
@Override
174190
public String toString() {
175191
return MoreObjects.toStringHelper(this)
@@ -179,12 +195,13 @@ public String toString() {
179195
.add("validDiskSize", validDiskSize)
180196
.add("selfLink", selfLink)
181197
.add("defaultDiskSizeGb", defaultDiskSizeGb)
198+
.add("deprecationStatus", deprecationStatus)
182199
.toString();
183200
}
184201

185202
@Override
186203
public int hashCode() {
187-
return Objects.hash(id);
204+
return Objects.hash(diskTypeId);
188205
}
189206

190207
@Override
@@ -204,6 +221,9 @@ com.google.api.services.compute.model.DiskType toPb() {
204221
diskTypePb.setSelfLink(selfLink);
205222
diskTypePb.setDefaultDiskSizeGb(defaultDiskSizeGb);
206223
diskTypePb.setZone(diskTypeId.zoneId().toUrl());
224+
if (deprecationStatus != null) {
225+
diskTypePb.setDeprecated(deprecationStatus.toPb());
226+
}
207227
return diskTypePb;
208228
}
209229

@@ -213,7 +233,7 @@ static Builder builder() {
213233

214234
static DiskType fromPb(com.google.api.services.compute.model.DiskType diskTypePb) {
215235
Builder builder = builder();
216-
if (diskTypePb.getId() != null ) {
236+
if (diskTypePb.getId() != null) {
217237
builder.id(diskTypePb.getId().longValue());
218238
}
219239
builder.creationTimestamp(diskTypePb.getCreationTimestamp());
@@ -222,6 +242,10 @@ static DiskType fromPb(com.google.api.services.compute.model.DiskType diskTypePb
222242
builder.validDiskSize(diskTypePb.getValidDiskSize());
223243
builder.selfLink(diskTypePb.getSelfLink());
224244
builder.defaultDiskSizeGb(diskTypePb.getDefaultDiskSizeGb());
245+
if (diskTypePb.getDeprecated() != null) {
246+
builder.deprecationStatus(
247+
DeprecationStatus.fromPb(diskTypePb.getDeprecated(), DiskTypeId.FROM_URL_FUNCTION));
248+
}
225249
return builder.build();
226250
}
227251
}

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

Lines changed: 15 additions & 1 deletion
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;
2223

2324
import java.util.Objects;
@@ -27,11 +28,24 @@
2728
*/
2829
public final class DiskTypeId extends ZoneResourceId {
2930

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

3246
private final String diskType;
3347

34-
DiskTypeId(String project, String zone, String diskType) {
48+
private DiskTypeId(String project, String zone, String diskType) {
3549
super(project, zone);
3650
this.diskType = checkNotNull(diskType);
3751
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
/**
2727
* A Google Compute Engine License. A License represents a software license. Licenses are used to
2828
* track software usage in images, persistent disks, snapshots, and virtual machine instances.
29+
*
30+
* @see <a href="https://cloud.google.com/compute/docs/reference/latest/licenses">Licenses</a>
2931
*/
3032
public final class License implements Serializable {
3133

@@ -74,7 +76,7 @@ public String toString() {
7476

7577
@Override
7678
public int hashCode() {
77-
return Objects.hash(licenseId, chargesUseFee, selfLink);
79+
return Objects.hash(licenseId);
7880
}
7981

8082
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public String apply(LicenseId licenseId) {
4545

4646
private final String license;
4747

48-
LicenseId(String project, String license) {
48+
private LicenseId(String project, String license) {
4949
super(project);
5050
this.license = checkNotNull(license);
5151
}

0 commit comments

Comments
 (0)