batchMeterUsage method
BatchMeterUsage, which is used for metering SaaS flexible
consumption pricing (FCP). Identical requests are idempotent and can be
retried with the same records or a subset of records. Each
BatchMeterUsage request is for only one product. If you want
to meter usage for multiple products, you must make multiple
BatchMeterUsage calls.
Usage records should be submitted in quick succession following a recorded
event. Usage records aren't accepted 24 hours or more after an event. At
the end of each billing cycle, a 6-hour grace period applies. We accept
usage records for the previous billing month until 06:00 UTC on the first
day of the next month. For example, you must submit March usage records
before 06:00 UTC on April 1. After this grace period, we return a
TimestampOutOfBoundsException error.
BatchMeterUsage can process up to 25
UsageRecords at a time, and each request must be less than 1
MB in size. Optionally, you can have multiple usage allocations for usage
data that's split into buckets according to predefined tags.
BatchMeterUsage returns a list of
UsageRecordResult objects, which have each
UsageRecord. It also returns a list of
UnprocessedRecords, which indicate errors on the service side
that should be retried.
For Amazon Web Services Regions that support BatchMeterUsage,
see BatchMeterUsage
Region support.
May throw DisabledApiException.
May throw InternalServiceErrorException.
May throw InvalidCustomerIdentifierException.
May throw InvalidLicenseException.
May throw InvalidProductCodeException.
May throw InvalidTagException.
May throw InvalidUsageAllocationsException.
May throw InvalidUsageDimensionException.
May throw ThrottlingException.
May throw TimestampOutOfBoundsException.
Parameter usageRecords :
The set of UsageRecords to submit.
BatchMeterUsage accepts up to 25 UsageRecords at
a time.
Parameter productCode :
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.
Implementation
Future<BatchMeterUsageResult> batchMeterUsage({
required List<UsageRecord> usageRecords,
String? productCode,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSMPMeteringService.BatchMeterUsage'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'UsageRecords': usageRecords,
if (productCode != null) 'ProductCode': productCode,
},
);
return BatchMeterUsageResult.fromJson(jsonResponse.body);
}