17
17
package com .google .gcloud .dns ;
18
18
19
19
import static com .google .common .base .Preconditions .checkArgument ;
20
- import static com .google .gcloud .RetryHelper .RetryHelperException ;
21
20
import static com .google .gcloud .RetryHelper .runWithRetries ;
22
21
23
22
import com .google .api .services .dns .model .Change ;
24
23
import com .google .api .services .dns .model .ManagedZone ;
24
+ import com .google .api .services .dns .model .Project ;
25
25
import com .google .api .services .dns .model .ResourceRecordSet ;
26
26
import com .google .common .base .Function ;
27
27
import com .google .common .collect .ImmutableList ;
@@ -121,8 +121,7 @@ private static Page<Zone> listZones(final DnsOptions serviceOptions,
121
121
// this differs from the other list operations since zone is functional and requires dns service
122
122
Function <ManagedZone , Zone > pbToZoneFunction = new Function <ManagedZone , Zone >() {
123
123
@ Override
124
- public Zone apply (
125
- com .google .api .services .dns .model .ManagedZone zonePb ) {
124
+ public Zone apply (ManagedZone zonePb ) {
126
125
return Zone .fromPb (serviceOptions .service (), zonePb );
127
126
}
128
127
};
@@ -142,7 +141,7 @@ public DnsRpc.ListResult<ManagedZone> call() {
142
141
? ImmutableList .<Zone >of () : Iterables .transform (result .results (), pbToZoneFunction );
143
142
return new PageImpl <>(new ZonePageFetcher (serviceOptions , cursor , optionsMap ),
144
143
cursor , zones );
145
- } catch (RetryHelperException e ) {
144
+ } catch (RetryHelper . RetryHelperException e ) {
146
145
throw DnsException .translateAndThrow (e );
147
146
}
148
147
}
@@ -169,10 +168,10 @@ public DnsRpc.ListResult<Change> call() {
169
168
Iterable <ChangeRequest > changes = result .results () == null
170
169
? ImmutableList .<ChangeRequest >of ()
171
170
: Iterables .transform (result .results (),
172
- ChangeRequest .fromPbFunction (serviceOptions .service (), zoneName ));
171
+ ChangeRequest .fromPbFunction (serviceOptions .service (), zoneName ));
173
172
return new PageImpl <>(new ChangeRequestPageFetcher (zoneName , serviceOptions , cursor ,
174
173
optionsMap ), cursor , changes );
175
- } catch (RetryHelperException e ) {
174
+ } catch (RetryHelper . RetryHelperException e ) {
176
175
throw DnsException .translateAndThrow (e );
177
176
}
178
177
}
@@ -201,7 +200,7 @@ public DnsRpc.ListResult<ResourceRecordSet> call() {
201
200
: Iterables .transform (result .results (), RecordSet .FROM_PB_FUNCTION );
202
201
return new PageImpl <>(new DnsRecordPageFetcher (zoneName , serviceOptions , cursor , optionsMap ),
203
202
cursor , recordSets );
204
- } catch (RetryHelperException e ) {
203
+ } catch (RetryHelper . RetryHelperException e ) {
205
204
throw DnsException .translateAndThrow (e );
206
205
}
207
206
}
@@ -210,10 +209,10 @@ public DnsRpc.ListResult<ResourceRecordSet> call() {
210
209
public Zone create (final ZoneInfo zoneInfo , Dns .ZoneOption ... options ) {
211
210
final Map <DnsRpc .Option , ?> optionsMap = optionMap (options );
212
211
try {
213
- com . google . api . services . dns . model . ManagedZone answer = runWithRetries (
214
- new Callable <com . google . api . services . dns . model . ManagedZone >() {
212
+ ManagedZone answer = runWithRetries (
213
+ new Callable <ManagedZone >() {
215
214
@ Override
216
- public com . google . api . services . dns . model . ManagedZone call () {
215
+ public ManagedZone call () {
217
216
return dnsRpc .create (zoneInfo .toPb (), optionsMap );
218
217
}
219
218
}, options ().retryParams (), EXCEPTION_HANDLER );
@@ -227,10 +226,10 @@ public com.google.api.services.dns.model.ManagedZone call() {
227
226
public Zone getZone (final String zoneName , Dns .ZoneOption ... options ) {
228
227
final Map <DnsRpc .Option , ?> optionsMap = optionMap (options );
229
228
try {
230
- com . google . api . services . dns . model . ManagedZone answer = runWithRetries (
231
- new Callable <com . google . api . services . dns . model . ManagedZone >() {
229
+ ManagedZone answer = runWithRetries (
230
+ new Callable <ManagedZone >() {
232
231
@ Override
233
- public com . google . api . services . dns . model . ManagedZone call () {
232
+ public ManagedZone call () {
234
233
return dnsRpc .getZone (zoneName , optionsMap );
235
234
}
236
235
}, options ().retryParams (), EXCEPTION_HANDLER );
@@ -258,10 +257,10 @@ public Boolean call() {
258
257
public ProjectInfo getProject (Dns .ProjectOption ... fields ) {
259
258
final Map <DnsRpc .Option , ?> optionsMap = optionMap (fields );
260
259
try {
261
- com . google . api . services . dns . model . Project answer = runWithRetries (
262
- new Callable <com . google . api . services . dns . model . Project >() {
260
+ Project answer = runWithRetries (
261
+ new Callable <Project >() {
263
262
@ Override
264
- public com . google . api . services . dns . model . Project call () {
263
+ public Project call () {
265
264
return dnsRpc .getProject (optionsMap );
266
265
}
267
266
}, options ().retryParams (), EXCEPTION_HANDLER );
@@ -276,14 +275,13 @@ public ChangeRequest applyChangeRequest(final String zoneName,
276
275
final ChangeRequestInfo changeRequest , ChangeRequestOption ... options ) {
277
276
final Map <DnsRpc .Option , ?> optionsMap = optionMap (options );
278
277
try {
279
- com .google .api .services .dns .model .Change answer =
280
- runWithRetries (
281
- new Callable <com .google .api .services .dns .model .Change >() {
282
- @ Override
283
- public com .google .api .services .dns .model .Change call () {
284
- return dnsRpc .applyChangeRequest (zoneName , changeRequest .toPb (), optionsMap );
285
- }
286
- }, options ().retryParams (), EXCEPTION_HANDLER );
278
+ Change answer = runWithRetries (
279
+ new Callable <Change >() {
280
+ @ Override
281
+ public Change call () {
282
+ return dnsRpc .applyChangeRequest (zoneName , changeRequest .toPb (), optionsMap );
283
+ }
284
+ }, options ().retryParams (), EXCEPTION_HANDLER );
287
285
return answer == null ? null : ChangeRequest .fromPb (this , zoneName , answer ); // not null
288
286
} catch (RetryHelper .RetryHelperException ex ) {
289
287
throw DnsException .translateAndThrow (ex );
@@ -295,14 +293,13 @@ public ChangeRequest getChangeRequest(final String zoneName, final String change
295
293
Dns .ChangeRequestOption ... options ) {
296
294
final Map <DnsRpc .Option , ?> optionsMap = optionMap (options );
297
295
try {
298
- com .google .api .services .dns .model .Change answer =
299
- runWithRetries (
300
- new Callable <com .google .api .services .dns .model .Change >() {
301
- @ Override
302
- public com .google .api .services .dns .model .Change call () {
303
- return dnsRpc .getChangeRequest (zoneName , changeRequestId , optionsMap );
304
- }
305
- }, options ().retryParams (), EXCEPTION_HANDLER );
296
+ Change answer = runWithRetries (
297
+ new Callable <Change >() {
298
+ @ Override
299
+ public Change call () {
300
+ return dnsRpc .getChangeRequest (zoneName , changeRequestId , optionsMap );
301
+ }
302
+ }, options ().retryParams (), EXCEPTION_HANDLER );
306
303
return answer == null ? null : ChangeRequest .fromPb (this , zoneName , answer );
307
304
} catch (RetryHelper .RetryHelperException ex ) {
308
305
throw DnsException .translateAndThrow (ex );
0 commit comments