PolicyAction expressions

Table of contents

Policy Action expressions are used to reference Policy Actions. They can return PolicyActionSave, PolicyActionClear, PolicyActionJsonMerge and PolicyActionJsonPatch entities. Parser command to be invoked is PEELParser(str).parseAction() and it returns IPolicyAction entity.

Command table

CommandTypeformatoptions
*savePolicyAction*save(<content|PolicyVariable|Reference>{2,2},#opts?)failOnMissingKey(*), failOnExistingKey(*), failOnNullSource(*)
*clearPolicyAction*clear(<content>{1,1},#opts?)failOnMissingKey(*)
*patchPolicyAction*patch((<content|PolicyVariable|Reference>{3,3},#opts?)failOnMissingKey(*), failOnExistingKey(*), failOnNullSource(*), castNullSourceToArray(*)
*mergePolicyAction*merge((<content|PolicyVariable|Reference>{3,3},#opts?)failOnMissingKey(*), failOnExistingKey(*), failOnNullSource(*), failOnNullMerge(*), type, format

(*) - Boolean condition

PolicyActionSave

Template: *save(<content|PolicyVariable|Reference>{2,2},#opts?)
Command starts with *save
It can contain:

  • one parameter of type content that represents key field
  • one parameter of type PolicyVariable or Reference that represents value field

Supported options:

  • failOnMissingKey - boolean, default value is null. It will fail if key cannot be found
  • failOnExistingKey - boolean, default value is null. It will fail if key exists
  • failOnNullSource - boolean, default value is null. It will fail if value resolves to null

Minimal example:

*save(foo,#ref(pvd1))

Full example with options:

*save(foo,#ref(pvd1),#opts(id=cond,ver=1.2.3,desc="Some desc",labels=foo|bar,failOnMissingKey,failOnExistingKey,failOnNullSource))

PolicyActionClear

Template: *clear(<content>{1,1},#opts?)
Command starts with *clear
It can contain:

  • one parameter of type content that represents key field

Supported options:

  • failOnMissingKey - boolean, default value is null. It will fail if key cannot be found

Minimal example:

*clear(foo)

Full example with options:

*clear(foo,#opts(id=cond,ver=1.2.3,desc="Some desc",labels=foo|bar,failOnMissingKey))

PolicyActionPatch

Template: *patch((<content|PolicyVariable|Reference>{3,3},#opts?)
Command starts with *patch
It can contain:

  • one parameter of type content that represents key field
  • two parameters of type PolicyVariable or Reference where:
    • first parameter represents source field
    • second parameter represents patch field

Supported options:

  • failOnMissingKey - boolean, default value is null. It will fail if key cannot be found
  • failOnExistingKey - boolean, default value is null. It will fail if key exists
  • failOnNullSource - boolean, default value is null. It will fail if source resolves to null
  • castNullSourceToArray - boolean, default value is null. It will fail if value resolves to null

Minimal example:

*patch(foo,#ref(pvd1),#ref(pvd2))

Full example with options:

*patch(foo,#ref(pvd1),#ref(pvd2),#opts(id=cond,ver=1.2.3,desc="Some desc",labels=foo|bar,failOnMissingKey,failOnExistingKey,failOnNullSource,castNullSourceToArray))

PolicyActionMerge

Template: *merge((<content|PolicyVariable|Reference>{3,3},#opts?)
Command starts with *merge
It can contain:

  • one parameter of type content that represents key field
  • two parameters of type PolicyVariable or Reference where:
    • first parameter represents source field
    • second parameter represents merge field

Supported options:

  • failOnMissingKey - boolean, default value is null. It will fail if key cannot be found
  • failOnExistingKey - boolean, default value is null. It will fail if key exists
  • failOnNullSource - boolean, default value is null. It will fail if source resolves to null
  • failOnNullmerge - boolean, default value is null. It will fail if merge resolves to null
  • type - string enum, default value is null. It can contain possible variable types to which parsed value will be cast to
  • format - string enum, default value is null. It can contain possible variable formats to which parsed value will be cast to

Minimal example:

*merge(foo,#ref(pvd1),#ref(pvd2))

Full example with options:

*merge(foo,#ref(pvd1),#ref(pvd2),#opts(id=cond,ver=1.2.3,desc="Some desc",labels=foo|bar,failOnMissingKey,failOnExistingKey,failOnNullSource,failOnNullMerge,type=string,format=time))