createGrant method

Future<CreateGrantResponse> createGrant({
  1. required List<AllowedOperation> allowedOperations,
  2. required String clientToken,
  3. required String grantName,
  4. required String homeRegion,
  5. required String licenseArn,
  6. required List<String> principals,
  7. List<Tag>? tags,
})

Creates a grant for the specified license. A grant shares the use of license entitlements with a specific Amazon Web Services account, an organization, or an organizational unit (OU). For more information, see Granted licenses in License Manager in the License Manager User Guide.

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

Parameter allowedOperations : Allowed operations for the grant.

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

Parameter grantName : Grant name.

Parameter homeRegion : Home Region of the grant.

Parameter licenseArn : Amazon Resource Name (ARN) of the license.

Parameter principals : The grant principals. You can specify one of the following as an Amazon Resource Name (ARN):

  • An Amazon Web Services account, which includes only the account specified.
  • An organizational unit (OU), which includes all accounts in the OU.
  • An organization, which will include all accounts across your organization.

Parameter tags : Tags to add to the grant. For more information about tagging support in License Manager, see the TagResource operation.

Implementation

Future<CreateGrantResponse> createGrant({
  required List<AllowedOperation> allowedOperations,
  required String clientToken,
  required String grantName,
  required String homeRegion,
  required String licenseArn,
  required List<String> principals,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSLicenseManager.CreateGrant'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AllowedOperations': allowedOperations.map((e) => e.value).toList(),
      'ClientToken': clientToken,
      'GrantName': grantName,
      'HomeRegion': homeRegion,
      'LicenseArn': licenseArn,
      'Principals': principals,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateGrantResponse.fromJson(jsonResponse.body);
}