Skip to content

delete_user

delete_user(
    organization_id: OrganizationId,
    user_id: EntityIdentifier,
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
) -> DeleteUserResponse

Deletes a user from WorkMail and all subsequent systems. Before you can delete a user, the user state must be DISABLED. Use the DescribeUser action to confirm the user state.

Deleting a user is permanent and cannot be undone. WorkMail archives user mailboxes for 30 days before they are permanently removed.

Parameters:

  • organization_id (OrganizationId) –

    The organization that contains the user to be deleted.

  • user_id (EntityIdentifier) –

    The identifier of the user to be deleted.

    The identifier can be the UserId or Username. The following identity formats are available:

    • User ID: 12345678-1234-1234-1234-123456789012 or S-1-1-12-1234567890-123456789-123456789-1234

    • User name: user

Raises:

Source code in docs_src/capo_workmail/_services/work_mail.py
def delete_user(
    self,
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    user_id: "capo_workmail.types.entity_identifier.EntityIdentifier",
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
) -> "capo_workmail.types.delete_user_response.DeleteUserResponse":
    """<p>Deletes a user from WorkMail and all subsequent systems. Before you can delete a user, the user state must be <code>DISABLED</code>. Use the <a>DescribeUser</a> action to confirm the user state.</p> <p>Deleting a user is permanent and cannot be undone. WorkMail archives user mailboxes for 30 days before they are permanently removed.</p>

    Args:
        organization_id: <p>The organization that contains the user to be deleted.</p>
        user_id: <p>The identifier of the user to be deleted.</p> <p>The identifier can be the <i>UserId</i> or <i>Username</i>. The following identity formats are available:</p> <ul> <li> <p>User ID: 12345678-1234-1234-1234-123456789012 or S-1-1-12-1234567890-123456789-123456789-1234</p> </li> <li> <p>User name: user</p> </li> </ul>

    Raises:
        capo_workmail.errors.directory_service_authentication_failed_exception.DirectoryServiceAuthenticationFailedException: <p>The directory service doesn't recognize the credentials supplied by WorkMail.</p>
        capo_workmail.errors.directory_unavailable_exception.DirectoryUnavailableException: <p>The directory is unavailable. It might be located in another Region or deleted.</p>
        capo_workmail.errors.entity_state_exception.EntityStateException: <p>You are performing an operation on a user, group, or resource that isn't in the expected state, such as trying to delete an active user.</p>
        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.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.unsupported_operation_exception.UnsupportedOperationException: <p>You can't perform a write operation against a read-only directory.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_workmail.types.delete_user_request.DeleteUserRequest]",
    ) -> OperationResponse[
        "capo_workmail.types.delete_user_response.DeleteUserResponse"
    ]:
        import capo_workmail._operations.work_mail_service.delete_user

        output, http_response = (
            capo_workmail._operations.work_mail_service.delete_user.delete_user(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteUser")
    )
    input_: capo_workmail.types.delete_user_request.DeleteUserRequest = {
        "organization_id": organization_id,
        "user_id": user_id,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output