createGrant method
Creates a grant for the specified license. A grant shares the use of license entitlements with specific AWS accounts.
May throw ValidationException. May throw InvalidParameterValueException. May throw ResourceLimitExceededException. May throw ServerInternalException. May throw AuthorizationException. May throw RateLimitExceededException. May throw AccessDeniedException.
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.
Implementation
Future<CreateGrantResponse> createGrant({
required List<AllowedOperation> allowedOperations,
required String clientToken,
required String grantName,
required String homeRegion,
required String licenseArn,
required List<String> principals,
}) async {
ArgumentError.checkNotNull(allowedOperations, 'allowedOperations');
ArgumentError.checkNotNull(clientToken, 'clientToken');
ArgumentError.checkNotNull(grantName, 'grantName');
ArgumentError.checkNotNull(homeRegion, 'homeRegion');
ArgumentError.checkNotNull(licenseArn, 'licenseArn');
_s.validateStringLength(
'licenseArn',
licenseArn,
0,
2048,
isRequired: true,
);
ArgumentError.checkNotNull(principals, 'principals');
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.toValue()).toList(),
'ClientToken': clientToken,
'GrantName': grantName,
'HomeRegion': homeRegion,
'LicenseArn': licenseArn,
'Principals': principals,
},
);
return CreateGrantResponse.fromJson(jsonResponse.body);
}