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 AWS account using a specified permission set.

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

Parameter instanceArn : The ARN of the SSO instance under which the operation will be executed. For more information about ARNs, see Amazon Resource Names (ARNs) and AWS Service Namespaces in the AWS 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 AWS SSO, such as a user or group. PrincipalIds are GUIDs (For example, f81d4fae-7dec-11d0-a765-00a0c91e6bf6). For more information about PrincipalIds in AWS SSO, see the AWS SSO Identity Store API Reference.

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

Parameter targetId : TargetID is an AWS account identifier, typically a 10-12 digit string (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 {
  ArgumentError.checkNotNull(instanceArn, 'instanceArn');
  _s.validateStringLength(
    'instanceArn',
    instanceArn,
    10,
    1224,
    isRequired: true,
  );
  ArgumentError.checkNotNull(permissionSetArn, 'permissionSetArn');
  _s.validateStringLength(
    'permissionSetArn',
    permissionSetArn,
    10,
    1224,
    isRequired: true,
  );
  ArgumentError.checkNotNull(principalId, 'principalId');
  _s.validateStringLength(
    'principalId',
    principalId,
    1,
    47,
    isRequired: true,
  );
  ArgumentError.checkNotNull(principalType, 'principalType');
  ArgumentError.checkNotNull(targetId, 'targetId');
  ArgumentError.checkNotNull(targetType, 'targetType');
  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.toValue(),
      'TargetId': targetId,
      'TargetType': targetType.toValue(),
    },
  );

  return CreateAccountAssignmentResponse.fromJson(jsonResponse.body);
}