Skip to content

put_third_party_cost async

put_third_party_cost(
    app_id: AppId,
    label: ThirdPartyCostLabel,
    amount: CostValue,
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    cost_id: Optional[ThirdPartyCostId] = None,
    frequency: Optional[ThirdPartyCostFrequency] = None,
    currency: Optional[Currency] = None,
    description: Optional[ThirdPartyCostDescription] = None,
    effective_from: Optional[ThirdPartyCostMonth] = None,
    effective_to: Optional[ThirdPartyCostMonth] = None,
    client_token: Optional[ClientToken] = None,
) -> PutThirdPartyCostResponse

Adds or updates a seller-declared third-party (non-AWS) monthly cost for an app. Omit the cost identifier to create a new cost, or supply an existing cost identifier to update it in place. The amount is a flat monthly value, and currency defaults to USD when omitted.

Parameters:

  • app_id (AppId) –

    The ID of the app the cost belongs to.

  • cost_id (Optional[ThirdPartyCostId], default: None ) –

    The ID of the cost. Omit it to create a new cost, or supply an existing cost ID to update that cost in place.

  • label (ThirdPartyCostLabel) –

    A human-readable label for the cost (for example, "Anthropic API").

  • amount (CostValue) –

    A flat monthly amount as a decimal string (for example, "12.50").

  • frequency (Optional[ThirdPartyCostFrequency], default: None ) –

    How often the cost recurs. MONTHLY is the only value today.

  • currency (Optional[Currency], default: None ) –

    The currency of the amount. Defaults to USD when omitted (USD is the only supported currency).

  • description (Optional[ThirdPartyCostDescription], default: None ) –

    A free-form description of the cost.

  • effective_from (Optional[ThirdPartyCostMonth], default: None ) –

    First month (YYYY-MM) the cost applies in. Absent means the cost has no start month.

  • effective_to (Optional[ThirdPartyCostMonth], default: None ) –

    Last month (YYYY-MM) the cost applies in. Absent means the cost has no end month. When both are present, effectiveFrom must not be after effectiveTo.

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

    AWS App Monetization does not use this value for this operation. To retry without creating a duplicate cost, pass the costId returned by the first call.

Raises:

Source code in docs_src/capo_appmonetization/_services/async_app_monetization.py
async def put_third_party_cost(
    self,
    app_id: "capo_appmonetization.types.app_id.AppId",
    label: "capo_appmonetization.types.third_party_cost_label.ThirdPartyCostLabel",
    amount: "capo_appmonetization.types.cost_value.CostValue",
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    cost_id: Optional[
        "capo_appmonetization.types.third_party_cost_id.ThirdPartyCostId"
    ] = None,
    frequency: Optional[
        "capo_appmonetization.types.third_party_cost_frequency.ThirdPartyCostFrequency"
    ] = None,
    currency: Optional["capo_appmonetization.types.currency.Currency"] = None,
    description: Optional[
        "capo_appmonetization.types.third_party_cost_description.ThirdPartyCostDescription"
    ] = None,
    effective_from: Optional[
        "capo_appmonetization.types.third_party_cost_month.ThirdPartyCostMonth"
    ] = None,
    effective_to: Optional[
        "capo_appmonetization.types.third_party_cost_month.ThirdPartyCostMonth"
    ] = None,
    client_token: Optional[
        "capo_appmonetization.types.client_token.ClientToken"
    ] = None,
) -> "capo_appmonetization.types.put_third_party_cost_response.PutThirdPartyCostResponse":
    """Adds or updates a seller-declared third-party (non-AWS) monthly cost for an app. Omit the cost identifier to create a new cost, or supply an existing cost identifier to update it in place. The amount is a flat monthly value, and currency defaults to USD when omitted.

    Args:
        app_id: The ID of the app the cost belongs to.
        cost_id: The ID of the cost. Omit it to create a new cost, or supply an existing cost ID to update that cost in place.
        label: A human-readable label for the cost (for example, "Anthropic API").
        amount: A flat monthly amount as a decimal string (for example, "12.50").
        frequency: How often the cost recurs. MONTHLY is the only value today.
        currency: The currency of the amount. Defaults to USD when omitted (USD is the only supported currency).
        description: A free-form description of the cost.
        effective_from: First month (YYYY-MM) the cost applies in. Absent means the cost has no start month.
        effective_to: Last month (YYYY-MM) the cost applies in. Absent means the cost has no end month. When both are present, effectiveFrom must not be after effectiveTo.
        client_token: AWS App Monetization does not use this value for this operation. To retry without creating a duplicate cost, pass the `costId` returned by the first call.

    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_third_party_cost_request.PutThirdPartyCostRequest]",
    ) -> AsyncOperationResponse[
        "capo_appmonetization.types.put_third_party_cost_response.PutThirdPartyCostResponse"
    ]:
        import capo_appmonetization._operations.aws_monetization_ai_front_end.put_third_party_cost

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutThirdPartyCost")
    )
    input_: capo_appmonetization.types.put_third_party_cost_request.PutThirdPartyCostRequest = {
        "app_id": app_id,
        "label": label,
        "amount": amount,
    }
    if cost_id is not None:
        input_["cost_id"] = cost_id
    if frequency is not None:
        input_["frequency"] = frequency
    if currency is not None:
        input_["currency"] = currency
    if description is not None:
        input_["description"] = description
    if effective_from is not None:
        input_["effective_from"] = effective_from
    if effective_to is not None:
        input_["effective_to"] = effective_to
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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