Search in sources :

Example 1 with SubnetworkAggregatedList

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

the class HttpComputeRpc method listSubnetworks.

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

Aggregations

Subnetwork (com.google.api.services.compute.model.Subnetwork)1 SubnetworkAggregatedList (com.google.api.services.compute.model.SubnetworkAggregatedList)1 SubnetworksScopedList (com.google.api.services.compute.model.SubnetworksScopedList)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1