updatePolicy method

Future<UpdatePolicyResponse> updatePolicy({
  1. required String policyId,
  2. String? content,
  3. String? description,
  4. String? name,
})

Updates an existing policy with a new name, description, or content. If you don't supply any parameter, that value remains unchanged. You can't change a policy's type.

You can only call this operation from the management account or a member account that is a delegated administrator.

May throw AccessDeniedException. May throw AWSOrganizationsNotInUseException. May throw ConcurrentModificationException. May throw ConstraintViolationException. May throw DuplicatePolicyException. May throw InvalidInputException. May throw MalformedPolicyDocumentException. May throw PolicyChangesInProgressException. May throw PolicyNotFoundException. May throw ServiceException. May throw TooManyRequestsException. May throw UnsupportedAPIEndpointException.

Parameter policyId : ID for the policy that you want to update.

The regex pattern for a policy ID string requires "p-" followed by from 8 to 128 lowercase or uppercase letters, digits, or the underscore character (_).

Parameter content : If provided, the new content for the policy. The text must be correctly formatted JSON that complies with the syntax for the policy's type. For more information, see SCP syntax in the Organizations User Guide.

The maximum size of a policy document depends on the policy's type. For more information, see Maximum and minimum values in the Organizations User Guide.

Parameter description : If provided, the new description for the policy.

Parameter name : If provided, the new name for the policy.

The regex pattern that is used to validate this parameter is a string of any of the characters in the ASCII character range.

Implementation

Future<UpdatePolicyResponse> updatePolicy({
  required String policyId,
  String? content,
  String? description,
  String? name,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSOrganizationsV20161128.UpdatePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'PolicyId': policyId,
      if (content != null) 'Content': content,
      if (description != null) 'Description': description,
      if (name != null) 'Name': name,
    },
  );

  return UpdatePolicyResponse.fromJson(jsonResponse.body);
}