Skip to content

check_if_phone_number_is_opted_out

check_if_phone_number_is_opted_out(
    phone_number: PhoneNumber, *, config_overrides: Optional[SNSClientConfig] = None
) -> CheckIfPhoneNumberIsOptedOutResponse

Accepts a phone number and indicates whether the phone holder has opted out of receiving SMS messages from your Amazon Web Services account. You cannot send SMS messages to a number that is opted out.

To resume sending messages, you can opt in the number by using the OptInPhoneNumber action.

Parameters:

  • phone_number (PhoneNumber) –

    The phone number for which you want to check the opt out status.

Raises:

Source code in docs_src/capo_sns/_services/sns.py
def check_if_phone_number_is_opted_out(
    self,
    phone_number: "capo_sns.types.phone_number.PhoneNumber",
    *,
    config_overrides: Optional[SNSClientConfig] = None,
) -> "capo_sns.types.check_if_phone_number_is_opted_out_response.CheckIfPhoneNumberIsOptedOutResponse":
    """<p>Accepts a phone number and indicates whether the phone holder has opted out of receiving SMS messages from your Amazon Web Services account. You cannot send SMS messages to a number that is opted out.</p> <p>To resume sending messages, you can opt in the number by using the <code>OptInPhoneNumber</code> action.</p>

    Args:
        phone_number: <p>The phone number for which you want to check the opt out status.</p>

    Raises:
        capo_sns.errors.authorization_error_exception.AuthorizationErrorException: <p>Indicates that the user has been denied access to the requested resource.</p>
        capo_sns.errors.internal_error_exception.InternalErrorException: <p>Indicates an internal service error.</p>
        capo_sns.errors.invalid_parameter_exception.InvalidParameterException: <p>Indicates that a request parameter does not comply with the associated constraints.</p>
        capo_sns.errors.throttled_exception.ThrottledException: <p>Indicates that the rate at which requests have been submitted for this action exceeds the limit for your Amazon Web Services account.</p>
        capo_sns.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sns.types.check_if_phone_number_is_opted_out_input.CheckIfPhoneNumberIsOptedOutInput]",
    ) -> OperationResponse[
        "capo_sns.types.check_if_phone_number_is_opted_out_response.CheckIfPhoneNumberIsOptedOutResponse"
    ]:
        import capo_sns._operations.amazon_simple_notification_service.check_if_phone_number_is_opted_out

        output, http_response = (
            capo_sns._operations.amazon_simple_notification_service.check_if_phone_number_is_opted_out.check_if_phone_number_is_opted_out(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sns.types.check_if_phone_number_is_opted_out_input.CheckIfPhoneNumberIsOptedOutInput",
    ) -> dict[str, Any]:
        import capo_sns.types.check_if_phone_number_is_opted_out_input

        return capo_sns.types.check_if_phone_number_is_opted_out_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CheckIfPhoneNumberIsOptedOut", redact_input=_redact_input
        ),
    )
    input_: capo_sns.types.check_if_phone_number_is_opted_out_input.CheckIfPhoneNumberIsOptedOutInput = {
        "phone_number": phone_number
    }

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