Skip to content

batch_revoke_sessions async

batch_revoke_sessions(
    session_arns: SessionArnList,
    *,
    config_overrides: Optional[AsyncSigninClientConfig] = None,
    principal_arn: Optional[PrincipalArnFilter] = None,
    reason: Optional[RevocationReason] = None,
) -> BatchRevokeSessionsOutput

Revokes up to five sign-in sessions. A revoked session can no longer be refreshed. Revoking a session that is already revoked succeeds. Each session must belong to the identity specified by principalArn, or to the caller if principalArn is omitted. Failures for individual sessions are returned in the errors list and do not fail the whole request.

Parameters:

  • principal_arn (Optional[PrincipalArnFilter], default: None ) –

    The identity that owns the sessions. Omit to use the caller. Specify arn:aws:iam::{account-id}:* to revoke any session in the account.

  • session_arns (SessionArnList) –

    The ARNs of the sessions to revoke

  • reason (Optional[RevocationReason], default: None ) –

    The reason for revoking the sessions

Raises:

Examples:

Revoke one of your own sessions Revokes a session owned by the caller and records the reason.

>>> await client.batch_revoke_sessions(session_arns=['arn:aws:signin:us-east-1:123456789012:session/3b0a6152-ba23-447d-83cf-b3b3cc7b95f7'], reason='Signed out of a lost device')
Revoke another identity's session as an account administrator
Uses the account wildcard principal ARN to revoke another IAM identity's session.
>>> await client.batch_revoke_sessions(principal_arn='arn:aws:iam::123456789012:*', session_arns=['arn:aws:signin:us-east-1:123456789012:session/5dbdd43b-4135-4c59-ad06-5ddbcc2c1d77'], reason='Revoked by account administrator')
Revoke a batch of sessions with a partial failure
Revokes the caller's session and reports a session that was not found in the errors list.
>>> await client.batch_revoke_sessions(session_arns=['arn:aws:signin:us-east-1:123456789012:session/ac148df8-7f37-48eb-b0cf-8987fc4a55a4', 'arn:aws:signin:us-east-1:123456789012:session/36b6ae9d-4fa9-40d9-8eff-eeeb4d15f79d'])
Source code in docs_src/capo_signin/_services/async_signin.py
async def batch_revoke_sessions(
    self,
    session_arns: "capo_signin.types.session_arn_list.SessionArnList",
    *,
    config_overrides: Optional[AsyncSigninClientConfig] = None,
    principal_arn: Optional[
        "capo_signin.types.principal_arn_filter.PrincipalArnFilter"
    ] = None,
    reason: Optional["capo_signin.types.revocation_reason.RevocationReason"] = None,
) -> "capo_signin.types.batch_revoke_sessions_output.BatchRevokeSessionsOutput":
    """Revokes up to five sign-in sessions. A revoked session can no longer be refreshed. Revoking a session that is already revoked succeeds. Each session must belong to the identity specified by principalArn, or to the caller if principalArn is omitted. Failures for individual sessions are returned in the errors list and do not fail the whole request.

    Args:
        principal_arn: The identity that owns the sessions. Omit to use the caller. Specify arn:aws:iam::{account-id}:* to revoke any session in the account.
        session_arns: The ARNs of the sessions to revoke
        reason: The reason for revoking the sessions

    Raises:
        capo_signin.errors.access_denied_exception.AccessDeniedException: You do not have sufficient access to perform this action.
        capo_signin.errors.internal_server_exception.InternalServerException: The request failed because of an internal server error.
        capo_signin.errors.resource_not_found_exception.ResourceNotFoundException: Error thrown when requested resource is not found HTTP Status Code: 404 Not Found Used when the specified resource does not exist
        capo_signin.errors.too_many_requests_error.TooManyRequestsError: The request failed because you exceeded the request rate limit for this operation.
        capo_signin.errors.validation_exception.ValidationException: The request failed because it contains a malformed, missing, or invalid parameter.
        capo_signin.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Revoke one of your own sessions
        Revokes a session owned by the caller and records the reason.

        >>> await client.batch_revoke_sessions(session_arns=['arn:aws:signin:us-east-1:123456789012:session/3b0a6152-ba23-447d-83cf-b3b3cc7b95f7'], reason='Signed out of a lost device')
        Revoke another identity's session as an account administrator
        Uses the account wildcard principal ARN to revoke another IAM identity's session.

        >>> await client.batch_revoke_sessions(principal_arn='arn:aws:iam::123456789012:*', session_arns=['arn:aws:signin:us-east-1:123456789012:session/5dbdd43b-4135-4c59-ad06-5ddbcc2c1d77'], reason='Revoked by account administrator')
        Revoke a batch of sessions with a partial failure
        Revokes the caller's session and reports a session that was not found in the errors list.

        >>> await client.batch_revoke_sessions(session_arns=['arn:aws:signin:us-east-1:123456789012:session/ac148df8-7f37-48eb-b0cf-8987fc4a55a4', 'arn:aws:signin:us-east-1:123456789012:session/36b6ae9d-4fa9-40d9-8eff-eeeb4d15f79d'])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_signin.types.batch_revoke_sessions_input.BatchRevokeSessionsInput]",
    ) -> AsyncOperationResponse[
        "capo_signin.types.batch_revoke_sessions_output.BatchRevokeSessionsOutput"
    ]:
        import capo_signin._operations.signin.batch_revoke_sessions

        (
            output,
            http_response,
        ) = await capo_signin._operations.signin.batch_revoke_sessions.async_batch_revoke_sessions(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("BatchRevokeSessions")
    )
    input_: capo_signin.types.batch_revoke_sessions_input.BatchRevokeSessionsInput = {
        "session_arns": session_arns
    }
    if principal_arn is not None:
        input_["principal_arn"] = principal_arn
    if reason is not None:
        input_["reason"] = reason

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