use of com.google.api.services.compute.model.InstancesScopedList in project google-cloud-java by GoogleCloudPlatform.
the class HttpComputeRpc method listInstances.
@Override
public Tuple<String, Iterable<Instance>> listInstances(Map<Option, ?> options) {
try {
InstanceAggregatedList aggregatedList = compute.instances().aggregatedList(this.options.getProjectId()).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).execute();
ImmutableList.Builder<Instance> builder = ImmutableList.builder();
Map<String, InstancesScopedList> scopedList = aggregatedList.getItems();
if (scopedList != null) {
for (InstancesScopedList instancesScopedList : scopedList.values()) {
if (instancesScopedList.getInstances() != null) {
builder.addAll(instancesScopedList.getInstances());
}
}
}
return Tuple.<String, Iterable<Instance>>of(aggregatedList.getNextPageToken(), builder.build());
} catch (IOException ex) {
throw translate(ex);
}
}
Aggregations