Skip to content

search_available_phone_numbers async

search_available_phone_numbers(
    *,
    config_overrides: Optional[AsyncChimeSDKVoiceClientConfig] = 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 the provisioned phone numbers in an organization.

Parameters:

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

    Confines a search to just the phone numbers associated with the specified area code.

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

    Confines a search to just the phone numbers associated with the specified city.

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

    Confines a search to just the phone numbers associated with the specified country.

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

    Confines a search to just the phone numbers associated with the specified state.

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

    Confines a search to just the phone numbers associated with the specified toll-free prefix.

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

    Confines a search to just the phone numbers associated with the specified phone number type, either local or toll-free.

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

    The maximum number of results to return.

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

    The token used to return the next page of results.

Raises:

Source code in docs_src/capo_chime_sdk_voice/_services/async_chime_sdk_voice.py
async def search_available_phone_numbers(
    self,
    *,
    config_overrides: Optional[AsyncChimeSDKVoiceClientConfig] = None,
    area_code: Optional["capo_chime_sdk_voice.types.string.String"] = None,
    city: Optional["capo_chime_sdk_voice.types.string.String"] = None,
    country: Optional[
        "capo_chime_sdk_voice.types.alpha2_country_code.Alpha2CountryCode"
    ] = None,
    state: Optional["capo_chime_sdk_voice.types.string.String"] = None,
    toll_free_prefix: Optional[
        "capo_chime_sdk_voice.types.toll_free_prefix.TollFreePrefix"
    ] = None,
    phone_number_type: Optional[
        "capo_chime_sdk_voice.types.phone_number_type.PhoneNumberType"
    ] = None,
    max_results: Optional[
        "capo_chime_sdk_voice.types.phone_number_max_results.PhoneNumberMaxResults"
    ] = None,
    next_token: Optional["capo_chime_sdk_voice.types.string.String"] = None,
) -> "capo_chime_sdk_voice.types.search_available_phone_numbers_response.SearchAvailablePhoneNumbersResponse":
    """<p>Searches the provisioned phone numbers in an organization.</p>

    Args:
        area_code: <p>Confines a search to just the phone numbers associated with the specified area code.</p>
        city: <p>Confines a search to just the phone numbers associated with the specified city.</p>
        country: <p>Confines a search to just the phone numbers associated with the specified country.</p>
        state: <p>Confines a search to just the phone numbers associated with the specified state.</p>
        toll_free_prefix: <p>Confines a search to just the phone numbers associated with the specified toll-free prefix.</p>
        phone_number_type: <p>Confines a search to just the phone numbers associated with the specified phone number type, either <b>local</b> or <b>toll-free</b>.</p>
        max_results: <p>The maximum number of results to return.</p>
        next_token: <p>The token used to return the next page of results.</p>

    Raises:
        capo_chime_sdk_voice.errors.access_denied_exception.AccessDeniedException: <p>You don't have the permissions needed to run this action.</p>
        capo_chime_sdk_voice.errors.bad_request_exception.BadRequestException: <p>The input parameters don't match the service's restrictions.</p>
        capo_chime_sdk_voice.errors.forbidden_exception.ForbiddenException: <p>The client is permanently forbidden from making the request.</p>
        capo_chime_sdk_voice.errors.service_failure_exception.ServiceFailureException: <p>The service encountered an unexpected error.</p>
        capo_chime_sdk_voice.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is currently unavailable.</p>
        capo_chime_sdk_voice.errors.throttled_client_exception.ThrottledClientException: <p>The number of customer requests exceeds the request rate limit.</p>
        capo_chime_sdk_voice.errors.unauthorized_client_exception.UnauthorizedClientException: <p>The client isn't authorized to request a resource.</p>
        capo_chime_sdk_voice.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_chime_sdk_voice.types.search_available_phone_numbers_request.SearchAvailablePhoneNumbersRequest]",
    ) -> AsyncOperationResponse[
        "capo_chime_sdk_voice.types.search_available_phone_numbers_response.SearchAvailablePhoneNumbersResponse"
    ]:
        import capo_chime_sdk_voice._operations.chime_sdk_telephony_service.search_available_phone_numbers

        (
            output,
            http_response,
        ) = await capo_chime_sdk_voice._operations.chime_sdk_telephony_service.search_available_phone_numbers.async_search_available_phone_numbers(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

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

        return capo_chime_sdk_voice.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_sdk_voice.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 = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output