Skip to content

list_regions

list_regions(
    *,
    config_overrides: Optional[AccountClientConfig] = None,
    account_id: Optional[AccountId] = None,
    max_results: Optional[int] = None,
    next_token: Optional[str] = None,
    region_opt_status_contains: Optional[RegionOptStatusList] = None,
) -> ListRegionsResponse

Lists all the Regions for a given account and their respective opt-in statuses. Optionally, this list can be filtered by the region-opt-status-contains parameter.

Parameters:

  • account_id (Optional[AccountId], default: None ) –

    Specifies the 12-digit account ID number of the Amazon Web Services account that you want to access or modify with this operation. If you don't specify this parameter, it defaults to the Amazon Web Services account of the identity used to call the operation. To use this parameter, the caller must be an identity in the organization's management account or a delegated administrator account. The specified account ID must be a member account in the same organization. The organization must have all features enabled, and the organization must have trusted access enabled for the Account Management service, and optionally a delegated admin account assigned.

    The management account can't specify its own AccountId. It must call the operation in standalone context by not including the AccountId parameter.

    To call this operation on an account that is not a member of an organization, don't specify this parameter. Instead, call the operation using an identity belonging to the account whose contacts you wish to retrieve or modify.

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

    The total number of items to return in the command’s output. If the total number of items available is more than the value specified, a NextToken is provided in the command’s output. To resume pagination, provide the NextToken value in the starting-token argument of a subsequent command. Do not use the NextToken response element directly outside of the Amazon Web Services CLI. For usage examples, see Pagination in the Amazon Web Services Command Line Interface User Guide.

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

    A token used to specify where to start paginating. This is the NextToken from a previously truncated response. For usage examples, see Pagination in the Amazon Web Services Command Line Interface User Guide.

  • region_opt_status_contains (Optional[RegionOptStatusList], default: None ) –

    A list of Region statuses (Enabling, Enabled, Disabling, Disabled, Enabled_by_default) to use to filter the list of Regions for a given account. For example, passing in a value of ENABLING will only return a list of Regions with a Region status of ENABLING.

Raises:

  • AccessDeniedException –

    The operation failed because the calling identity doesn't have the minimum required permissions.

  • InternalServerException –

    The operation failed because of an error internal to Amazon Web Services. Try your operation again later.

  • TooManyRequestsException –

    The operation failed because it was called too frequently and exceeded a throttle limit.

  • ValidationException –

    The operation failed because one of the input parameters was invalid.

  • UnknownServiceError –

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

Source code in docs_src/capo_account/_services/account.py
def list_regions(
    self,
    *,
    config_overrides: Optional[AccountClientConfig] = None,
    account_id: Optional["capo_account.types.account_id.AccountId"] = None,
    max_results: Optional[int] = None,
    next_token: Optional[str] = None,
    region_opt_status_contains: Optional[
        "capo_account.types.region_opt_status_list.RegionOptStatusList"
    ] = None,
) -> "capo_account.types.list_regions_response.ListRegionsResponse":
    """<p>Lists all the Regions for a given account and their respective opt-in statuses. Optionally, this list can be filtered by the <code>region-opt-status-contains</code> parameter. </p>

    Args:
        account_id: <p>Specifies the 12-digit account ID number of the Amazon Web Services account that you want to access or modify with this operation. If you don't specify this parameter, it defaults to the Amazon Web Services account of the identity used to call the operation. To use this parameter, the caller must be an identity in the <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#account">organization's management account</a> or a delegated administrator account. The specified account ID must be a member account in the same organization. The organization must have <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html">all features enabled</a>, and the organization must have <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services.html">trusted access</a> enabled for the Account Management service, and optionally a <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#delegated-admin">delegated admin</a> account assigned.</p> <note> <p>The management account can't specify its own <code>AccountId</code>. It must call the operation in standalone context by not including the <code>AccountId</code> parameter.</p> </note> <p>To call this operation on an account that is not a member of an organization, don't specify this parameter. Instead, call the operation using an identity belonging to the account whose contacts you wish to retrieve or modify.</p>
        max_results: <p>The total number of items to return in the command’s output. If the total number of items available is more than the value specified, a <code>NextToken</code> is provided in the command’s output. To resume pagination, provide the <code>NextToken</code> value in the <code>starting-token</code> argument of a subsequent command. Do not use the <code>NextToken</code> response element directly outside of the Amazon Web Services CLI. For usage examples, see <a href="http://docs.aws.amazon.com/cli/latest/userguide/pagination.html">Pagination</a> in the <i>Amazon Web Services Command Line Interface User Guide</i>. </p>
        next_token: <p>A token used to specify where to start paginating. This is the <code>NextToken</code> from a previously truncated response. For usage examples, see <a href="http://docs.aws.amazon.com/cli/latest/userguide/pagination.html">Pagination</a> in the <i>Amazon Web Services Command Line Interface User Guide</i>.</p>
        region_opt_status_contains: <p>A list of Region statuses (Enabling, Enabled, Disabling, Disabled, Enabled_by_default) to use to filter the list of Regions for a given account. For example, passing in a value of ENABLING will only return a list of Regions with a Region status of ENABLING.</p>

    Raises:
        capo_account.errors.access_denied_exception.AccessDeniedException: <p>The operation failed because the calling identity doesn't have the minimum required permissions.</p>
        capo_account.errors.internal_server_exception.InternalServerException: <p>The operation failed because of an error internal to Amazon Web Services. Try your operation again later.</p>
        capo_account.errors.too_many_requests_exception.TooManyRequestsException: <p>The operation failed because it was called too frequently and exceeded a throttle limit.</p>
        capo_account.errors.validation_exception.ValidationException: <p>The operation failed because one of the input parameters was invalid.</p>
        capo_account.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_account.types.list_regions_request.ListRegionsRequest]",
    ) -> OperationResponse[
        "capo_account.types.list_regions_response.ListRegionsResponse"
    ]:
        import capo_account._operations.account.list_regions

        output, http_response = (
            capo_account._operations.account.list_regions.list_regions(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListRegions")
    )
    input_: capo_account.types.list_regions_request.ListRegionsRequest = {}
    if account_id is not None:
        input_["account_id"] = account_id
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if region_opt_status_contains is not None:
        input_["region_opt_status_contains"] = region_opt_status_contains

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