createSnapshot method

Future<CreateSnapshotResponse> createSnapshot({
  1. required String name,
  2. required String volumeId,
  3. String? clientRequestToken,
  4. List<Tag>? tags,
})

Creates a snapshot of an existing Amazon FSx for OpenZFS volume. With snapshots, you can easily undo file changes and compare file versions by restoring the volume to a previous version.

If a snapshot with the specified client request token exists, and the parameters match, this operation returns the description of the existing snapshot. If a snapshot with the specified client request token exists, and the parameters don't match, this operation returns IncompatibleParameterError. If a snapshot with the specified client request token doesn't exist, CreateSnapshot does the following:

  • Creates a new OpenZFS snapshot with an assigned ID, and an initial lifecycle state of CREATING.
  • Returns the description of the snapshot.
By using the idempotent operation, you can retry a CreateSnapshot operation without the risk of creating an extra snapshot. This approach can be useful when an initial call fails in a way that makes it unclear whether a snapshot was created. If you use the same client request token and the initial call created a snapshot, the operation returns a successful result because all the parameters are the same.

The CreateSnapshot operation returns while the snapshot's lifecycle state is still CREATING. You can check the snapshot creation status by calling the DescribeSnapshots operation, which returns the snapshot state along with other information.

May throw BadRequest. May throw InternalServerError. May throw ServiceLimitExceeded. May throw VolumeNotFound.

Parameter name : The name of the snapshot.

Parameter volumeId : The ID of the volume that you are taking a snapshot of.

Implementation

Future<CreateSnapshotResponse> createSnapshot({
  required String name,
  required String volumeId,
  String? clientRequestToken,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSSimbaAPIService_v20180301.CreateSnapshot'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'VolumeId': volumeId,
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateSnapshotResponse.fromJson(jsonResponse.body);
}