Search in sources :

Example 1 with AddressAggregatedList

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

the class HttpComputeRpc method listAddresses.

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

Aggregations

Address (com.google.api.services.compute.model.Address)1 AddressAggregatedList (com.google.api.services.compute.model.AddressAggregatedList)1 AddressesScopedList (com.google.api.services.compute.model.AddressesScopedList)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1