updatePolicyTemplate method

Future<UpdatePolicyTemplateOutput> updatePolicyTemplate({
  1. required String policyStoreId,
  2. required String policyTemplateId,
  3. required String statement,
  4. String? description,
  5. String? name,
})

Updates the specified policy template. You can update only the description and the some elements of the policyBody.

May throw ConflictException. May throw ResourceNotFoundException.

Parameter policyStoreId : Specifies the ID of the policy store that contains the policy template that you want to update.

To specify a policy store, use its ID or alias name. When using an alias name, prefix it with policy-store-alias/. For example:

  • ID: PSEXAMPLEabcdefg111111
  • Alias name: policy-store-alias/example-policy-store
To view aliases, use ListPolicyStoreAliases.

Parameter policyTemplateId : Specifies the ID of the policy template that you want to update.

You can use the policy template name in place of the policy template ID. When using a name, prefix it with name/. For example:

  • ID: PTEXAMPLEabcdefg111111
  • Name: name/example-policy-template

Parameter statement : Specifies new statement content written in Cedar policy language to replace the current body of the policy template.

You can change only the following elements of the policy body:

  • The action referenced by the policy template.
  • Any conditional clauses, such as when or unless clauses.
You can't change the following elements:
  • The effect (permit or forbid) of the policy template.
  • The principal referenced by the policy template.
  • The resource referenced by the policy template.

Parameter description : Specifies a new description to apply to the policy template.

Parameter name : Specifies a name for the policy template that is unique among all policy templates within the policy store. You can use the name in place of the policy template ID in API operations that reference the policy template. The name must be prefixed with name/. If you specify a name that is already associated with another policy template in the policy store, you receive a ConflictException error.

Implementation

Future<UpdatePolicyTemplateOutput> updatePolicyTemplate({
  required String policyStoreId,
  required String policyTemplateId,
  required String statement,
  String? description,
  String? name,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'VerifiedPermissions.UpdatePolicyTemplate'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'policyStoreId': policyStoreId,
      'policyTemplateId': policyTemplateId,
      'statement': statement,
      if (description != null) 'description': description,
      if (name != null) 'name': name,
    },
  );

  return UpdatePolicyTemplateOutput.fromJson(jsonResponse.body);
}