Skip to content

put_retention_policy async

put_retention_policy(
    organization_id: OrganizationId,
    name: ShortString,
    folder_configurations: FolderConfigurations,
    *,
    config_overrides: Optional[AsyncWorkMailClientConfig] = None,
    id: Optional[ShortString] = None,
    description: Optional[PolicyDescription] = None,
) -> PutRetentionPolicyResponse

Puts a retention policy to the specified organization.

Parameters:

Raises:

Source code in docs_src/capo_workmail/_services/async_work_mail.py
async def put_retention_policy(
    self,
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    name: "capo_workmail.types.short_string.ShortString",
    folder_configurations: "capo_workmail.types.folder_configurations.FolderConfigurations",
    *,
    config_overrides: Optional[AsyncWorkMailClientConfig] = None,
    id: Optional["capo_workmail.types.short_string.ShortString"] = None,
    description: Optional[
        "capo_workmail.types.policy_description.PolicyDescription"
    ] = None,
) -> "capo_workmail.types.put_retention_policy_response.PutRetentionPolicyResponse":
    """<p>Puts a retention policy to the specified organization.</p>

    Args:
        organization_id: <p>The organization ID.</p>
        id: <p>The retention policy ID.</p>
        name: <p>The retention policy name.</p>
        description: <p>The retention policy description.</p>
        folder_configurations: <p>The retention policy folder configurations.</p>

    Raises:
        capo_workmail.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more of the input parameters don't match the service's restrictions.</p>
        capo_workmail.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeds the limit of the resource.</p>
        capo_workmail.errors.organization_not_found_exception.OrganizationNotFoundException: <p>An operation received a valid organization identifier that either doesn't belong or exist in the system.</p>
        capo_workmail.errors.organization_state_exception.OrganizationStateException: <p>The organization must have a valid state to perform certain operations on the organization or its members.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_workmail.types.put_retention_policy_request.PutRetentionPolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_workmail.types.put_retention_policy_response.PutRetentionPolicyResponse"
    ]:
        import capo_workmail._operations.work_mail_service.put_retention_policy

        (
            output,
            http_response,
        ) = await capo_workmail._operations.work_mail_service.put_retention_policy.async_put_retention_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_workmail.types.put_retention_policy_request.PutRetentionPolicyRequest",
    ) -> dict[str, Any]:
        import capo_workmail.types.put_retention_policy_request

        return capo_workmail.types.put_retention_policy_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PutRetentionPolicy", redact_input=_redact_input),
    )
    input_: capo_workmail.types.put_retention_policy_request.PutRetentionPolicyRequest = {
        "organization_id": organization_id,
        "name": name,
        "folder_configurations": folder_configurations,
    }
    if id is not None:
        input_["id"] = id
    if description is not None:
        input_["description"] = description

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