16
16
17
17
package com .google .gcloud .compute ;
18
18
19
+ import com .google .api .client .util .DateTime ;
19
20
import com .google .common .base .Function ;
20
21
import com .google .common .base .MoreObjects ;
21
22
@@ -48,34 +49,32 @@ public com.google.api.services.compute.model.DiskType apply(DiskType diskType) {
48
49
49
50
private static final long serialVersionUID = -944042261695072026L ;
50
51
51
- private final BigInteger id ;
52
+ private final String id ;
52
53
private final DiskTypeId diskTypeId ;
53
- private final String creationTimestamp ;
54
+ private final Long creationTimestamp ;
54
55
private final String description ;
55
56
private final String validDiskSize ;
56
- private final String selfLink ;
57
57
private final Long defaultDiskSizeGb ;
58
58
private final DeprecationStatus <DiskTypeId > deprecationStatus ;
59
59
60
60
static final class Builder {
61
61
62
- private BigInteger id ;
62
+ private String id ;
63
63
private DiskTypeId diskTypeId ;
64
- private String creationTimestamp ;
64
+ private Long creationTimestamp ;
65
65
private String description ;
66
66
private String validDiskSize ;
67
- private String selfLink ;
68
67
private Long defaultDiskSizeGb ;
69
68
private DeprecationStatus <DiskTypeId > deprecationStatus ;
70
69
71
70
private Builder () {}
72
71
73
- Builder id (BigInteger id ) {
72
+ Builder id (String id ) {
74
73
this .id = id ;
75
74
return this ;
76
75
}
77
76
78
- Builder creationTimestamp (String creationTimestamp ) {
77
+ Builder creationTimestamp (Long creationTimestamp ) {
79
78
this .creationTimestamp = creationTimestamp ;
80
79
return this ;
81
80
}
@@ -95,11 +94,6 @@ Builder validDiskSize(String validDiskSize) {
95
94
return this ;
96
95
}
97
96
98
- Builder selfLink (String selfLink ) {
99
- this .selfLink = selfLink ;
100
- return this ;
101
- }
102
-
103
97
Builder defaultDiskSizeGb (Long defaultDiskSizeGb ) {
104
98
this .defaultDiskSizeGb = defaultDiskSizeGb ;
105
99
return this ;
@@ -121,17 +115,14 @@ private DiskType(Builder builder) {
121
115
this .diskTypeId = builder .diskTypeId ;
122
116
this .description = builder .description ;
123
117
this .validDiskSize = builder .validDiskSize ;
124
- this .selfLink = builder .selfLink ;
125
118
this .defaultDiskSizeGb = builder .defaultDiskSizeGb ;
126
119
this .deprecationStatus = builder .deprecationStatus ;
127
120
}
128
121
129
122
/**
130
- * Returns the creation timestamp in RFC3339 text format.
131
- *
132
- * @see <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC3339</a>
123
+ * Returns the creation timestamp in milliseconds since epoch.
133
124
*/
134
- public String creationTimestamp () {
125
+ public Long creationTimestamp () {
135
126
return creationTimestamp ;
136
127
}
137
128
@@ -145,7 +136,7 @@ public DiskTypeId diskTypeId() {
145
136
/**
146
137
* Returns an unique identifier for the disk type; defined by the service.
147
138
*/
148
- public BigInteger id () {
139
+ public String id () {
149
140
return id ;
150
141
}
151
142
@@ -163,13 +154,6 @@ public String validDiskSize() {
163
154
return validDiskSize ;
164
155
}
165
156
166
- /**
167
- * Returns a service-defined URL for the disk type.
168
- */
169
- public String selfLink () {
170
- return selfLink ;
171
- }
172
-
173
157
/**
174
158
* Returns the service-defined default disk size in GB.
175
159
*/
@@ -193,7 +177,6 @@ public String toString() {
193
177
.add ("creationTimestamp" , creationTimestamp )
194
178
.add ("description" , description )
195
179
.add ("validDiskSize" , validDiskSize )
196
- .add ("selfLink" , selfLink )
197
180
.add ("defaultDiskSizeGb" , defaultDiskSizeGb )
198
181
.add ("deprecationStatus" , deprecationStatus )
199
182
.toString ();
@@ -212,13 +195,17 @@ public boolean equals(Object obj) {
212
195
com .google .api .services .compute .model .DiskType toPb () {
213
196
com .google .api .services .compute .model .DiskType diskTypePb =
214
197
new com .google .api .services .compute .model .DiskType ();
215
- diskTypePb .setId (id );
216
- diskTypePb .setCreationTimestamp (creationTimestamp );
198
+ if (id != null ) {
199
+ diskTypePb .setId (new BigInteger (id ));
200
+ }
201
+ if (creationTimestamp != null ) {
202
+ diskTypePb .setCreationTimestamp (new DateTime (creationTimestamp ).toStringRfc3339 ());
203
+ }
217
204
diskTypePb .setDescription (description );
218
205
diskTypePb .setValidDiskSize (validDiskSize );
219
- diskTypePb .setSelfLink (selfLink );
206
+ diskTypePb .setSelfLink (diskTypeId . selfLink () );
220
207
diskTypePb .setDefaultDiskSizeGb (defaultDiskSizeGb );
221
- diskTypePb .setZone (diskTypeId .zoneId ().toUrl ());
208
+ diskTypePb .setZone (diskTypeId .zoneId ().selfLink ());
222
209
if (deprecationStatus != null ) {
223
210
diskTypePb .setDeprecated (deprecationStatus .toPb ());
224
211
}
@@ -231,12 +218,16 @@ static Builder builder() {
231
218
232
219
static DiskType fromPb (com .google .api .services .compute .model .DiskType diskTypePb ) {
233
220
Builder builder = builder ();
234
- builder .id (diskTypePb .getId ());
235
- builder .creationTimestamp (diskTypePb .getCreationTimestamp ());
221
+ if (diskTypePb .getId () != null ) {
222
+ builder .id (diskTypePb .getId ().toString ());
223
+ }
224
+ if (diskTypePb .getCreationTimestamp () != null ) {
225
+ builder .creationTimestamp (
226
+ DateTime .parseRfc3339 (diskTypePb .getCreationTimestamp ()).getValue ());
227
+ }
236
228
builder .diskTypeId (DiskTypeId .fromUrl (diskTypePb .getSelfLink ()));
237
229
builder .description (diskTypePb .getDescription ());
238
230
builder .validDiskSize (diskTypePb .getValidDiskSize ());
239
- builder .selfLink (diskTypePb .getSelfLink ());
240
231
builder .defaultDiskSizeGb (diskTypePb .getDefaultDiskSizeGb ());
241
232
if (diskTypePb .getDeprecated () != null ) {
242
233
builder .deprecationStatus (
0 commit comments