Skip to content

assume_impersonation_role async

assume_impersonation_role(
    organization_id: OrganizationId,
    impersonation_role_id: ImpersonationRoleId,
    *,
    config_overrides: Optional[AsyncWorkMailClientConfig] = None,
) -> AssumeImpersonationRoleResponse

Assumes an impersonation role for the given WorkMail organization. This method returns an authentication token you can use to make impersonated calls.

Parameters:

  • organization_id (OrganizationId) –

    The WorkMail organization under which the impersonation role will be assumed.

  • impersonation_role_id (ImpersonationRoleId) –

    The impersonation role ID to assume.

Raises:

Source code in docs_src/capo_workmail/_services/async_work_mail.py
async def assume_impersonation_role(
    self,
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    impersonation_role_id: "capo_workmail.types.impersonation_role_id.ImpersonationRoleId",
    *,
    config_overrides: Optional[AsyncWorkMailClientConfig] = None,
) -> "capo_workmail.types.assume_impersonation_role_response.AssumeImpersonationRoleResponse":
    """<p>Assumes an impersonation role for the given WorkMail organization. This method returns an authentication token you can use to make impersonated calls.</p>

    Args:
        organization_id: <p>The WorkMail organization under which the impersonation role will be assumed.</p>
        impersonation_role_id: <p>The impersonation role ID to assume.</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.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.resource_not_found_exception.ResourceNotFoundException: <p>The resource cannot be found.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_workmail.types.assume_impersonation_role_request.AssumeImpersonationRoleRequest]",
    ) -> AsyncOperationResponse[
        "capo_workmail.types.assume_impersonation_role_response.AssumeImpersonationRoleResponse"
    ]:
        import capo_workmail._operations.work_mail_service.assume_impersonation_role

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssumeImpersonationRole")
    )
    input_: capo_workmail.types.assume_impersonation_role_request.AssumeImpersonationRoleRequest = {
        "organization_id": organization_id,
        "impersonation_role_id": impersonation_role_id,
    }

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