Skip to content

update_user

update_user(
    organization_id: OrganizationId,
    user_id: EntityIdentifier,
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    role: Optional[UserRole] = None,
    display_name: Optional[UserAttribute] = None,
    first_name: Optional[UserAttribute] = None,
    last_name: Optional[UserAttribute] = None,
    hidden_from_global_address_list: Optional[BooleanObject] = None,
    initials: Optional[UserAttribute] = None,
    telephone: Optional[UserAttribute] = None,
    street: Optional[UserAttribute] = None,
    job_title: Optional[UserAttribute] = None,
    city: Optional[UserAttribute] = None,
    company: Optional[UserAttribute] = None,
    zip_code: Optional[UserAttribute] = None,
    department: Optional[UserAttribute] = None,
    country: Optional[UserAttribute] = None,
    office: Optional[UserAttribute] = None,
    identity_provider_user_id: Optional[IdentityProviderUserIdForUpdate] = None,
) -> UpdateUserResponse

Updates data for the user. To have the latest information, it must be preceded by a DescribeUser call. The dataset in the request should be the one expected when performing another DescribeUser call.

Parameters:

  • organization_id (OrganizationId) –

    The identifier for the organization under which the user exists.

  • user_id (EntityIdentifier) –

    The identifier for the user to be updated.

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

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

    • Email address: [email protected]

    • User name: user

  • role (Optional[UserRole], default: None ) –

    Updates the user role.

    You cannot pass SYSTEM_USER or RESOURCE.

  • display_name (Optional[UserAttribute], default: None ) –

    Updates the display name of the user.

  • first_name (Optional[UserAttribute], default: None ) –

    Updates the user's first name.

  • last_name (Optional[UserAttribute], default: None ) –

    Updates the user's last name.

  • hidden_from_global_address_list (Optional[BooleanObject], default: None ) –

    If enabled, the user is hidden from the global address list.

  • initials (Optional[UserAttribute], default: None ) –

    Updates the user's initials.

  • telephone (Optional[UserAttribute], default: None ) –

    Updates the user's contact details.

  • street (Optional[UserAttribute], default: None ) –

    Updates the user's street address.

  • job_title (Optional[UserAttribute], default: None ) –

    Updates the user's job title.

  • city (Optional[UserAttribute], default: None ) –

    Updates the user's city.

  • company (Optional[UserAttribute], default: None ) –

    Updates the user's company.

  • zip_code (Optional[UserAttribute], default: None ) –

    Updates the user's zip code.

  • department (Optional[UserAttribute], default: None ) –

    Updates the user's department.

  • country (Optional[UserAttribute], default: None ) –

    Updates the user's country.

  • office (Optional[UserAttribute], default: None ) –

    Updates the user's office.

  • identity_provider_user_id (Optional[IdentityProviderUserIdForUpdate], default: None ) –

    User ID from the IAM Identity Center. If this parameter is empty it will be updated automatically when the user logs in for the first time to the mailbox associated with WorkMail.

Raises:

Source code in docs_src/capo_workmail/_services/work_mail.py
def update_user(
    self,
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    user_id: "capo_workmail.types.entity_identifier.EntityIdentifier",
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    role: Optional["capo_workmail.types.user_role.UserRole"] = None,
    display_name: Optional[
        "capo_workmail.types.user_attribute.UserAttribute"
    ] = None,
    first_name: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    last_name: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    hidden_from_global_address_list: Optional[
        "capo_workmail.types.boolean_object.BooleanObject"
    ] = None,
    initials: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    telephone: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    street: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    job_title: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    city: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    company: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    zip_code: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    department: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    country: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    office: Optional["capo_workmail.types.user_attribute.UserAttribute"] = None,
    identity_provider_user_id: Optional[
        "capo_workmail.types.identity_provider_user_id_for_update.IdentityProviderUserIdForUpdate"
    ] = None,
) -> "capo_workmail.types.update_user_response.UpdateUserResponse":
    """<p>Updates data for the user. To have the latest information, it must be preceded by a <a>DescribeUser</a> call. The dataset in the request should be the one expected when performing another <code>DescribeUser</code> call.</p>

    Args:
        organization_id: <p>The identifier for the organization under which the user exists.</p>
        user_id: <p>The identifier for the user to be updated.</p> <p>The identifier can be the <i>UserId</i>, <i>Username</i>, or <i>email</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>Email address: [email protected]</p> </li> <li> <p>User name: user</p> </li> </ul>
        role: <p>Updates the user role.</p> <p>You cannot pass <i>SYSTEM_USER</i> or <i>RESOURCE</i>.</p>
        display_name: <p>Updates the display name of the user.</p>
        first_name: <p>Updates the user's first name.</p>
        last_name: <p>Updates the user's last name.</p>
        hidden_from_global_address_list: <p>If enabled, the user is hidden from the global address list.</p>
        initials: <p>Updates the user's initials.</p>
        telephone: <p>Updates the user's contact details.</p>
        street: <p>Updates the user's street address.</p>
        job_title: <p>Updates the user's job title.</p>
        city: <p>Updates the user's city.</p>
        company: <p>Updates the user's company.</p>
        zip_code: <p>Updates the user's zip code.</p>
        department: <p>Updates the user's department.</p>
        country: <p>Updates the user's country.</p>
        office: <p>Updates the user's office.</p>
        identity_provider_user_id: <p>User ID from the IAM Identity Center. If this parameter is empty it will be updated automatically when the user logs in for the first time to the mailbox associated with WorkMail.</p>

    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_not_found_exception.EntityNotFoundException: <p>The identifier supplied for the user, group, or resource does not exist in your organization.</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.update_user_request.UpdateUserRequest]",
    ) -> OperationResponse[
        "capo_workmail.types.update_user_response.UpdateUserResponse"
    ]:
        import capo_workmail._operations.work_mail_service.update_user

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

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

        return capo_workmail.types.update_user_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateUser", redact_input=_redact_input)
    )
    input_: capo_workmail.types.update_user_request.UpdateUserRequest = {
        "organization_id": organization_id,
        "user_id": user_id,
    }
    if role is not None:
        input_["role"] = role
    if display_name is not None:
        input_["display_name"] = display_name
    if first_name is not None:
        input_["first_name"] = first_name
    if last_name is not None:
        input_["last_name"] = last_name
    if hidden_from_global_address_list is not None:
        input_["hidden_from_global_address_list"] = hidden_from_global_address_list
    if initials is not None:
        input_["initials"] = initials
    if telephone is not None:
        input_["telephone"] = telephone
    if street is not None:
        input_["street"] = street
    if job_title is not None:
        input_["job_title"] = job_title
    if city is not None:
        input_["city"] = city
    if company is not None:
        input_["company"] = company
    if zip_code is not None:
        input_["zip_code"] = zip_code
    if department is not None:
        input_["department"] = department
    if country is not None:
        input_["country"] = country
    if office is not None:
        input_["office"] = office
    if identity_provider_user_id is not None:
        input_["identity_provider_user_id"] = identity_provider_user_id

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