createIAMPolicyAssignment method

Future<CreateIAMPolicyAssignmentResponse> createIAMPolicyAssignment({
  1. required String assignmentName,
  2. required AssignmentStatus assignmentStatus,
  3. required String awsAccountId,
  4. required String namespace,
  5. Map<String, List<String>>? identities,
  6. String? policyArn,
})

Creates an assignment with one specified IAM policy, identified by its Amazon Resource Name (ARN). This policy assignment is attached to the specified groups or users of Amazon QuickSight. Assignment names are unique per AWS account. To avoid overwriting rules in other namespaces, use assignment names that are unique.

May throw AccessDeniedException. May throw InvalidParameterValueException. May throw ResourceExistsException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ConcurrentUpdatingException. May throw InternalFailureException.

Parameter assignmentName : The name of the assignment, also called a rule. It must be unique within an AWS account.

Parameter assignmentStatus : The status of the assignment. Possible values are as follows:

  • ENABLED - Anything specified in this assignment is used when creating the data source.
  • DISABLED - This assignment isn't used when creating the data source.
  • DRAFT - This assignment is an unfinished draft and isn't used when creating the data source.

Parameter awsAccountId : The ID of the AWS account where you want to assign an IAM policy to QuickSight users or groups.

Parameter namespace : The namespace that contains the assignment.

Parameter identities : The QuickSight users, groups, or both that you want to assign the policy to.

Parameter policyArn : The ARN for the IAM policy to apply to the QuickSight users and groups specified in this assignment.

Implementation

Future<CreateIAMPolicyAssignmentResponse> createIAMPolicyAssignment({
  required String assignmentName,
  required AssignmentStatus assignmentStatus,
  required String awsAccountId,
  required String namespace,
  Map<String, List<String>>? identities,
  String? policyArn,
}) async {
  ArgumentError.checkNotNull(assignmentName, 'assignmentName');
  _s.validateStringLength(
    'assignmentName',
    assignmentName,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(assignmentStatus, 'assignmentStatus');
  ArgumentError.checkNotNull(awsAccountId, 'awsAccountId');
  _s.validateStringLength(
    'awsAccountId',
    awsAccountId,
    12,
    12,
    isRequired: true,
  );
  ArgumentError.checkNotNull(namespace, 'namespace');
  _s.validateStringLength(
    'namespace',
    namespace,
    0,
    64,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'AssignmentName': assignmentName,
    'AssignmentStatus': assignmentStatus.toValue(),
    if (identities != null) 'Identities': identities,
    if (policyArn != null) 'PolicyArn': policyArn,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/accounts/${Uri.encodeComponent(awsAccountId)}/namespaces/${Uri.encodeComponent(namespace)}/iam-policy-assignments/',
    exceptionFnMap: _exceptionFns,
  );
  return CreateIAMPolicyAssignmentResponse.fromJson(response);
}