Search in sources :

Example 1 with MachineTypeList

use of com.google.api.services.compute.model.MachineTypeList in project platformlayer by platformlayer.

the class GoogleComputeClient method listMachineTypes.

private Iterable<MachineType> listMachineTypes(String projectId) throws OpsException {
    List<MachineType> ret = Lists.newArrayList();
    MachineTypeList machineTypeList;
    try {
        log.debug("Listing machine types in project " + projectId);
        machineTypeList = compute.machineTypes().list(projectId).execute();
    } catch (IOException e) {
        throw new OpsException("Error listing machine types", e);
    }
    if (machineTypeList.getItems() != null) {
        ret.addAll(machineTypeList.getItems());
    }
    return ret;
}
Also used : OpsException(org.platformlayer.ops.OpsException) MachineType(com.google.api.services.compute.model.MachineType) IOException(java.io.IOException) MachineTypeList(com.google.api.services.compute.model.MachineTypeList)

Example 2 with MachineTypeList

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

the class HttpComputeRpc method listMachineTypes.

@Override
public Tuple<String, Iterable<MachineType>> listMachineTypes(String zone, Map<Option, ?> options) {
    try {
        MachineTypeList machineTypesList = compute.machineTypes().list(this.options.getProjectId(), zone).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).setFields(Option.FIELDS.getString(options)).execute();
        Iterable<MachineType> machineTypes = machineTypesList.getItems();
        return Tuple.of(machineTypesList.getNextPageToken(), machineTypes);
    } catch (IOException ex) {
        throw translate(ex);
    }
}
Also used : MachineType(com.google.api.services.compute.model.MachineType) IOException(java.io.IOException) MachineTypeList(com.google.api.services.compute.model.MachineTypeList)

Aggregations

MachineType (com.google.api.services.compute.model.MachineType)2 MachineTypeList (com.google.api.services.compute.model.MachineTypeList)2 IOException (java.io.IOException)2 OpsException (org.platformlayer.ops.OpsException)1