createImpersonationRole method
Creates an impersonation role for the given WorkMail organization.
Idempotency ensures that an API request completes no more than one time. With an idempotent request, if the original request completes successfully, any subsequent retries also complete successfully without performing any further actions.
May throw EntityNotFoundException.
May throw EntityStateException.
May throw InvalidParameterException.
May throw LimitExceededException.
May throw OrganizationNotFoundException.
May throw OrganizationStateException.
Parameter name :
The name of the new impersonation role.
Parameter organizationId :
The WorkMail organization to create the new impersonation role within.
Parameter rules :
The list of rules for the impersonation role.
Parameter type :
The impersonation role's type. The available impersonation role types are
READ_ONLY or FULL_ACCESS.
Parameter clientToken :
The idempotency token for the client request.
Parameter description :
The description of the new impersonation role.
Implementation
Future<CreateImpersonationRoleResponse> createImpersonationRole({
required String name,
required String organizationId,
required List<ImpersonationRule> rules,
required ImpersonationRoleType type,
String? clientToken,
String? description,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'WorkMailService.CreateImpersonationRole'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Name': name,
'OrganizationId': organizationId,
'Rules': rules,
'Type': type.value,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
if (description != null) 'Description': description,
},
);
return CreateImpersonationRoleResponse.fromJson(jsonResponse.body);
}