Skip to content

cancel_subscription async

cancel_subscription(
    app_id: AppId,
    user_id: UserId,
    effective_at: Timestamp,
    scope: RequestScope,
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
) -> CancelSubscriptionResponse

Cancels a user's subscription at the end of the current billing period.

Parameters:

  • app_id (AppId) –

    The ID of the app.

  • user_id (UserId) –

    An opaque identifier that you assign to an end user. Do not include personally identifiable or otherwise sensitive data in this value.

  • effective_at (Timestamp) –

    The subscription's current effective time, as returned by GetSubscription, used as an optimistic-concurrency check. If GetSubscription returns a pending change, pass pendingChange.effectiveAt; otherwise pass subscription.effectiveAt. This value does not choose when the cancellation takes effect: a new cancellation takes effect at the end of the current billing period, returned as cancellationEffectiveAt. If the subscription's effective time has changed since you read it (for example, because another plan change was made), the value no longer matches and the request fails with ConflictException; call GetSubscription again and retry with the new value. If the subscription is already cancelled or a cancellation is already scheduled, the request returns its current state and does not compare this value.

  • scope (RequestScope) –

    Required. The environment: live or sandbox.

Raises:

Source code in docs_src/capo_appmonetization/_services/async_app_monetization.py
async def cancel_subscription(
    self,
    app_id: "capo_appmonetization.types.app_id.AppId",
    user_id: "capo_appmonetization.types.user_id.UserId",
    effective_at: "capo_appmonetization.types.timestamp.Timestamp",
    scope: "capo_appmonetization.types.request_scope.RequestScope",
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
) -> "capo_appmonetization.types.cancel_subscription_response.CancelSubscriptionResponse":
    """Cancels a user's subscription at the end of the current billing period.

    Args:
        app_id: The ID of the app.
        user_id: An opaque identifier that you assign to an end user. Do not include personally identifiable or otherwise sensitive data in this value.
        effective_at: The subscription's current effective time, as returned by GetSubscription, used as an optimistic-concurrency check. If GetSubscription returns a pending change, pass `pendingChange.effectiveAt`; otherwise pass `subscription.effectiveAt`. This value does not choose when the cancellation takes effect: a new cancellation takes effect at the end of the current billing period, returned as `cancellationEffectiveAt`. If the subscription's effective time has changed since you read it (for example, because another plan change was made), the value no longer matches and the request fails with ConflictException; call GetSubscription again and retry with the new value. If the subscription is already cancelled or a cancellation is already scheduled, the request returns its current state and does not compare this value.
        scope: Required. The environment: live or sandbox.

    Raises:
        capo_appmonetization.errors.access_denied_exception.AccessDeniedException: The caller does not have sufficient permission to perform this action.
        capo_appmonetization.errors.conflict_exception.ConflictException: The request conflicts with the current state of the resource, such as a duplicate identifier or a version mismatch. Retrieve the current state of the resource and retry the request.
        capo_appmonetization.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_appmonetization.errors.resource_not_found_exception.ResourceNotFoundException: The referenced resource does not exist.
        capo_appmonetization.errors.throttling_exception.ThrottlingException: The request was denied due to request throttling.
        capo_appmonetization.errors.validation_exception.ValidationException: The request failed input validation.
        capo_appmonetization.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_appmonetization.types.cancel_subscription_request.CancelSubscriptionRequest]",
    ) -> AsyncOperationResponse[
        "capo_appmonetization.types.cancel_subscription_response.CancelSubscriptionResponse"
    ]:
        import capo_appmonetization._operations.aws_monetization_ai_front_end.cancel_subscription

        (
            output,
            http_response,
        ) = await capo_appmonetization._operations.aws_monetization_ai_front_end.cancel_subscription.async_cancel_subscription(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelSubscription")
    )
    input_: capo_appmonetization.types.cancel_subscription_request.CancelSubscriptionRequest = {
        "app_id": app_id,
        "user_id": user_id,
        "effective_at": effective_at,
        "scope": scope,
    }

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