addPolicyStatement method

Future<AddPolicyStatementOutput> addPolicyStatement({
  1. required List<String> action,
  2. required String arn,
  3. required StatementEffect effect,
  4. required List<String> principal,
  5. required String statementId,
  6. String? condition,
})

Adds a policy statement object. To retrieve a list of existing policy statements, use the GetPolicy API.

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

Parameter action : The action that the principal can use on the resource.

For example, entityresolution:GetIdMappingJob, entityresolution:GetMatchingJob.

Parameter arn : The Amazon Resource Name (ARN) of the resource that will be accessed by the principal.

Parameter effect : Determines whether the permissions specified in the policy are to be allowed (Allow) or denied (Deny).

Parameter principal : The Amazon Web Services service or Amazon Web Services account that can access the resource defined as ARN.

Parameter statementId : A statement identifier that differentiates the statement from others in the same policy.

Parameter condition : A set of condition keys that you can use in key policies.

Implementation

Future<AddPolicyStatementOutput> addPolicyStatement({
  required List<String> action,
  required String arn,
  required StatementEffect effect,
  required List<String> principal,
  required String statementId,
  String? condition,
}) async {
  final $payload = <String, dynamic>{
    'action': action,
    'effect': effect.value,
    'principal': principal,
    if (condition != null) 'condition': condition,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/policies/${Uri.encodeComponent(arn)}/${Uri.encodeComponent(statementId)}',
    exceptionFnMap: _exceptionFns,
  );
  return AddPolicyStatementOutput.fromJson(response);
}