Skip to content

list_account_roles

list_account_roles(
    access_token: AccessTokenType,
    account_id: AccountIdType,
    *,
    config_overrides: Optional[SSOClientConfig] = None,
    next_token: Optional[NextTokenType] = None,
    max_results: Optional[MaxResultType] = None,
) -> ListAccountRolesResponse

Lists all roles that are assigned to the user for a given AWS account.

Parameters:

  • next_token (Optional[NextTokenType], default: None ) –

    The page token from the previous response output when you request subsequent pages.

  • max_results (Optional[MaxResultType], default: None ) –

    The number of items that clients can request per page.

  • access_token (AccessTokenType) –

    The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide.

  • account_id (AccountIdType) –

    The identifier for the AWS account that is assigned to the user.

Raises:

  • InvalidRequestException –

    Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.

  • ResourceNotFoundException –

    The specified resource doesn't exist.

  • TooManyRequestsException –

    Indicates that the request is being made too frequently and is more than what the server can handle.

  • UnauthorizedException –

    Indicates that the request is not authorized. This can happen due to an invalid access token in the request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sso/_services/sso.py
def list_account_roles(
    self,
    access_token: "capo_sso.types.access_token_type.AccessTokenType",
    account_id: "capo_sso.types.account_id_type.AccountIdType",
    *,
    config_overrides: Optional[SSOClientConfig] = None,
    next_token: Optional["capo_sso.types.next_token_type.NextTokenType"] = None,
    max_results: Optional["capo_sso.types.max_result_type.MaxResultType"] = None,
) -> "capo_sso.types.list_account_roles_response.ListAccountRolesResponse":
    """<p>Lists all roles that are assigned to the user for a given AWS account.</p>

    Args:
        next_token: <p>The page token from the previous response output when you request subsequent pages.</p>
        max_results: <p>The number of items that clients can request per page.</p>
        access_token: <p>The token issued by the <code>CreateToken</code> API call. For more information, see <a href="https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html">CreateToken</a> in the <i>IAM Identity Center OIDC API Reference Guide</i>.</p>
        account_id: <p>The identifier for the AWS account that is assigned to the user.</p>

    Raises:
        capo_sso.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.</p>
        capo_sso.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource doesn't exist.</p>
        capo_sso.errors.too_many_requests_exception.TooManyRequestsException: <p>Indicates that the request is being made too frequently and is more than what the server can handle.</p>
        capo_sso.errors.unauthorized_exception.UnauthorizedException: <p>Indicates that the request is not authorized. This can happen due to an invalid access token in the request.</p>
        capo_sso.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sso.types.list_account_roles_request.ListAccountRolesRequest]",
    ) -> OperationResponse[
        "capo_sso.types.list_account_roles_response.ListAccountRolesResponse"
    ]:
        import capo_sso._operations.swb_portal_service.list_account_roles

        output, http_response = (
            capo_sso._operations.swb_portal_service.list_account_roles.list_account_roles(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sso.types.list_account_roles_request.ListAccountRolesRequest",
    ) -> dict[str, Any]:
        import capo_sso.types.list_account_roles_request

        return capo_sso.types.list_account_roles_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListAccountRoles", redact_input=_redact_input),
    )
    input_: capo_sso.types.list_account_roles_request.ListAccountRolesRequest = {
        "access_token": access_token,
        "account_id": account_id,
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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