Skip to content

update_phone_number

update_phone_number(
    phone_number_id: PhoneNumberIdOrArn,
    *,
    config_overrides: Optional[PinpointSMSVoiceV2ClientConfig] = None,
    two_way_enabled: Optional[bool] = None,
    two_way_channel_arn: Optional[TwoWayChannelArn] = None,
    two_way_channel_role: Optional[IamRoleArn] = None,
    self_managed_opt_outs_enabled: Optional[bool] = None,
    opt_out_list_name: Optional[OptOutListNameOrArn] = None,
    international_sending_enabled: Optional[bool] = None,
    deletion_protection_enabled: Optional[bool] = None,
) -> UpdatePhoneNumberResult

Updates the configuration of an existing origination phone number. You can update the opt-out list, enable or disable two-way messaging, change the TwoWayChannelArn, enable or disable self-managed opt-outs, and enable or disable deletion protection.

If the origination phone number is associated with a pool, an error is returned.

Parameters:

  • phone_number_id (PhoneNumberIdOrArn) –

    The unique identifier of the phone number. Valid values for this field can be either the PhoneNumberId or PhoneNumberArn.

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

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

    By default this is set to false. When set to true you can receive incoming text messages from your end recipients.

  • two_way_channel_arn (Optional[TwoWayChannelArn], default: None ) –

    The Amazon Resource Name (ARN) of the two way channel.

  • two_way_channel_role (Optional[IamRoleArn], default: None ) –

    An optional IAM Role Arn for a service to assume, to be able to post inbound SMS messages.

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

    By default this is set to false. When set to false and an end recipient sends a message that begins with HELP or STOP to one of your dedicated numbers, End User Messaging SMS automatically replies with a customizable message and adds the end recipient to the OptOutList. When set to true you're responsible for responding to HELP and STOP requests. You're also responsible for tracking and honoring opt-out requests.

  • opt_out_list_name (Optional[OptOutListNameOrArn], default: None ) –

    The OptOutList to add the phone number to. You can use either the opt out list name or the opt out list ARN.

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

    By default this is set to false. When set to true the international sending of phone number is Enabled.

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

    By default this is set to false. When set to true the phone number can't be deleted.

Raises:

  • AccessDeniedException –

    The request was denied because you don't have sufficient permissions to access the resource.

  • ConflictException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time or it could be that the requested action isn't valid for the current state or configuration of the resource.

  • InternalServerException –

    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.

  • ResourceNotFoundException –

    A requested resource couldn't be found.

  • ThrottlingException –

    An error that occurred because too many requests were sent during a certain amount of time.

  • ValidationException –

    A validation exception for a field.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_pinpoint_sms_voice_v2/_services/pinpoint_sms_voice_v2.py
def update_phone_number(
    self,
    phone_number_id: "capo_pinpoint_sms_voice_v2.types.phone_number_id_or_arn.PhoneNumberIdOrArn",
    *,
    config_overrides: Optional[PinpointSMSVoiceV2ClientConfig] = None,
    two_way_enabled: Optional[bool] = None,
    two_way_channel_arn: Optional[
        "capo_pinpoint_sms_voice_v2.types.two_way_channel_arn.TwoWayChannelArn"
    ] = None,
    two_way_channel_role: Optional[
        "capo_pinpoint_sms_voice_v2.types.iam_role_arn.IamRoleArn"
    ] = None,
    self_managed_opt_outs_enabled: Optional[bool] = None,
    opt_out_list_name: Optional[
        "capo_pinpoint_sms_voice_v2.types.opt_out_list_name_or_arn.OptOutListNameOrArn"
    ] = None,
    international_sending_enabled: Optional[bool] = None,
    deletion_protection_enabled: Optional[bool] = None,
) -> "capo_pinpoint_sms_voice_v2.types.update_phone_number_result.UpdatePhoneNumberResult":
    """<p>Updates the configuration of an existing origination phone number. You can update the opt-out list, enable or disable two-way messaging, change the TwoWayChannelArn, enable or disable self-managed opt-outs, and enable or disable deletion protection.</p> <p>If the origination phone number is associated with a pool, an error is returned.</p>

    Args:
        phone_number_id: <p>The unique identifier of the phone number. Valid values for this field can be either the PhoneNumberId or PhoneNumberArn.</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>
        two_way_enabled: <p>By default this is set to false. When set to true you can receive incoming text messages from your end recipients.</p>
        two_way_channel_arn: <p>The Amazon Resource Name (ARN) of the two way channel.</p>
        two_way_channel_role: <p>An optional IAM Role Arn for a service to assume, to be able to post inbound SMS messages.</p>
        self_managed_opt_outs_enabled: <p>By default this is set to false. When set to false and an end recipient sends a message that begins with HELP or STOP to one of your dedicated numbers, End User Messaging SMS automatically replies with a customizable message and adds the end recipient to the OptOutList. When set to true you're responsible for responding to HELP and STOP requests. You're also responsible for tracking and honoring opt-out requests.</p>
        opt_out_list_name: <p>The OptOutList to add the phone number to. You can use either the opt out list name or the opt out list ARN.</p>
        international_sending_enabled: <p>By default this is set to false. When set to true the international sending of phone number is Enabled. </p>
        deletion_protection_enabled: <p>By default this is set to false. When set to true the phone number can't be deleted. </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.conflict_exception.ConflictException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time or it could be that the requested action isn't valid for the current state or configuration of 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.update_phone_number_request.UpdatePhoneNumberRequest]",
    ) -> OperationResponse[
        "capo_pinpoint_sms_voice_v2.types.update_phone_number_result.UpdatePhoneNumberResult"
    ]:
        import capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.update_phone_number

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdatePhoneNumber")
    )
    input_: capo_pinpoint_sms_voice_v2.types.update_phone_number_request.UpdatePhoneNumberRequest = {
        "phone_number_id": phone_number_id
    }
    if two_way_enabled is not None:
        input_["two_way_enabled"] = two_way_enabled
    if two_way_channel_arn is not None:
        input_["two_way_channel_arn"] = two_way_channel_arn
    if two_way_channel_role is not None:
        input_["two_way_channel_role"] = two_way_channel_role
    if self_managed_opt_outs_enabled is not None:
        input_["self_managed_opt_outs_enabled"] = self_managed_opt_outs_enabled
    if opt_out_list_name is not None:
        input_["opt_out_list_name"] = opt_out_list_name
    if international_sending_enabled is not None:
        input_["international_sending_enabled"] = international_sending_enabled
    if deletion_protection_enabled is not None:
        input_["deletion_protection_enabled"] = deletion_protection_enabled

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