MarketplaceMetering / Client / meter_usage

meter_usage

MarketplaceMetering.Client.meter_usage(**kwargs)

API to emit metering records. For identical requests, the API is idempotent and returns the metering record ID. This is used for metering flexible consumption pricing (FCP) Amazon Machine Images (AMI) and container products.

MeterUsage is authenticated on the buyer’s Amazon Web Services account using credentials from the Amazon EC2 instance, Amazon ECS task, or Amazon EKS pod.

MeterUsage can optionally include multiple usage allocations, to provide customers with usage data split into buckets by tags that you define (or allow the customer to define).

Submit usage records to report events from the previous hour. If you submit records that are greater than six hours after events occur, the records won’t be accepted. The timestamp in your request determines when an event is recorded. You can only report usage once per hour for each dimension. For AMI-based products, this is per dimension and per EC2 instance. For container products, this is per dimension and per ECS task or EKS pod. You can’t modify values after they’re recorded. If you report usage before the current hour ends, you will be unable to report additional usage until the next hour begins.

For Amazon Web Services Regions that support MeterUsage, see MeterUsage Region support for Amazon EC2 and MeterUsage Region support for Amazon ECS and Amazon EKS.

See also: AWS API Documentation

Request Syntax

response = client.meter_usage(
    ProductCode='string',
    Timestamp=datetime(2015, 1, 1),
    UsageDimension='string',
    UsageQuantity=123,
    DryRun=True|False,
    UsageAllocations=[
        {
            'AllocatedUsageQuantity': 123,
            'Tags': [
                {
                    'Key': 'string',
                    'Value': 'string'
                },
            ]
        },
    ],
    ClientToken='string'
)
Parameters:
  • ProductCode (string) –

    [REQUIRED]

    Product code is used to uniquely identify a product in Amazon Web Services Marketplace. The product code should be the same as the one used during the publishing of a new product.

  • Timestamp (datetime) –

    [REQUIRED]

    Timestamp, in UTC, for which the usage is being reported. Your application can meter usage for up to six hours in the past. Make sure the timestamp value is not before the start of the software usage.

  • UsageDimension (string) –

    [REQUIRED]

    It will be one of the fcp dimension name provided during the publishing of the product.

  • UsageQuantity (integer) – Consumption value for the hour. Defaults to 0 if not specified.

  • DryRun (boolean) – Checks whether you have the permissions required for the action, but does not make the request. If you have the permissions, the request returns DryRunOperation; otherwise, it returns UnauthorizedException. Defaults to false if not specified.

  • UsageAllocations (list) –

    The set of UsageAllocations to submit.

    The sum of all UsageAllocation quantities must equal the UsageQuantity of the MeterUsage request, and each UsageAllocation must have a unique set of tags (include no tags).

    • (dict) –

      Usage allocations allow you to split usage into buckets by tags.

      Each UsageAllocation indicates the usage quantity for a specific set of tags.

      • AllocatedUsageQuantity (integer) – [REQUIRED]

        The total quantity allocated to this bucket of usage.

      • Tags (list) –

        The set of tags that define the bucket of usage. For the bucket of items with no tags, this parameter can be left out.

        • (dict) –

          Metadata assigned to an allocation. Each tag is made up of a key and a value.

          • Key (string) – [REQUIRED]

            One part of a key-value pair that makes up a tag. A key is a label that acts like a category for the specific tag values.

          • Value (string) – [REQUIRED]

            One part of a key-value pair that makes up a tag. A value acts as a descriptor within a tag category (key). The value can be empty or null.

  • ClientToken (string) –

    Specifies a unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value.

    If you don’t provide this value, then Amazon Web Services generates a random one for you.

    If you retry the operation with the same ClientToken, but with different parameters, the retry fails with an IdempotencyConflictException error.

    This field is autopopulated if not provided.

Return type:

dict

Returns:

Response Syntax

{
    'MeteringRecordId': 'string'
}

Response Structure

  • (dict) –

    • MeteringRecordId (string) –

      Metering record id.

Exceptions