AppMonetization / Client / get_entitlement_decision

get_entitlement_decision

AppMonetization.Client.get_entitlement_decision(**kwargs)

Returns an entitlement decision for a user action, indicating whether the action is allowed and why. It takes the pending event’s quantity and properties so the check sizes the decision per metric the way PutEvent counts the event: it applies each metric’s filter to the properties, counts 1 for a COUNT metric, and reads the summed or maxed field value for a SUM or MAX metric. The decision is DENY when usage already reached the limit, or when folding this event in would push it past (a SUM or COUNT metric adds the increment to current usage, a MAX metric takes the larger of the two). Send the same eventType, quantity and properties you will send on the event: the check applies the rules PutEvent applies to that event. A SUM or MAX metric that reads a property rejects the check with a ValidationException when the property is missing or not a plain decimal, including when properties are omitted or sent as {}; a metric filter matches only properties that are present, so a filtered metric is skipped for an event with no properties, as PutEvent skips it. It is idempotent, and it may create the user’s default-plan subscription on first use.

See also: AWS API Documentation

Request Syntax

response = client.get_entitlement_decision(
    appId='string',
    userId='string',
    eventType='string',
    scope='sandbox'|'live',
    quantity='string',
    properties={
        'string': 'string'
    }
)
Parameters:
  • appId (string) –

    [REQUIRED]

    The ID of the app.

  • userId (string) –

    [REQUIRED]

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

  • eventType (string) –

    [REQUIRED]

    The type of action the user is attempting, used to determine the applicable plan capability and quota. Use the same event type you will send on the event.

  • scope (string) –

    [REQUIRED]

    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.

  • quantity (string) –

    [REQUIRED]

    The number of units the pending action will consume, as a non-negative decimal string (the same Quantity shape PutEvent uses). Send the real amount if known, otherwise your best upper estimate (for example a request’s max tokens). Used when a metric counts events or sums or maxes the event quantity itself. The decision is DENY when usage already reached the limit, or when folding this event in would push it past (SUM and COUNT add the increment; MAX takes the larger of current usage and the increment).

  • properties (dict) –

    The same event properties you will send on the event. Each metric’s filter is applied to them, and a summed or maxed field value is read from them. Omit them or send {} when the event has none; a metric that sums or maxes a property then rejects the check, as PutEvent rejects the event. Do not include personally identifiable or otherwise sensitive data in these values.

    • (string) –

      Key of an event property. Lowercase, starting with a letter; letters, digits, underscore, and dot; 1-64 characters.

      • (string) –

        Value of an event property, up to 256 characters.

Return type:

dict

Returns:

Response Syntax

{
    'decision': 'ALLOW'|'DENY',
    'reason': {
        'category': 'CAPABILITY'|'USAGE'|'SYSTEM',
        'code': 'ALLOWED'|'WITHIN_QUOTA'|'NO_QUOTA_RESTRICTION'|'OVERAGE_ACCRUING'|'SERVICE_DEGRADED'|'PAYMENT_PAST_DUE'|'COVERED_BY_PURCHASED_UNITS'|'NO_SUBSCRIPTION'|'SUBSCRIPTION_INACTIVE'|'CAPABILITY_NOT_INCLUDED'|'QUOTA_EXCEEDED'|'SUBSCRIPTION_SUSPENDED'|'OUT_OF_UNITS'
    },
    'planId': 'string',
    'metrics': [
        {
            'metricId': 'string',
            'usedQuantity': 123,
            'includedQuantity': 123,
            'remainingQuantity': 123
        },
    ]
}

Response Structure

  • (dict) –

    Output for GetEntitlementDecision.

    • decision (string) –

      The decision indicating whether the user may perform the action.

    • reason (dict) –

      The reason behind the decision.

      • category (string) –

        The category of the reason for the decision.

      • code (string) –

        The specific reason code for the decision.

    • planId (string) –

      The ID of the plan the decision was evaluated against, when the user has a subscription.

    • metrics (list) –

      The per-metric quota status relevant to the decision.

      • (dict) –

        The quota status of a single metric for the period.

        • metricId (string) –

          The ID of the metric.

        • usedQuantity (integer) –

          The quantity of the metric already used in the current period.

        • includedQuantity (integer) –

          The quantity included for the period, prorated after a mid-period plan change. Only metrics with a limit are listed.

        • remainingQuantity (integer) –

          max(0, includedQuantity - usedQuantity).

Exceptions