Skip to content

put_opted_out_number

put_opted_out_number(
    opt_out_list_name: OptOutListNameOrArn,
    opted_out_number: PhoneNumber,
    *,
    config_overrides: Optional[PinpointSMSVoiceV2ClientConfig] = None,
) -> PutOptedOutNumberResult

Creates an opted out destination phone number in the opt-out list.

If the destination phone number isn't valid or if the specified opt-out list doesn't exist, an error is returned.

Parameters:

  • opt_out_list_name (OptOutListNameOrArn) –

    The OptOutListName or OptOutListArn to add the phone number to.

    If you are using a shared End User Messaging SMS resource then you must use the full Amazon Resource Name(ARN).

  • opted_out_number (PhoneNumber) –

    The phone number to add to the OptOutList in E.164 format.

Raises:

Source code in docs_src/capo_pinpoint_sms_voice_v2/_services/pinpoint_sms_voice_v2.py
def put_opted_out_number(
    self,
    opt_out_list_name: "capo_pinpoint_sms_voice_v2.types.opt_out_list_name_or_arn.OptOutListNameOrArn",
    opted_out_number: "capo_pinpoint_sms_voice_v2.types.phone_number.PhoneNumber",
    *,
    config_overrides: Optional[PinpointSMSVoiceV2ClientConfig] = None,
) -> "capo_pinpoint_sms_voice_v2.types.put_opted_out_number_result.PutOptedOutNumberResult":
    """<p>Creates an opted out destination phone number in the opt-out list.</p> <p>If the destination phone number isn't valid or if the specified opt-out list doesn't exist, an error is returned.</p>

    Args:
        opt_out_list_name: <p>The OptOutListName or OptOutListArn to add the phone number to.</p> <important> <p>If you are using a shared End User Messaging SMS resource then you must use the full Amazon Resource Name(ARN).</p> </important>
        opted_out_number: <p>The phone number to add to the OptOutList in E.164 format.</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.resource_not_found_exception.ResourceNotFoundException: <p>A requested resource couldn't be found.</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.
    """

    def _handler(
        req: "OperationRequest[capo_pinpoint_sms_voice_v2.types.put_opted_out_number_request.PutOptedOutNumberRequest]",
    ) -> OperationResponse[
        "capo_pinpoint_sms_voice_v2.types.put_opted_out_number_result.PutOptedOutNumberResult"
    ]:
        import capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.put_opted_out_number

        output, http_response = (
            capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.put_opted_out_number.put_opted_out_number(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutOptedOutNumber")
    )
    input_: capo_pinpoint_sms_voice_v2.types.put_opted_out_number_request.PutOptedOutNumberRequest = {
        "opt_out_list_name": opt_out_list_name,
        "opted_out_number": opted_out_number,
    }

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