use of com.google.cloud.PageImpl in project google-cloud-java by GoogleCloudPlatform.
the class DnsImpl method listRecordSets.
private static Page<RecordSet> listRecordSets(final String zoneName, final DnsOptions serviceOptions, final Map<DnsRpc.Option, ?> optionsMap) {
try {
// get a list of record sets
final DnsRpc rpc = serviceOptions.getDnsRpcV1();
DnsRpc.ListResult<ResourceRecordSet> result = runWithRetries(new Callable<DnsRpc.ListResult<ResourceRecordSet>>() {
@Override
public DnsRpc.ListResult<ResourceRecordSet> call() {
return rpc.listRecordSets(zoneName, optionsMap);
}
}, serviceOptions.getRetrySettings(), EXCEPTION_HANDLER, serviceOptions.getClock());
String cursor = result.pageToken();
// transform that list into record sets
Iterable<RecordSet> recordSets = result.results() == null ? ImmutableList.<RecordSet>of() : Iterables.transform(result.results(), RecordSet.FROM_PB_FUNCTION);
return new PageImpl<>(new RecordSetPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, recordSets);
} catch (RetryHelper.RetryHelperException e) {
throw DnsException.translateAndThrow(e);
}
}
use of com.google.cloud.PageImpl in project google-cloud-java by GoogleCloudPlatform.
the class DnsImpl method listZones.
private static Page<Zone> listZones(final DnsOptions serviceOptions, final Map<DnsRpc.Option, ?> optionsMap) {
try {
// get a list of managed zones
final DnsRpc rpc = serviceOptions.getDnsRpcV1();
DnsRpc.ListResult<ManagedZone> result = runWithRetries(new Callable<DnsRpc.ListResult<ManagedZone>>() {
@Override
public DnsRpc.ListResult<ManagedZone> call() {
return rpc.listZones(optionsMap);
}
}, serviceOptions.getRetrySettings(), EXCEPTION_HANDLER, serviceOptions.getClock());
String cursor = result.pageToken();
// transform that list into zone objects
Iterable<Zone> zones = result.results() == null ? ImmutableList.<Zone>of() : Iterables.transform(result.results(), zoneFromPb(serviceOptions));
return new PageImpl<>(new ZonePageFetcher(serviceOptions, cursor, optionsMap), cursor, zones);
} catch (RetryHelper.RetryHelperException e) {
throw DnsException.translateAndThrow(e);
}
}
use of com.google.cloud.PageImpl in project google-cloud-java by GoogleCloudPlatform.
the class DnsImpl method listChangeRequests.
private static Page<ChangeRequest> listChangeRequests(final String zoneName, final DnsOptions serviceOptions, final Map<DnsRpc.Option, ?> optionsMap) {
try {
// get a list of changes
final DnsRpc rpc = serviceOptions.getDnsRpcV1();
DnsRpc.ListResult<Change> result = runWithRetries(new Callable<DnsRpc.ListResult<Change>>() {
@Override
public DnsRpc.ListResult<Change> call() {
return rpc.listChangeRequests(zoneName, optionsMap);
}
}, serviceOptions.getRetrySettings(), EXCEPTION_HANDLER, serviceOptions.getClock());
String cursor = result.pageToken();
// transform that list into change request objects
Iterable<ChangeRequest> changes = result.results() == null ? ImmutableList.<ChangeRequest>of() : Iterables.transform(result.results(), ChangeRequest.fromPbFunction(serviceOptions.getService(), zoneName));
return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, changes);
} catch (RetryHelper.RetryHelperException e) {
throw DnsException.translateAndThrow(e);
}
}
Aggregations