Skip to content

create_legal_hold async

create_legal_hold(
    title: string,
    description: string,
    *,
    config_overrides: Optional[AsyncBackupClientConfig] = None,
    idempotency_token: Optional[string] = None,
    recovery_point_selection: Optional[RecoveryPointSelection] = None,
    tags: Optional[Tags] = None,
) -> CreateLegalHoldOutput

Creates a legal hold on a recovery point (backup). A legal hold is a restraint on altering or deleting a backup until an authorized user cancels the legal hold. Any actions to delete or disassociate a recovery point will fail with an error if one or more active legal holds are on the recovery point.

Parameters:

  • title (string) –

    The title of the legal hold.

  • description (string) –

    The description of the legal hold.

  • idempotency_token (Optional[string], default: None ) –

    This is a user-chosen string used to distinguish between otherwise identical calls. Retrying a successful request with the same idempotency token results in a success message with no action taken.

  • recovery_point_selection (Optional[RecoveryPointSelection], default: None ) –

    The criteria to assign a set of resources, such as resource types or backup vaults.

  • tags (Optional[Tags], default: None ) –

    Optional tags to include. A tag is a key-value pair you can use to manage, filter, and search for your resources. Allowed characters include UTF-8 letters, numbers, spaces, and the following characters: + - = . _ : /.

Raises:

Source code in docs_src/capo_backup/_services/async_backup.py
async def create_legal_hold(
    self,
    title: "capo_backup.types.string.string",
    description: "capo_backup.types.string.string",
    *,
    config_overrides: Optional[AsyncBackupClientConfig] = None,
    idempotency_token: Optional["capo_backup.types.string.string"] = None,
    recovery_point_selection: Optional[
        "capo_backup.types.recovery_point_selection.RecoveryPointSelection"
    ] = None,
    tags: Optional["capo_backup.types.tags.Tags"] = None,
) -> "capo_backup.types.create_legal_hold_output.CreateLegalHoldOutput":
    """<p>Creates a legal hold on a recovery point (backup). A legal hold is a restraint on altering or deleting a backup until an authorized user cancels the legal hold. Any actions to delete or disassociate a recovery point will fail with an error if one or more active legal holds are on the recovery point.</p>

    Args:
        title: <p>The title of the legal hold.</p>
        description: <p>The description of the legal hold.</p>
        idempotency_token: <p>This is a user-chosen string used to distinguish between otherwise identical calls. Retrying a successful request with the same idempotency token results in a success message with no action taken.</p>
        recovery_point_selection: <p>The criteria to assign a set of resources, such as resource types or backup vaults.</p>
        tags: <p>Optional tags to include. A tag is a key-value pair you can use to manage, filter, and search for your resources. Allowed characters include UTF-8 letters, numbers, spaces, and the following characters: + - = . _ : /. </p>

    Raises:
        capo_backup.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>Indicates that something is wrong with a parameter's value. For example, the value is out of range.</p>
        capo_backup.errors.limit_exceeded_exception.LimitExceededException: <p>A limit in the request has been exceeded; for example, a maximum number of items allowed in a request.</p>
        capo_backup.errors.missing_parameter_value_exception.MissingParameterValueException: <p>Indicates that a required parameter is missing.</p>
        capo_backup.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request failed due to a temporary failure of the server.</p>
        capo_backup.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_backup.types.create_legal_hold_input.CreateLegalHoldInput]",
    ) -> AsyncOperationResponse[
        "capo_backup.types.create_legal_hold_output.CreateLegalHoldOutput"
    ]:
        import capo_backup._operations.cryo_controller_user_manager.create_legal_hold

        (
            output,
            http_response,
        ) = await capo_backup._operations.cryo_controller_user_manager.create_legal_hold.async_create_legal_hold(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_backup.types.create_legal_hold_input.CreateLegalHoldInput",
    ) -> dict[str, Any]:
        import capo_backup.types.create_legal_hold_input

        return capo_backup.types.create_legal_hold_input.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateLegalHold", redact_input=_redact_input),
    )
    input_: capo_backup.types.create_legal_hold_input.CreateLegalHoldInput = {
        "title": title,
        "description": description,
    }
    if idempotency_token is None:
        idempotency_token = str(uuid.uuid4())
    input_["idempotency_token"] = idempotency_token
    if recovery_point_selection is not None:
        input_["recovery_point_selection"] = recovery_point_selection
    if tags is not None:
        input_["tags"] = tags

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