Java源码示例:com.amazonaws.services.ec2.model.DescribeSnapshotsRequest
示例1
/**
* 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;
}
示例2
@Override
public SnapshotCollection getSnapshots(DescribeSnapshotsRequest request) {
ResourceCollectionImpl result = resource.getCollection("Snapshots",
request);
if (result == null) return null;
return new SnapshotCollectionImpl(result);
}
示例3
@Override
public SnapshotCollection getSnapshots(DescribeSnapshotsRequest request) {
ResourceCollectionImpl result = service.getCollection("Snapshots",
request);
if (result == null) return null;
return new SnapshotCollectionImpl(result);
}
示例4
@Override
public SnapshotCollection getSnapshots() {
return getSnapshots((DescribeSnapshotsRequest)null);
}
示例5
@Override
public boolean load(DescribeSnapshotsRequest request) {
return load(request, null);
}
示例6
@Override
public boolean load(DescribeSnapshotsRequest request,
ResultCapture<DescribeSnapshotsResult> extractor) {
return resource.load(request, extractor);
}
示例7
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);
}
示例8
/**
* 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);
示例9
/**
* 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);
示例10
/**
* Retrieves the Snapshots collection referenced by this resource.
*/
SnapshotCollection getSnapshots(DescribeSnapshotsRequest request);
示例11
/**
* Retrieves the Snapshots collection referenced by this resource.
*/
SnapshotCollection getSnapshots(DescribeSnapshotsRequest request);