/** * Creates a snapshot and return the snapshot id. */ public static String createSnapshot(VerificationHost host, AmazonEC2Client client, String volumeId) { CreateSnapshotRequest req = new CreateSnapshotRequest() .withVolumeId(volumeId); CreateSnapshotResult res = client.createSnapshot(req); String snapshotId = res.getSnapshot().getSnapshotId(); Filter filter = new Filter().withName(SNAPSHOT_ID_ATTRIBUTE).withValues(snapshotId); DescribeSnapshotsRequest snapshotsRequest = new DescribeSnapshotsRequest() .withSnapshotIds(snapshotId) .withFilters(filter); host.waitFor("Timeout waiting for creating snapshot", () -> { DescribeSnapshotsResult snapshotsResult = client.describeSnapshots(snapshotsRequest); String state = snapshotsResult.getSnapshots().get(0).getState(); if (state.equalsIgnoreCase(SNAPSHOT_STATUS_COMPLETE)) { return true; } return false; }); return snapshotId; }
@Override public Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor) { ActionResult result = resource.performAction("CreateSnapshot", request, extractor); if (result == null) return null; return new SnapshotImpl(result.getResource()); }
@Override public Snapshot createSnapshot(String description, ResultCapture<CreateSnapshotResult> extractor) { CreateSnapshotRequest request = new CreateSnapshotRequest() .withDescription(description); return createSnapshot(request, extractor); }
@Override public Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor) { ActionResult result = service.performAction("CreateSnapshot", request, extractor); if (result == null) return null; return new SnapshotImpl(result.getResource()); }
@Override public Snapshot createSnapshot(String description, String volumeId, ResultCapture<CreateSnapshotResult> extractor) { CreateSnapshotRequest request = new CreateSnapshotRequest() .withDescription(description) .withVolumeId(volumeId); return createSnapshot(request, extractor); }
@Override public CreateSnapshotResult createSnapshot(CreateSnapshotRequest createSnapshotRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public Snapshot createSnapshot(CreateSnapshotRequest request) { return createSnapshot(request, null); }
private CreateSnapshotRequest prepareCreateSnapshotRequest(CreateVolumeResult volumeResult) { return new CreateSnapshotRequest().withVolumeId(volumeResult.getVolume().getVolumeId()).withDescription(ENCRYPTED_SNAPSHOT); }
/** * Performs the <code>CreateSnapshot</code> action. * * <p> * * @return The <code>Snapshot</code> resource object associated with the * result of this action. * @see CreateSnapshotRequest */ com.amazonaws.resources.ec2.Snapshot createSnapshot(CreateSnapshotRequest request);
/** * Performs the <code>CreateSnapshot</code> action and use a ResultCapture * to retrieve the low-level client response. * * <p> * * @return The <code>Snapshot</code> resource object associated with the * result of this action. * @see CreateSnapshotRequest */ com.amazonaws.resources.ec2.Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor);
/** * Performs the <code>CreateSnapshot</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Volume</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VolumeId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The <code>Snapshot</code> resource object associated with the * result of this action. * @see CreateSnapshotRequest */ Snapshot createSnapshot(CreateSnapshotRequest request);
/** * Performs the <code>CreateSnapshot</code> action and use a ResultCapture * to retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Volume</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VolumeId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The <code>Snapshot</code> resource object associated with the * result of this action. * @see CreateSnapshotRequest */ Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor);