Skip to content

put_aws_service_event async

put_aws_service_event(
    app_id: AppId,
    user_id: UserId,
    service: ServiceName,
    operation: OperationName,
    timestamp: Timestamp,
    scope: RequestScope,
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    quantity: Optional[Quantity] = None,
    aws_region: Optional[Region] = None,
    properties: Optional[EventProperties] = None,
) -> PutAwsServiceEventResponse

Records an AWS service usage event for cost attribution. The event is accepted and processed asynchronously.

Parameters:

  • app_id (AppId) –

    The ID of the app.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.

  • 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.

  • service (ServiceName) –

    The AWS service name that emitted the usage event.

  • operation (OperationName) –

    The AWS operation (API action) that produced the usage event.

  • quantity (Optional[Quantity], default: None ) –

    A non-negative decimal quantity represented as a string (for example, "1500" or "12.5").

  • timestamp (Timestamp) –

    The time the event occurred, as an ISO-8601 date-time in UTC (for example, "2026-07-26T15:04:05Z").

  • aws_region (Optional[Region], default: None ) –

    The AWS Region in which the event occurred.

  • properties (Optional[EventProperties], default: None ) –

    The key/value properties carried on a usage event. Property values can be referenced by metric filters and grouping.

  • scope (RequestScope) –

    The environment of the app that this operation applies to. Specify live to use the live app, or sandbox to use the app's isolated test environment.

Raises:

Source code in docs_src/capo_appmonetization/_services/async_app_monetization.py
async def put_aws_service_event(
    self,
    app_id: "capo_appmonetization.types.app_id.AppId",
    user_id: "capo_appmonetization.types.user_id.UserId",
    service: "capo_appmonetization.types.service_name.ServiceName",
    operation: "capo_appmonetization.types.operation_name.OperationName",
    timestamp: "capo_appmonetization.types.timestamp.Timestamp",
    scope: "capo_appmonetization.types.request_scope.RequestScope",
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    client_token: Optional[
        "capo_appmonetization.types.client_token.ClientToken"
    ] = None,
    quantity: Optional["capo_appmonetization.types.quantity.Quantity"] = None,
    aws_region: Optional["capo_appmonetization.types.region.Region"] = None,
    properties: Optional[
        "capo_appmonetization.types.event_properties.EventProperties"
    ] = None,
) -> "capo_appmonetization.types.put_aws_service_event_response.PutAwsServiceEventResponse":
    """Records an AWS service usage event for cost attribution. The event is accepted and processed asynchronously.

    Args:
        app_id: The ID of the app.
        client_token: A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.
        user_id: An opaque identifier that you assign to an end user. Do not include personally identifiable or otherwise sensitive data in this value.
        service: The AWS service name that emitted the usage event.
        operation: The AWS operation (API action) that produced the usage event.
        quantity: A non-negative decimal quantity represented as a string (for example, "1500" or "12.5").
        timestamp: The time the event occurred, as an ISO-8601 date-time in UTC (for example, "2026-07-26T15:04:05Z").
        aws_region: The AWS Region in which the event occurred.
        properties: The key/value properties carried on a usage event. Property values can be referenced by metric filters and grouping.
        scope: The environment of the app that this operation applies to. Specify live to use the live app, or sandbox to use the app's isolated test environment.

    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.put_aws_service_event_request.PutAwsServiceEventRequest]",
    ) -> AsyncOperationResponse[
        "capo_appmonetization.types.put_aws_service_event_response.PutAwsServiceEventResponse"
    ]:
        import capo_appmonetization._operations.aws_monetization_ai_front_end.put_aws_service_event

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutAwsServiceEvent")
    )
    input_: capo_appmonetization.types.put_aws_service_event_request.PutAwsServiceEventRequest = {
        "app_id": app_id,
        "user_id": user_id,
        "service": service,
        "operation": operation,
        "timestamp": timestamp,
        "scope": scope,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if quantity is not None:
        input_["quantity"] = quantity
    if aws_region is not None:
        input_["aws_region"] = aws_region
    if properties is not None:
        input_["properties"] = properties

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