Search in sources :

Example 1 with MachineTypeAggregatedList

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);
    }
}
Also used : MachineTypesScopedList(com.google.api.services.compute.model.MachineTypesScopedList) ImmutableList(com.google.common.collect.ImmutableList) MachineType(com.google.api.services.compute.model.MachineType) IOException(java.io.IOException) MachineTypeAggregatedList(com.google.api.services.compute.model.MachineTypeAggregatedList)

Aggregations

MachineType (com.google.api.services.compute.model.MachineType)1 MachineTypeAggregatedList (com.google.api.services.compute.model.MachineTypeAggregatedList)1 MachineTypesScopedList (com.google.api.services.compute.model.MachineTypesScopedList)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1