updatePolicyTemplate
inline suspend fun VerifiedPermissionsClient.updatePolicyTemplate(crossinline block: UpdatePolicyTemplateRequest.Builder.() -> Unit): UpdatePolicyTemplateResponse
Updates the specified policy template. You can update only the description and the some elements of the policyBody.
Changes you make to the policy template content are immediately (within the constraints of eventual consistency) reflected in authorization decisions that involve all template-linked policies instantiated from this template.
Verified Permissions is eventually consistent. It can take a few seconds for a new or changed element to propagate through the service and be visible in the results of other Verified Permissions operations.
Samples
fun main() {
//sampleStart
// The following example updates a policy template with both a new description and a new policy body.
// The effect, principal, and resource are the same as the original policy template. Only the action in
// the head, and the when and unless clauses can be different. Note The JSON in the parameters of this
// operation are strings that can contain embedded quotation marks
// (") within the outermost quotation mark pair. This requires that you stringify the JSON object by preceding all embedded quotation marks with a backslash character ( \" ) and combining all lines into a single text line with no line breaks. Example strings might be
// displayed wrapped across multiple lines here for readability, but the operation requires the parameters be
// submitted as single line strings.
val resp = verifiedPermissionsClient.updatePolicyTemplate {
description = "My updated template description"
policyStoreId = "C7v5xMplfFH3i3e4Jrzb1a"
policyTemplateId = "PTEXAMPLEabcdefg111111"
statement = "\"ResearchAccess\"\npermit(\nprincipal in ?principal,\naction == Action::\"view\",\nresource in ?resource\"\n)\nwhen {\nprincipal has department && principal.department == \"research\"\n};"
}
//sampleEnd
}