createAccountAssignment method

Future<CreateAccountAssignmentResponse> createAccountAssignment({
  1. required String instanceArn,
  2. required String permissionSetArn,
  3. required String principalId,
  4. required PrincipalType principalType,
  5. required String targetId,
  6. required TargetType targetType,
})

Assigns access to a principal for a specified Amazon Web Services account using a specified permission set.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter instanceArn : The ARN of the IAM Identity Center instance under which the operation will be executed. For more information about ARNs, see Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces in the Amazon Web Services General Reference.

Parameter permissionSetArn : The ARN of the permission set that the admin wants to grant the principal access to.

Parameter principalId : An identifier for an object in IAM Identity Center, such as a user or group. PrincipalIds are GUIDs (For example, f81d4fae-7dec-11d0-a765-00a0c91e6bf6). For more information about PrincipalIds in IAM Identity Center, see the IAM Identity Center Identity Store API Reference.

Parameter principalType : The entity type for which the assignment will be created.

Parameter targetId : TargetID is an Amazon Web Services account identifier, (For example, 123456789012).

Parameter targetType : The entity type for which the assignment will be created.

Implementation

Future<CreateAccountAssignmentResponse> createAccountAssignment({
  required String instanceArn,
  required String permissionSetArn,
  required String principalId,
  required PrincipalType principalType,
  required String targetId,
  required TargetType targetType,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SWBExternalService.CreateAccountAssignment'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'InstanceArn': instanceArn,
      'PermissionSetArn': permissionSetArn,
      'PrincipalId': principalId,
      'PrincipalType': principalType.value,
      'TargetId': targetId,
      'TargetType': targetType.value,
    },
  );

  return CreateAccountAssignmentResponse.fromJson(jsonResponse.body);
}