getSnapshotBlock method

Future<GetSnapshotBlockResponse> getSnapshotBlock({
  1. required int blockIndex,
  2. required String blockToken,
  3. required String snapshotId,
})

Returns the data in a block in an Amazon Elastic Block Store snapshot.

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

Parameter blockIndex : The block index of the block from which to get data.

Obtain the BlockIndex by running the ListChangedBlocks or ListSnapshotBlocks operations.

Parameter blockToken : The block token of the block from which to get data.

Obtain the BlockToken by running the ListChangedBlocks or ListSnapshotBlocks operations.

Parameter snapshotId : The ID of the snapshot containing the block from which to get data.

Implementation

Future<GetSnapshotBlockResponse> getSnapshotBlock({
  required int blockIndex,
  required String blockToken,
  required String snapshotId,
}) async {
  ArgumentError.checkNotNull(blockIndex, 'blockIndex');
  _s.validateNumRange(
    'blockIndex',
    blockIndex,
    0,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(blockToken, 'blockToken');
  _s.validateStringLength(
    'blockToken',
    blockToken,
    0,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(snapshotId, 'snapshotId');
  _s.validateStringLength(
    'snapshotId',
    snapshotId,
    1,
    64,
    isRequired: true,
  );
  final $query = <String, List<String>>{
    'blockToken': [blockToken],
  };
  final response = await _protocol.sendRaw(
    payload: null,
    method: 'GET',
    requestUri:
        '/snapshots/${Uri.encodeComponent(snapshotId)}/blocks/${Uri.encodeComponent(blockIndex.toString())}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return GetSnapshotBlockResponse(
    blockData: await response.stream.toBytes(),
    checksum: _s.extractHeaderStringValue(response.headers, 'x-amz-Checksum'),
    checksumAlgorithm: _s
        .extractHeaderStringValue(
            response.headers, 'x-amz-Checksum-Algorithm')
        ?.toChecksumAlgorithm(),
    dataLength:
        _s.extractHeaderIntValue(response.headers, 'x-amz-Data-Length'),
  );
}