Skip to content

update_contact async

update_contact(
    contact_list_name: ContactListName,
    email_address: EmailAddress,
    *,
    config_overrides: Optional[AsyncSESv2ClientConfig] = None,
    topic_preferences: Optional[TopicPreferenceList] = None,
    unsubscribe_all: Optional[UnsubscribeAll] = None,
    attributes_data: Optional[AttributesData] = None,
) -> UpdateContactResponse

Updates a contact's preferences for a list.

You must specify all existing topic preferences in the TopicPreferences object, not just the ones that need updating; otherwise, all your existing preferences will be removed.

Parameters:

  • contact_list_name (ContactListName) –

    The name of the contact list.

  • email_address (EmailAddress) –

    The contact's email address.

  • topic_preferences (Optional[TopicPreferenceList], default: None ) –

    The contact's preference for being opted-in to or opted-out of a topic.

  • unsubscribe_all (Optional[UnsubscribeAll], default: None ) –

    A boolean value status noting if the contact is unsubscribed from all contact list topics.

  • attributes_data (Optional[AttributesData], default: None ) –

    The attribute data attached to a contact.

Raises:

Source code in docs_src/capo_sesv2/_services/async_se_sv2.py
async def update_contact(
    self,
    contact_list_name: "capo_sesv2.types.contact_list_name.ContactListName",
    email_address: "capo_sesv2.types.email_address.EmailAddress",
    *,
    config_overrides: Optional[AsyncSESv2ClientConfig] = None,
    topic_preferences: Optional[
        "capo_sesv2.types.topic_preference_list.TopicPreferenceList"
    ] = None,
    unsubscribe_all: Optional[
        "capo_sesv2.types.unsubscribe_all.UnsubscribeAll"
    ] = None,
    attributes_data: Optional[
        "capo_sesv2.types.attributes_data.AttributesData"
    ] = None,
) -> "capo_sesv2.types.update_contact_response.UpdateContactResponse":
    """<p>Updates a contact's preferences for a list.</p> <note> <p>You must specify all existing topic preferences in the <code>TopicPreferences</code> object, not just the ones that need updating; otherwise, all your existing preferences will be removed.</p> </note>

    Args:
        contact_list_name: <p>The name of the contact list.</p>
        email_address: <p>The contact's email address.</p>
        topic_preferences: <p>The contact's preference for being opted-in to or opted-out of a topic.</p>
        unsubscribe_all: <p>A boolean value status noting if the contact is unsubscribed from all contact list topics.</p>
        attributes_data: <p>The attribute data attached to a contact.</p>

    Raises:
        capo_sesv2.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_sesv2.errors.concurrent_modification_exception.ConcurrentModificationException: <p>The resource is being modified by another operation or thread.</p>
        capo_sesv2.errors.not_found_exception.NotFoundException: <p>The resource you attempted to access doesn't exist.</p>
        capo_sesv2.errors.too_many_requests_exception.TooManyRequestsException: <p>Too many requests have been made to the operation.</p>
        capo_sesv2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sesv2.types.update_contact_request.UpdateContactRequest]",
    ) -> AsyncOperationResponse[
        "capo_sesv2.types.update_contact_response.UpdateContactResponse"
    ]:
        import capo_sesv2._operations.simple_email_service_v2.update_contact

        (
            output,
            http_response,
        ) = await capo_sesv2._operations.simple_email_service_v2.update_contact.async_update_contact(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateContact")
    )
    input_: capo_sesv2.types.update_contact_request.UpdateContactRequest = {
        "contact_list_name": contact_list_name,
        "email_address": email_address,
    }
    if topic_preferences is not None:
        input_["topic_preferences"] = topic_preferences
    if unsubscribe_all is not None:
        input_["unsubscribe_all"] = unsubscribe_all
    if attributes_data is not None:
        input_["attributes_data"] = attributes_data

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