Search in sources :

Example 1 with DiskAggregatedList

use of com.google.api.services.compute.model.DiskAggregatedList in project google-cloud-java by GoogleCloudPlatform.

the class HttpComputeRpc method listDisks.

@Override
public Tuple<String, Iterable<Disk>> listDisks(Map<Option, ?> options) {
    try {
        DiskAggregatedList aggregatedList = compute.disks().aggregatedList(this.options.getProjectId()).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).execute();
        ImmutableList.Builder<Disk> builder = ImmutableList.builder();
        Map<String, DisksScopedList> scopedList = aggregatedList.getItems();
        if (scopedList != null) {
            for (DisksScopedList disksScopedList : scopedList.values()) {
                if (disksScopedList.getDisks() != null) {
                    builder.addAll(disksScopedList.getDisks());
                }
            }
        }
        return Tuple.<String, Iterable<Disk>>of(aggregatedList.getNextPageToken(), builder.build());
    } catch (IOException ex) {
        throw translate(ex);
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) DiskAggregatedList(com.google.api.services.compute.model.DiskAggregatedList) IOException(java.io.IOException) AttachedDisk(com.google.api.services.compute.model.AttachedDisk) Disk(com.google.api.services.compute.model.Disk) DisksScopedList(com.google.api.services.compute.model.DisksScopedList)

Aggregations

AttachedDisk (com.google.api.services.compute.model.AttachedDisk)1 Disk (com.google.api.services.compute.model.Disk)1 DiskAggregatedList (com.google.api.services.compute.model.DiskAggregatedList)1 DisksScopedList (com.google.api.services.compute.model.DisksScopedList)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1