Example usage for com.amazonaws.services.ec2.model DescribeImagesRequest getImageIds

List of usage examples for com.amazonaws.services.ec2.model DescribeImagesRequest getImageIds

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DescribeImagesRequest getImageIds.

Prototype


public java.util.List<String> getImageIds() 

Source Link

Document

The image IDs.

Usage

From source file:com.netflix.edda.EddaEc2Client.java

License:Apache License

public DescribeImagesResult describeImages(DescribeImagesRequest request) {
    validateEmpty("ExecutableUsers", request.getExecutableUsers());
    List<Filter> filters = request.getFilters();
    String path = "aws/images";
    if (filters != null && filters.size() > 0) {
        if (filters.size() == 1 && filters.get(0) != null && "is-public".equals(filters.get(0).getName())
                && filters.get(0).getValues() != null && filters.get(0).getValues().size() == 1
                && "false".equals(filters.get(0).getValues().get(0))) {
            path = "view/images";
        } else {/* w w w. j a  va2  s .c  o m*/
            throw new UnsupportedOperationException("filters only support is-public=false");
        }
    }

    TypeReference<List<Image>> ref = new TypeReference<List<Image>>() {
    };
    String url = config.url() + "/api/v2/" + path + ";_expand";
    try {
        List<Image> images = parse(ref, doGet(url));

        List<String> owners = request.getOwners();
        List<String> ids = request.getImageIds();
        if (shouldFilter(owners) || shouldFilter(ids)) {
            List<Image> is = new ArrayList<Image>();
            for (Image i : images) {
                if (matches(owners, i.getOwnerId()) && matches(ids, i.getImageId()))
                    is.add(i);
            }
            images = is;
        }

        return new DescribeImagesResult().withImages(images);
    } catch (IOException e) {
        throw new AmazonClientException("Faled to parse " + url, e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DescribeImagesResult describeImages(DescribeImagesRequest describeImagesRequest) {
    try {/*from   ww  w  .  j  a  v a 2 s .com*/
        List<ImageDescription> descriptions = jec2.describeImages(describeImagesRequest.getImageIds(),
                describeImagesRequest.getOwners(), describeImagesRequest.getExecutableUsers(), null);
        List<Image> images = new ImageConverter().convert(descriptions);
        return new DescribeImagesResult().withImages(images);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}