Example usage for com.amazonaws.services.ec2.model DescribeSnapshotsRequest setSnapshotIds

List of usage examples for com.amazonaws.services.ec2.model DescribeSnapshotsRequest setSnapshotIds

Introduction

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

Prototype


public void setSnapshotIds(java.util.Collection<String> snapshotIds) 

Source Link

Document

The snapshot IDs.

Usage

From source file:com.netflix.simianarmy.client.aws.AWSClient.java

License:Apache License

/**
 * Describe a set of specific EBS snapshots.
 *
 * @param snapshotIds the snapshot ids/*from   w ww.j a v a 2  s.  com*/
 * @return the snapshots
 */
public List<Snapshot> describeSnapshots(String... snapshotIds) {
    if (snapshotIds == null || snapshotIds.length == 0) {
        LOGGER.info(String.format("Getting all EBS snapshots in region %s.", region));
    } else {
        LOGGER.info(
                String.format("Getting EBS snapshotIds for %d ids in region %s.", snapshotIds.length, region));
    }

    AmazonEC2 ec2Client = ec2Client();
    DescribeSnapshotsRequest request = new DescribeSnapshotsRequest();
    // Set the owner id to self to avoid getting snapshots from other accounts.
    request.withOwnerIds(Arrays.<String>asList("self"));
    if (snapshotIds != null) {
        request.setSnapshotIds(Arrays.asList(snapshotIds));
    }
    DescribeSnapshotsResult result = ec2Client.describeSnapshots(request);
    List<Snapshot> snapshots = result.getSnapshots();

    LOGGER.info(String.format("Got %d EBS snapshots in region %s.", snapshots.size(), region));
    return snapshots;
}