createSnapshot method

Future<CreateSnapshotOutput> createSnapshot({
  1. required String snapshotDescription,
  2. required String volumeARN,
  3. List<Tag>? tags,
})

Initiates a snapshot of a volume.

AWS Storage Gateway provides the ability to back up point-in-time snapshots of your data to Amazon Simple Storage (Amazon S3) for durable off-site recovery, as well as import the data to an Amazon Elastic Block Store (EBS) volume in Amazon Elastic Compute Cloud (EC2). You can take snapshots of your gateway volume on a scheduled or ad hoc basis. This API enables you to take an ad hoc snapshot. For more information, see Editing a snapshot schedule.

In the CreateSnapshot request, you identify the volume by providing its Amazon Resource Name (ARN). You must also provide description for the snapshot. When AWS Storage Gateway takes the snapshot of specified volume, the snapshot and description appears in the AWS Storage Gateway console. In response, AWS Storage Gateway returns you a snapshot ID. You can use this snapshot ID to check the snapshot progress or later use it when you want to create a volume from a snapshot. This operation is only supported in stored and cached volume gateway type.

May throw InvalidGatewayRequestException. May throw InternalServerError. May throw ServiceUnavailableError.

Parameter snapshotDescription : Textual description of the snapshot that appears in the Amazon EC2 console, Elastic Block Store snapshots panel in the Description field, and in the AWS Storage Gateway snapshot Details pane, Description field.

Parameter volumeARN : The Amazon Resource Name (ARN) of the volume. Use the ListVolumes operation to return a list of gateway volumes.

Parameter tags : A list of up to 50 tags that can be assigned to a snapshot. Each tag is a key-value pair.

Implementation

Future<CreateSnapshotOutput> createSnapshot({
  required String snapshotDescription,
  required String volumeARN,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(snapshotDescription, 'snapshotDescription');
  _s.validateStringLength(
    'snapshotDescription',
    snapshotDescription,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(volumeARN, 'volumeARN');
  _s.validateStringLength(
    'volumeARN',
    volumeARN,
    50,
    500,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'StorageGateway_20130630.CreateSnapshot'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'SnapshotDescription': snapshotDescription,
      'VolumeARN': volumeARN,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateSnapshotOutput.fromJson(jsonResponse.body);
}