com.amazonaws.services.ec2.model.DescribeSnapshotsRequest Java Examples

The following examples show how to use com.amazonaws.services.ec2.model.DescribeSnapshotsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InventoryUtil.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch snapshots.
 *
 * @param temporaryCredentials the temporary credentials
 * @param skipRegions the skip regions
 * @param accountId the accountId
 * @param accountName the account name
 * @return the map
 */
public static Map<String,List<Snapshot>> fetchSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName) {
	Map<String,List<Snapshot>> snapShots = new LinkedHashMap<>();
	String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Snapshot\" , \"region\":\"" ;
	for(Region region : RegionUtils.getRegions()){
		try{
			if(!skipRegions.contains(region.getName())){
				AmazonEC2 ec2Client = AmazonEC2ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
				List<Snapshot> snapShotsList = ec2Client.describeSnapshots(new DescribeSnapshotsRequest().withOwnerIds(accountId)).getSnapshots();// No need to paginate as all results will be returned
				if( !snapShotsList.isEmpty() ){
					log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Snapshot " +region.getName() + " >> "+snapShotsList.size());
					snapShots.put(accountId+delimiter+accountName+delimiter+region.getName(),snapShotsList);
				}
			}

		}catch(Exception e){
			log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
			ErrorManageUtil.uploadError(accountId,region.getName(),"snapshot",e.getMessage());
		}
	}
	return snapShots;
}
 
Example #2
Source File: VolumeImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public SnapshotCollection getSnapshots(DescribeSnapshotsRequest request) {
    ResourceCollectionImpl result = resource.getCollection("Snapshots",
            request);

    if (result == null) return null;
    return new SnapshotCollectionImpl(result);
}
 
Example #3
Source File: EC2Impl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public SnapshotCollection getSnapshots(DescribeSnapshotsRequest request) {
    ResourceCollectionImpl result = service.getCollection("Snapshots",
            request);

    if (result == null) return null;
    return new SnapshotCollectionImpl(result);
}
 
Example #4
Source File: EC2Impl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public SnapshotCollection getSnapshots() {
    return getSnapshots((DescribeSnapshotsRequest)null);
}
 
Example #5
Source File: SnapshotImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public boolean load(DescribeSnapshotsRequest request) {
    return load(request, null);
}
 
Example #6
Source File: SnapshotImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public boolean load(DescribeSnapshotsRequest request,
        ResultCapture<DescribeSnapshotsResult> extractor) {

    return resource.load(request, extractor);
}
 
Example #7
Source File: EncryptedSnapshotService.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
private void checkSnapshotReadiness(AuthenticatedContext ac, AmazonEC2Client client, CreateSnapshotResult snapshotResult) {
    Waiter<DescribeSnapshotsRequest> snapshotWaiter = client.waiters().snapshotCompleted();
    DescribeSnapshotsRequest describeSnapshotsRequest = new DescribeSnapshotsRequest().withSnapshotIds(snapshotResult.getSnapshot().getSnapshotId());
    StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId());
    run(snapshotWaiter, describeSnapshotsRequest, stackCancellationCheck);
}
 
Example #8
Source File: Snapshot.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Makes a call to the service to load this resource's attributes if they
 * are not loaded yet.
 * The following request parameters will be populated from the data of this
 * <code>Snapshot</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>SnapshotIds.0</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return Returns {@code true} if the resource is not yet loaded when this
 *         method was invoked, which indicates that a service call has been
 *         made to retrieve the attributes.
 * @see DescribeSnapshotsRequest
 */
boolean load(DescribeSnapshotsRequest request);
 
Example #9
Source File: Snapshot.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Makes a call to the service to load this resource's attributes if they
 * are not loaded yet, and use a ResultCapture to retrieve the low-level
 * client response
 * The following request parameters will be populated from the data of this
 * <code>Snapshot</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>SnapshotIds.0</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return Returns {@code true} if the resource is not yet loaded when this
 *         method was invoked, which indicates that a service call has been
 *         made to retrieve the attributes.
 * @see DescribeSnapshotsRequest
 */
boolean load(DescribeSnapshotsRequest request,
        ResultCapture<DescribeSnapshotsResult> extractor);
 
Example #10
Source File: EC2.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves the Snapshots collection referenced by this resource.
 */
SnapshotCollection getSnapshots(DescribeSnapshotsRequest request);
 
Example #11
Source File: Volume.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves the Snapshots collection referenced by this resource.
 */
SnapshotCollection getSnapshots(DescribeSnapshotsRequest request);