createLicense method

Future<CreateLicenseResponse> createLicense({
  1. required String beneficiary,
  2. required String clientToken,
  3. required ConsumptionConfiguration consumptionConfiguration,
  4. required List<Entitlement> entitlements,
  5. required String homeRegion,
  6. required Issuer issuer,
  7. required String licenseName,
  8. required String productName,
  9. required String productSKU,
  10. required DatetimeRange validity,
  11. List<Metadata>? licenseMetadata,
})

Creates a license.

May throw ValidationException. May throw InvalidParameterValueException. May throw RedirectException. May throw AuthorizationException. May throw AccessDeniedException. May throw RateLimitExceededException. May throw ServerInternalException.

Parameter beneficiary : License beneficiary.

Parameter clientToken : Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

Parameter consumptionConfiguration : Configuration for consumption of the license. Choose a provisional configuration for workloads running with continuous connectivity. Choose a borrow configuration for workloads with offline usage.

Parameter entitlements : License entitlements.

Parameter homeRegion : Home Region for the license.

Parameter issuer : License issuer.

Parameter licenseName : License name.

Parameter productName : Product name.

Parameter productSKU : Product SKU.

Parameter validity : Date and time range during which the license is valid, in ISO8601-UTC format.

Parameter licenseMetadata : Information about the license.

Implementation

Future<CreateLicenseResponse> createLicense({
  required String beneficiary,
  required String clientToken,
  required ConsumptionConfiguration consumptionConfiguration,
  required List<Entitlement> entitlements,
  required String homeRegion,
  required Issuer issuer,
  required String licenseName,
  required String productName,
  required String productSKU,
  required DatetimeRange validity,
  List<Metadata>? licenseMetadata,
}) async {
  ArgumentError.checkNotNull(beneficiary, 'beneficiary');
  ArgumentError.checkNotNull(clientToken, 'clientToken');
  ArgumentError.checkNotNull(
      consumptionConfiguration, 'consumptionConfiguration');
  ArgumentError.checkNotNull(entitlements, 'entitlements');
  ArgumentError.checkNotNull(homeRegion, 'homeRegion');
  ArgumentError.checkNotNull(issuer, 'issuer');
  ArgumentError.checkNotNull(licenseName, 'licenseName');
  ArgumentError.checkNotNull(productName, 'productName');
  ArgumentError.checkNotNull(productSKU, 'productSKU');
  ArgumentError.checkNotNull(validity, 'validity');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSLicenseManager.CreateLicense'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Beneficiary': beneficiary,
      'ClientToken': clientToken,
      'ConsumptionConfiguration': consumptionConfiguration,
      'Entitlements': entitlements,
      'HomeRegion': homeRegion,
      'Issuer': issuer,
      'LicenseName': licenseName,
      'ProductName': productName,
      'ProductSKU': productSKU,
      'Validity': validity,
      if (licenseMetadata != null) 'LicenseMetadata': licenseMetadata,
    },
  );

  return CreateLicenseResponse.fromJson(jsonResponse.body);
}