Skip to content

carrier_lookup async

carrier_lookup(
    phone_number: CarrierLookupInputPhoneNumberType,
    *,
    config_overrides: Optional[AsyncPinpointSMSVoiceV2ClientConfig] = None,
    enable_cleansing: Optional[bool] = None,
) -> CarrierLookupResult

Returns information about a destination phone number, including whether the number type and whether it is valid, the carrier, and more.

Parameters:

  • phone_number (CarrierLookupInputPhoneNumberType) –

    The phone number that you want to retrieve information about. You can provide the phone number in various formats including special characters such as parentheses, brackets, spaces, hyphens, periods, and commas. The service automatically converts the input to E164 format for processing.

  • enable_cleansing (Optional[bool], default: None ) –

    Specifies whether the service cleanses the phone number that you provide. When set to true, the service normalizes the phone number according to the destination country's national numbering plan and dialing rules. The service returns the cleansed number in E.164 format in the E164PhoneNumber field and returns the number that you provided in the OriginalPhoneNumber field.

Raises:

Examples:

Use CarrierLookup Call the CarrierLookup operation to get information about a customer provided phone number, including if the number is valid. The service accepts phone numbers with various formatting characters and returns the number in E164 format.

>>> await client.carrier_lookup(phone_number='+1 (555) 555-5333')
Source code in docs_src/capo_pinpoint_sms_voice_v2/_services/async_pinpoint_sms_voice_v2.py
async def carrier_lookup(
    self,
    phone_number: "capo_pinpoint_sms_voice_v2.types.carrier_lookup_input_phone_number_type.CarrierLookupInputPhoneNumberType",
    *,
    config_overrides: Optional[AsyncPinpointSMSVoiceV2ClientConfig] = None,
    enable_cleansing: Optional[bool] = None,
) -> "capo_pinpoint_sms_voice_v2.types.carrier_lookup_result.CarrierLookupResult":
    """<p>Returns information about a destination phone number, including whether the number type and whether it is valid, the carrier, and more.</p>

    Args:
        phone_number: <p>The phone number that you want to retrieve information about. You can provide the phone number in various formats including special characters such as parentheses, brackets, spaces, hyphens, periods, and commas. The service automatically converts the input to E164 format for processing.</p>
        enable_cleansing: <p>Specifies whether the service cleanses the phone number that you provide. When set to <code>true</code>, the service normalizes the phone number according to the destination country's national numbering plan and dialing rules. The service returns the cleansed number in E.164 format in the <code>E164PhoneNumber</code> field and returns the number that you provided in the <code>OriginalPhoneNumber</code> field.</p>

    Raises:
        capo_pinpoint_sms_voice_v2.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because you don't have sufficient permissions to access the resource.</p>
        capo_pinpoint_sms_voice_v2.errors.internal_server_exception.InternalServerException: <p>The API encountered an unexpected error and couldn't complete the request. You might be able to successfully issue the request again in the future.</p>
        capo_pinpoint_sms_voice_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p>
        capo_pinpoint_sms_voice_v2.errors.throttling_exception.ThrottlingException: <p>An error that occurred because too many requests were sent during a certain amount of time.</p>
        capo_pinpoint_sms_voice_v2.errors.validation_exception.ValidationException: <p>A validation exception for a field.</p>
        capo_pinpoint_sms_voice_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Use CarrierLookup
        Call the CarrierLookup operation to get information about a customer provided phone number, including if the number is valid. The service accepts phone numbers with various formatting characters and returns the number in E164 format.

        >>> await client.carrier_lookup(phone_number='+1 (555) 555-5333')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_pinpoint_sms_voice_v2.types.carrier_lookup_request.CarrierLookupRequest]",
    ) -> AsyncOperationResponse[
        "capo_pinpoint_sms_voice_v2.types.carrier_lookup_result.CarrierLookupResult"
    ]:
        import capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.carrier_lookup

        (
            output,
            http_response,
        ) = await capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.carrier_lookup.async_carrier_lookup(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CarrierLookup")
    )
    input_: capo_pinpoint_sms_voice_v2.types.carrier_lookup_request.CarrierLookupRequest = {
        "phone_number": phone_number
    }
    if enable_cleansing is not None:
        input_["enable_cleansing"] = enable_cleansing

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output