Skip to content

list_roles

list_roles(
    tenant_id: TenantId,
    *,
    config_overrides: Optional[AccountAccessRuntimeClientConfig] = None,
    max_results: Optional[int] = None,
    next_token: Optional[Token] = None,
) -> ListRolesResponse

Returns the roles that you are entitled to access within a tenant. The results are paginated. Use a returned role with GetRoleCredentials to obtain temporary credentials.

Parameters:

  • tenant_id (TenantId) –

    The identifier of the tenant whose roles you want to list. A tenant ID begins with aa- and is 3 to 24 characters long. It can contain lowercase letters, numbers, and hyphens.

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

    The maximum number of roles to return in a single response. If more roles are available than the specified value, the response includes a nextToken value that you can use to retrieve the next page of results. If you don't specify a value, the service uses a default page size.

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

    The pagination token from a previous ListRoles response. Use it to retrieve the next page of results. Omit this parameter on the first call.

Raises:

  • InternalServerException –

    An internal server error occurred. Retry the request. If the problem persists, contact Amazon Web Services Support. This error returns an HTTP 500 status code.

  • ThrottlingException –

    The request rate exceeded the allowed limit. Reduce your request rate, and then retry the request. This error returns an HTTP 429 status code.

  • UnauthorizedException –

    The bearer token is missing, invalid, or expired. Obtain a new token, and then retry the request. This error returns an HTTP 401 status code.

  • ValidationException –

    The request is missing a required parameter, or a parameter value doesn't satisfy its constraints, such as its length or pattern. Correct the input, and then retry the request. This error returns an HTTP 400 status code.

  • UnknownServiceError –

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

Source code in docs_src/capo_account_access_runtime/_services/account_access_runtime.py
def list_roles(
    self,
    tenant_id: "capo_account_access_runtime.types.tenant_id.TenantId",
    *,
    config_overrides: Optional[AccountAccessRuntimeClientConfig] = None,
    max_results: Optional[int] = None,
    next_token: Optional["capo_account_access_runtime.types.token.Token"] = None,
) -> "capo_account_access_runtime.types.list_roles_response.ListRolesResponse":
    """<p>Returns the roles that you are entitled to access within a tenant. The results are paginated. Use a returned role with <code>GetRoleCredentials</code> to obtain temporary credentials.</p>

    Args:
        tenant_id: <p>The identifier of the tenant whose roles you want to list. A tenant ID begins with <code>aa-</code> and is 3 to 24 characters long. It can contain lowercase letters, numbers, and hyphens.</p>
        max_results: <p>The maximum number of roles to return in a single response. If more roles are available than the specified value, the response includes a <code>nextToken</code> value that you can use to retrieve the next page of results. If you don't specify a value, the service uses a default page size.</p>
        next_token: <p>The pagination token from a previous <code>ListRoles</code> response. Use it to retrieve the next page of results. Omit this parameter on the first call.</p>

    Raises:
        capo_account_access_runtime.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry the request. If the problem persists, contact Amazon Web Services Support. This error returns an HTTP 500 status code.</p>
        capo_account_access_runtime.errors.throttling_exception.ThrottlingException: <p>The request rate exceeded the allowed limit. Reduce your request rate, and then retry the request. This error returns an HTTP 429 status code.</p>
        capo_account_access_runtime.errors.unauthorized_exception.UnauthorizedException: <p>The bearer token is missing, invalid, or expired. Obtain a new token, and then retry the request. This error returns an HTTP 401 status code.</p>
        capo_account_access_runtime.errors.validation_exception.ValidationException: <p>The request is missing a required parameter, or a parameter value doesn't satisfy its constraints, such as its length or pattern. Correct the input, and then retry the request. This error returns an HTTP 400 status code.</p>
        capo_account_access_runtime.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_account_access_runtime.types.list_roles_request.ListRolesRequest]",
    ) -> OperationResponse[
        "capo_account_access_runtime.types.list_roles_response.ListRolesResponse"
    ]:
        import capo_account_access_runtime._operations.aws_account_access_runtime.list_roles

        output, http_response = (
            capo_account_access_runtime._operations.aws_account_access_runtime.list_roles.list_roles(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListRoles")
    )
    input_: capo_account_access_runtime.types.list_roles_request.ListRolesRequest = {
        "tenant_id": tenant_id
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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