Skip to content

detach_volume async

detach_volume(
    volume_arn: VolumeARN,
    *,
    config_overrides: Optional[AsyncStorageGatewayClientConfig] = None,
    force_detach: Optional[Boolean] = None,
) -> DetachVolumeOutput

Disconnects a volume from an iSCSI connection and then detaches the volume from the specified gateway. Detaching and attaching a volume enables you to recover your data from one gateway to a different gateway without creating a snapshot. It also makes it easier to move your volumes from an on-premises gateway to a gateway hosted on an Amazon EC2 instance. This operation is only supported in the volume gateway type.

Parameters:

  • volume_arn (VolumeARN) –

    The Amazon Resource Name (ARN) of the volume to detach from the gateway.

  • force_detach (Optional[Boolean], default: None ) –

    Set to true to forcibly remove the iSCSI connection of the target volume and detach the volume. The default is false. If this value is set to false, you must manually disconnect the iSCSI connection from the target volume.

    Valid Values: true | false

Raises:

  • InternalServerError –

    An internal server error has occurred during the request. For more information, see the error and message fields.

  • InvalidGatewayRequestException –

    An exception occurred because an invalid gateway request was issued to the service. For more information, see the error and message fields.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_storage_gateway/_services/async_storage_gateway.py
async def detach_volume(
    self,
    volume_arn: "capo_storage_gateway.types.volume_arn.VolumeARN",
    *,
    config_overrides: Optional[AsyncStorageGatewayClientConfig] = None,
    force_detach: Optional["capo_storage_gateway.types.boolean.Boolean"] = None,
) -> "capo_storage_gateway.types.detach_volume_output.DetachVolumeOutput":
    """<p>Disconnects a volume from an iSCSI connection and then detaches the volume from the specified gateway. Detaching and attaching a volume enables you to recover your data from one gateway to a different gateway without creating a snapshot. It also makes it easier to move your volumes from an on-premises gateway to a gateway hosted on an Amazon EC2 instance. This operation is only supported in the volume gateway type.</p>

    Args:
        volume_arn: <p>The Amazon Resource Name (ARN) of the volume to detach from the gateway.</p>
        force_detach: <p>Set to <code>true</code> to forcibly remove the iSCSI connection of the target volume and detach the volume. The default is <code>false</code>. If this value is set to <code>false</code>, you must manually disconnect the iSCSI connection from the target volume.</p> <p>Valid Values: <code>true</code> | <code>false</code> </p>

    Raises:
        capo_storage_gateway.errors.internal_server_error.InternalServerError: <p>An internal server error has occurred during the request. For more information, see the error and message fields.</p>
        capo_storage_gateway.errors.invalid_gateway_request_exception.InvalidGatewayRequestException: <p>An exception occurred because an invalid gateway request was issued to the service. For more information, see the error and message fields.</p>
        capo_storage_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_storage_gateway.types.detach_volume_input.DetachVolumeInput]",
    ) -> AsyncOperationResponse[
        "capo_storage_gateway.types.detach_volume_output.DetachVolumeOutput"
    ]:
        import capo_storage_gateway._operations.storage_gateway_20130630.detach_volume

        (
            output,
            http_response,
        ) = await capo_storage_gateway._operations.storage_gateway_20130630.detach_volume.async_detach_volume(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DetachVolume")
    )
    input_: capo_storage_gateway.types.detach_volume_input.DetachVolumeInput = {
        "volume_arn": volume_arn
    }
    if force_detach is not None:
        input_["force_detach"] = force_detach

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output