updatePolicy method
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.
This operation can be called only from the organization's management account.
May throw AccessDeniedException. May throw AWSOrganizationsNotInUseException. May throw ConcurrentModificationException. May throw ConstraintViolationException. May throw DuplicatePolicyException. May throw InvalidInputException. May throw MalformedPolicyDocumentException. May throw PolicyNotFoundException. May throw ServiceException. May throw TooManyRequestsException. May throw UnsupportedAPIEndpointException. May throw PolicyChangesInProgressException.
Parameter policyId
:
The unique identifier (ID) of 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 Service
Control Policy Syntax in the AWS 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 {
ArgumentError.checkNotNull(policyId, 'policyId');
_s.validateStringLength(
'policyId',
policyId,
0,
130,
isRequired: true,
);
_s.validateStringLength(
'content',
content,
1,
1000000,
);
_s.validateStringLength(
'description',
description,
0,
512,
);
_s.validateStringLength(
'name',
name,
1,
128,
);
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);
}