completeSnapshot method

Future<CompleteSnapshotResponse> completeSnapshot({
  1. required int changedBlocksCount,
  2. required String snapshotId,
  3. String? checksum,
  4. ChecksumAggregationMethod? checksumAggregationMethod,
  5. ChecksumAlgorithm? checksumAlgorithm,
})

Seals and completes the snapshot after all of the required blocks of data have been written to it. Completing the snapshot changes the status to completed. You cannot write new blocks to a snapshot after it has been completed.

May throw AccessDeniedException. May throw ValidationException. May throw ResourceNotFoundException. May throw RequestThrottledException. May throw ServiceQuotaExceededException. May throw InternalServerException.

Parameter changedBlocksCount : The number of blocks that were written to the snapshot.

Parameter snapshotId : The ID of the snapshot.

Parameter checksum : An aggregated Base-64 SHA256 checksum based on the checksums of each written block.

To generate the aggregated checksum using the linear aggregation method, arrange the checksums for each written block in ascending order of their block index, concatenate them to form a single string, and then generate the checksum on the entire string using the SHA256 algorithm.

Parameter checksumAggregationMethod : The aggregation method used to generate the checksum. Currently, the only supported aggregation method is LINEAR.

Parameter checksumAlgorithm : The algorithm used to generate the checksum. Currently, the only supported algorithm is SHA256.

Implementation

Future<CompleteSnapshotResponse> completeSnapshot({
  required int changedBlocksCount,
  required String snapshotId,
  String? checksum,
  ChecksumAggregationMethod? checksumAggregationMethod,
  ChecksumAlgorithm? checksumAlgorithm,
}) async {
  ArgumentError.checkNotNull(changedBlocksCount, 'changedBlocksCount');
  _s.validateNumRange(
    'changedBlocksCount',
    changedBlocksCount,
    0,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(snapshotId, 'snapshotId');
  _s.validateStringLength(
    'snapshotId',
    snapshotId,
    1,
    64,
    isRequired: true,
  );
  _s.validateStringLength(
    'checksum',
    checksum,
    0,
    64,
  );
  final headers = <String, String>{
    'x-amz-ChangedBlocksCount': changedBlocksCount.toString(),
    if (checksum != null) 'x-amz-Checksum': checksum.toString(),
    if (checksumAggregationMethod != null)
      'x-amz-Checksum-Aggregation-Method':
          checksumAggregationMethod.toValue(),
    if (checksumAlgorithm != null)
      'x-amz-Checksum-Algorithm': checksumAlgorithm.toValue(),
  };
  final response = await _protocol.send(
    payload: null,
    method: 'POST',
    requestUri: '/snapshots/completion/${Uri.encodeComponent(snapshotId)}',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CompleteSnapshotResponse.fromJson(response);
}