Skip to content

list_accounts

list_accounts(
    access_token: AccessTokenType,
    *,
    config_overrides: Optional[SSOClientConfig] = None,
    next_token: Optional[NextTokenType] = None,
    max_results: Optional[MaxResultType] = None,
) -> ListAccountsResponse

Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see Assign User Access in the IAM Identity Center User Guide. This operation returns a paginated response.

Parameters:

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

    (Optional) When requesting subsequent pages, this is the page token from the previous response output.

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

    This is the number of items 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.

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_accounts(
    self,
    access_token: "capo_sso.types.access_token_type.AccessTokenType",
    *,
    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_accounts_response.ListAccountsResponse":
    """<p>Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see <a href="https://docs.aws.amazon.com/singlesignon/latest/userguide/useraccess.html#assignusers">Assign User Access</a> in the <i>IAM Identity Center User Guide</i>. This operation returns a paginated response.</p>

    Args:
        next_token: <p>(Optional) When requesting subsequent pages, this is the page token from the previous response output.</p>
        max_results: <p>This is the number of items 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>

    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_accounts_request.ListAccountsRequest]",
    ) -> OperationResponse[
        "capo_sso.types.list_accounts_response.ListAccountsResponse"
    ]:
        import capo_sso._operations.swb_portal_service.list_accounts

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

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

        return capo_sso.types.list_accounts_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListAccounts", redact_input=_redact_input),
    )
    input_: capo_sso.types.list_accounts_request.ListAccountsRequest = {
        "access_token": access_token
    }
    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