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