Skip to content

search_available_phone_numbers

search_available_phone_numbers(
    *,
    config_overrides: Optional[ChimeClientConfig] = None,
    area_code: Optional[String] = None,
    city: Optional[String] = None,
    country: Optional[Alpha2CountryCode] = None,
    state: Optional[String] = None,
    toll_free_prefix: Optional[TollFreePrefix] = None,
    phone_number_type: Optional[PhoneNumberType] = None,
    max_results: Optional[PhoneNumberMaxResults] = None,
    next_token: Optional[String] = None,
) -> SearchAvailablePhoneNumbersResponse

Searches for phone numbers that can be ordered. For US numbers, provide at least one of the following search filters: AreaCode, City, State, or TollFreePrefix. If you provide City, you must also provide State. Numbers outside the US only support the PhoneNumberType filter, which you must use.

Parameters:

  • area_code (Optional[String], default: None ) –

    The area code used to filter results. Only applies to the US.

  • city (Optional[String], default: None ) –

    The city used to filter results. Only applies to the US.

  • country (Optional[Alpha2CountryCode], default: None ) –

    The country used to filter results. Defaults to the US Format: ISO 3166-1 alpha-2.

  • state (Optional[String], default: None ) –

    The state used to filter results. Required only if you provide City. Only applies to the US.

  • toll_free_prefix (Optional[TollFreePrefix], default: None ) –

    The toll-free prefix that you use to filter results. Only applies to the US.

  • phone_number_type (Optional[PhoneNumberType], default: None ) –

    The phone number type used to filter results. Required for non-US numbers.

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

    The maximum number of results to return in a single call.

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

    The token used to retrieve the next page of results.

Raises:

Source code in docs_src/capo_chime/_services/chime.py
def search_available_phone_numbers(
    self,
    *,
    config_overrides: Optional[ChimeClientConfig] = None,
    area_code: Optional["capo_chime.types.string.String"] = None,
    city: Optional["capo_chime.types.string.String"] = None,
    country: Optional[
        "capo_chime.types.alpha2_country_code.Alpha2CountryCode"
    ] = None,
    state: Optional["capo_chime.types.string.String"] = None,
    toll_free_prefix: Optional[
        "capo_chime.types.toll_free_prefix.TollFreePrefix"
    ] = None,
    phone_number_type: Optional[
        "capo_chime.types.phone_number_type.PhoneNumberType"
    ] = None,
    max_results: Optional[
        "capo_chime.types.phone_number_max_results.PhoneNumberMaxResults"
    ] = None,
    next_token: Optional["capo_chime.types.string.String"] = None,
) -> "capo_chime.types.search_available_phone_numbers_response.SearchAvailablePhoneNumbersResponse":
    """<p>Searches for phone numbers that can be ordered. For US numbers, provide at least one of the following search filters: <code>AreaCode</code>, <code>City</code>, <code>State</code>, or <code>TollFreePrefix</code>. If you provide <code>City</code>, you must also provide <code>State</code>. Numbers outside the US only support the <code>PhoneNumberType</code> filter, which you must use.</p>

    Args:
        area_code: <p>The area code used to filter results. Only applies to the US.</p>
        city: <p>The city used to filter results. Only applies to the US.</p>
        country: <p>The country used to filter results. Defaults to the US Format: ISO 3166-1 alpha-2.</p>
        state: <p>The state used to filter results. Required only if you provide <code>City</code>. Only applies to the US.</p>
        toll_free_prefix: <p>The toll-free prefix that you use to filter results. Only applies to the US.</p>
        phone_number_type: <p>The phone number type used to filter results. Required for non-US numbers.</p>
        max_results: <p>The maximum number of results to return in a single call.</p>
        next_token: <p>The token used to retrieve the next page of results.</p>

    Raises:
        capo_chime.errors.access_denied_exception.AccessDeniedException: <p>You don't have permissions to perform the requested operation.</p>
        capo_chime.errors.bad_request_exception.BadRequestException: <p>The input parameters don't match the service's restrictions.</p>
        capo_chime.errors.forbidden_exception.ForbiddenException: <p>The client is permanently forbidden from making the request.</p>
        capo_chime.errors.service_failure_exception.ServiceFailureException: <p>The service encountered an unexpected error.</p>
        capo_chime.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is currently unavailable.</p>
        capo_chime.errors.throttled_client_exception.ThrottledClientException: <p>The client exceeded its request rate limit.</p>
        capo_chime.errors.unauthorized_client_exception.UnauthorizedClientException: <p>The client is not currently authorized to make the request.</p>
        capo_chime.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_chime.types.search_available_phone_numbers_request.SearchAvailablePhoneNumbersRequest]",
    ) -> OperationResponse[
        "capo_chime.types.search_available_phone_numbers_response.SearchAvailablePhoneNumbersResponse"
    ]:
        import capo_chime._operations.uc_buzz_console_service.search_available_phone_numbers

        output, http_response = (
            capo_chime._operations.uc_buzz_console_service.search_available_phone_numbers.search_available_phone_numbers(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_chime.types.search_available_phone_numbers_response.SearchAvailablePhoneNumbersResponse",
    ) -> dict[str, Any]:
        import capo_chime.types.search_available_phone_numbers_response

        return capo_chime.types.search_available_phone_numbers_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "SearchAvailablePhoneNumbers", redact_output=_redact_output
        ),
    )
    input_: capo_chime.types.search_available_phone_numbers_request.SearchAvailablePhoneNumbersRequest = {}
    if area_code is not None:
        input_["area_code"] = area_code
    if city is not None:
        input_["city"] = city
    if country is not None:
        input_["country"] = country
    if state is not None:
        input_["state"] = state
    if toll_free_prefix is not None:
        input_["toll_free_prefix"] = toll_free_prefix
    if phone_number_type is not None:
        input_["phone_number_type"] = phone_number_type
    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