Skip to content

put_segment_subscription async

put_segment_subscription(
    domain_name: name,
    segment_definition_name: name,
    *,
    config_overrides: Optional[AsyncCustomerProfilesClientConfig] = None,
    schedule_configuration: Optional[ScheduleConfiguration] = None,
) -> PutSegmentSubscriptionResponse

Creates or updates a segment subscription for membership events. When a subscription is created, an initial snapshot is taken and the system begins monitoring for membership changes.

You can optionally set a schedule configuration interval to control how often membership snapshots are run. The interval can be from 1 to 24 hours. If not set, the interval defaults to 24 hours. Scheduled snapshots run on a best-effort basis. If a scheduled snapshot takes longer than the configured interval, the next scheduled run does not start until the in-progress snapshot completes, so a run might be delayed or skipped and is not guaranteed to occur at exactly the requested time.

For Classic segments, membership events are generated from these scheduled snapshots and also in near real-time as profile attribute changes occur. For SQL segments, membership events are generated only from the scheduled snapshots.

Parameters:

  • domain_name (name) –

    The unique name of the domain.

  • segment_definition_name (name) –

    The unique name of the segment definition.

  • schedule_configuration (Optional[ScheduleConfiguration], default: None ) –

    The optional schedule configuration that controls how often membership snapshots are run. If not provided, the subscription defaults to a 24-hour interval.

Raises:

Source code in docs_src/capo_customer_profiles/_services/async_customer_profiles.py
async def put_segment_subscription(
    self,
    domain_name: "capo_customer_profiles.types.name.name",
    segment_definition_name: "capo_customer_profiles.types.name.name",
    *,
    config_overrides: Optional[AsyncCustomerProfilesClientConfig] = None,
    schedule_configuration: Optional[
        "capo_customer_profiles.types.schedule_configuration.ScheduleConfiguration"
    ] = None,
) -> "capo_customer_profiles.types.put_segment_subscription_response.PutSegmentSubscriptionResponse":
    """<p>Creates or updates a segment subscription for membership events. When a subscription is created, an initial snapshot is taken and the system begins monitoring for membership changes. </p> <p>You can optionally set a schedule configuration interval to control how often membership snapshots are run. The interval can be from 1 to 24 hours. If not set, the interval defaults to 24 hours. Scheduled snapshots run on a best-effort basis. If a scheduled snapshot takes longer than the configured interval, the next scheduled run does not start until the in-progress snapshot completes, so a run might be delayed or skipped and is not guaranteed to occur at exactly the requested time. </p> <p>For Classic segments, membership events are generated from these scheduled snapshots and also in near real-time as profile attribute changes occur. For SQL segments, membership events are generated only from the scheduled snapshots. </p>

    Args:
        domain_name: <p>The unique name of the domain.</p>
        segment_definition_name: <p>The unique name of the segment definition. </p>
        schedule_configuration: <p>The optional schedule configuration that controls how often membership snapshots are run. If not provided, the subscription defaults to a 24-hour interval. </p>

    Raises:
        capo_customer_profiles.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_customer_profiles.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_customer_profiles.errors.internal_server_exception.InternalServerException: <p>An internal service error occurred.</p>
        capo_customer_profiles.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource does not exist, or access was denied.</p>
        capo_customer_profiles.errors.throttling_exception.ThrottlingException: <p>You exceeded the maximum number of requests.</p>
        capo_customer_profiles.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_customer_profiles.types.put_segment_subscription_request.PutSegmentSubscriptionRequest]",
    ) -> AsyncOperationResponse[
        "capo_customer_profiles.types.put_segment_subscription_response.PutSegmentSubscriptionResponse"
    ]:
        import capo_customer_profiles._operations.customer_profiles_20200815.put_segment_subscription

        (
            output,
            http_response,
        ) = await capo_customer_profiles._operations.customer_profiles_20200815.put_segment_subscription.async_put_segment_subscription(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutSegmentSubscription")
    )
    input_: capo_customer_profiles.types.put_segment_subscription_request.PutSegmentSubscriptionRequest = {
        "domain_name": domain_name,
        "segment_definition_name": segment_definition_name,
    }
    if schedule_configuration is not None:
        input_["schedule_configuration"] = schedule_configuration

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