Search in sources :

Example 1 with ImageList

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

the class GoogleComputeClient method listImages.

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

Example 2 with ImageList

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

the class HttpComputeRpc method listImages.

@Override
public Tuple<String, Iterable<Image>> listImages(String project, Map<Option, ?> options) {
    try {
        ImageList imageList = compute.images().list(project).setFilter(Option.FILTER.getString(options)).setMaxResults(Option.MAX_RESULTS.getLong(options)).setPageToken(Option.PAGE_TOKEN.getString(options)).setFields(Option.FIELDS.getString(options)).execute();
        Iterable<Image> images = imageList.getItems();
        return Tuple.of(imageList.getNextPageToken(), images);
    } catch (IOException ex) {
        throw translate(ex);
    }
}
Also used : IOException(java.io.IOException) Image(com.google.api.services.compute.model.Image) ImageList(com.google.api.services.compute.model.ImageList)

Aggregations

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