getEntitlements method

Future<GetEntitlementsResult> getEntitlements({
  1. required String productCode,
  2. Map<GetEntitlementFilterName, List<String>>? filter,
  3. int? maxResults,
  4. String? nextToken,
})

GetEntitlements retrieves entitlement values for a given product. The results can be filtered based on customer identifier, AWS account ID, license ARN, or product dimensions.

May throw InternalServiceErrorException. May throw InvalidParameterException. May throw ThrottlingException.

Parameter productCode : Product code is used to uniquely identify a product in AWS Marketplace. The product code will be provided by AWS Marketplace when the product listing is created.

Parameter filter : Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described as keys mapped to a lists of values. Filtered requests are unioned for each value in the value list, and then intersected for each filter key.

CustomerIdentifier and CustomerAWSAccountId are mutually exclusive parameters. You must use one or the other, but not both in the same request.

Parameter maxResults : The maximum number of items to retrieve from the GetEntitlements operation. For pagination, use the NextToken field in subsequent calls to GetEntitlements.

Parameter nextToken : For paginated calls to GetEntitlements, pass the NextToken from the previous GetEntitlementsResult.

Implementation

Future<GetEntitlementsResult> getEntitlements({
  required String productCode,
  Map<GetEntitlementFilterName, List<String>>? filter,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    25,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSMPEntitlementService.GetEntitlements'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ProductCode': productCode,
      if (filter != null)
        'Filter': filter.map((k, e) => MapEntry(k.value, e)),
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return GetEntitlementsResult.fromJson(jsonResponse.body);
}