Skip to content

get_snapshot_block

get_snapshot_block(
    snapshot_id: SnapshotId,
    block_index: BlockIndex,
    block_token: BlockToken,
    *,
    config_overrides: Optional[EBSClientConfig] = None,
) -> Generator[GetSnapshotBlockResponse]

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

You should always retry requests that receive server (5xx) error responses, and ThrottlingException and RequestThrottledException client error responses. For more information see Error retries in the Amazon Elastic Compute Cloud User Guide.

Parameters:

  • snapshot_id (SnapshotId) –

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

    If the specified snapshot is encrypted, you must have permission to use the KMS key that was used to encrypt the snapshot. For more information, see Using encryption in the Amazon Elastic Compute Cloud User Guide.

  • block_index (BlockIndex) –

    The block index of the block in which to read the data. A block index is a logical index in units of 512 KiB blocks. To identify the block index, divide the logical offset of the data in the logical volume by the block size (logical offset of data/524288). The logical offset of the data must be 512 KiB aligned.

  • block_token (BlockToken) –

    The block token of the block from which to get data. You can obtain the BlockToken by running the ListChangedBlocks or ListSnapshotBlocks operations.

Raises:

Source code in docs_src/capo_ebs/_services/ebs.py
@contextmanager
def get_snapshot_block(
    self,
    snapshot_id: "capo_ebs.types.snapshot_id.SnapshotId",
    block_index: "capo_ebs.types.block_index.BlockIndex",
    block_token: "capo_ebs.types.block_token.BlockToken",
    *,
    config_overrides: Optional[EBSClientConfig] = None,
) -> (
    "Generator[capo_ebs.types.get_snapshot_block_response.GetSnapshotBlockResponse]"
):
    """<p>Returns the data in a block in an Amazon Elastic Block Store snapshot.</p> <note> <p>You should always retry requests that receive server (<code>5xx</code>) error responses, and <code>ThrottlingException</code> and <code>RequestThrottledException</code> client error responses. For more information see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/error-retries.html">Error retries</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p> </note>

    Args:
        snapshot_id: <p>The ID of the snapshot containing the block from which to get data.</p> <important> <p>If the specified snapshot is encrypted, you must have permission to use the KMS key that was used to encrypt the snapshot. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebsapis-using-encryption.html"> Using encryption</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p> </important>
        block_index: <p>The block index of the block in which to read the data. A block index is a logical index in units of <code>512</code> KiB blocks. To identify the block index, divide the logical offset of the data in the logical volume by the block size (logical offset of data/<code>524288</code>). The logical offset of the data must be <code>512</code> KiB aligned.</p>
        block_token: <p>The block token of the block from which to get data. You can obtain the <code>BlockToken</code> by running the <code>ListChangedBlocks</code> or <code>ListSnapshotBlocks</code> operations.</p>

    Raises:
        capo_ebs.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_ebs.errors.internal_server_exception.InternalServerException: <p>An internal error has occurred. For more information see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/error-retries.html">Error retries</a>.</p>
        capo_ebs.errors.request_throttled_exception.RequestThrottledException: <p>The number of API requests has exceeded the maximum allowed API request throttling limit for the snapshot. For more information see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/error-retries.html">Error retries</a>.</p>
        capo_ebs.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_ebs.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Your current service quotas do not allow you to perform this action.</p>
        capo_ebs.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints of the EBS direct APIs.</p>
        capo_ebs.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ebs.types.get_snapshot_block_request.GetSnapshotBlockRequest]",
    ) -> OperationResponse[
        "capo_ebs.types.get_snapshot_block_response.GetSnapshotBlockResponse"
    ]:
        import capo_ebs._operations.ebs.get_snapshot_block

        output, http_response = (
            capo_ebs._operations.ebs.get_snapshot_block.get_snapshot_block(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_ebs.types.get_snapshot_block_response.GetSnapshotBlockResponse",
    ) -> dict[str, Any]:
        import capo_ebs.types.get_snapshot_block_response

        return capo_ebs.types.get_snapshot_block_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetSnapshotBlock", redact_output=_redact_output),
    )
    input_: capo_ebs.types.get_snapshot_block_request.GetSnapshotBlockRequest = {
        "snapshot_id": snapshot_id,
        "block_index": block_index,
        "block_token": block_token,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    try:
        yield response.output
    finally:
        response.response.close()