Policy Action

Table of contents

PolicyAction represents an entity that applies side effect to the Policy evaluation that is realized through the modification of the Context data store.

It is defined by IPolicyAction interface, which has the following fields:

fieldtypecardinalitydescription
typeStringmandatoryDetermines type of PolicyAction. Possible values are:
* save
* clear
* jsonMerge
* jsonPatch

IPolicyAction interface implements IManaged interface. The IPolicyAction interface has four implementations:

PolicyActionSave

This entity represents an action that saves a value to the Context data store.

fieldtypecardinalitydescription
keyStringmandatoryThe key to use when saving the value in the data store.
valueIPolicyVariableRefOrValuemandatoryDefinition of a PolicyVariable. It is used as a source of a value that will be stored in the provided key
failOnMissingKeyBooleanoptionalFlag that determines should key already be defined in Context data store. Used for purposes when PolicyAction is strictly overriding existing value. Default value is false
failOnExistingKeyBooleanoptionalFlag that determines if key shouldn’t be defined in Context data store. Used for purposes when PolicyAction is strictly setting up new value. Default value is false
failOnNullSourceBooleanoptionalFlag that determines if action should fail if source PolicyVariable resolves to null. Default value is false

Examples

PolicyActionSave with static field

{
    "key": "foo",
    "value": {
        "type": "string",
        "value": "bar"
    },
    "failOnExistingKey": true,
    "type": "save"
}

PolicyActionSave with dynamic field

{
    "key": "foo",
    "value": {
        "resolvers": [
            {
                "id": "birthdayResolver",
                "refType": "PolicyVariableResolverRef"
            }
        ]
    },
    "failOnMissingKey": true,
    "failOnNullSource": true,
    "type": "save"
}

Managed PolicyActionSave

{
    "id": "polAct1",
    "version": "1.2.3",
    "description": "This is a managed PolicyActionSave",
    "labels": [
        "label1"
    ],
    "key": "foo",
    "value": {
        "resolvers": [
            {
                "id": "birthdayResolver",
                "refType": "PolicyVariableResolverRef"
            }
        ]
    },
    "failOnMissingKey": true,
    "failOnNullSource": true,
    "type": "save"
}

PolicyActionClear

This entity represents an action that deletes a value to the Context data store.

fieldtypecardinalitydescription
keyStringmandatoryThe key to be cleared from the data store.
failOnMissingKeyBooleanoptionalFlag that determines should key already be defined in Context data store. Used for purposes when PolicyAction needs to fail if key that is about to be deleted doesn’t exist. Default value is false

Examples

PolicyActionClear

{
    "key": "foo",
    "failOnMissingKey": true,
    "type": "clear"
}

Managed PolicyActionClear

{
    "id": "polAct1",
    "version": "1.2.3",
    "description": "This is a managed PolicyActionClear",
    "labels": [
        "label1"
    ],
    "key": "foo",
    "failOnMissingKey": true,
    "type": "clear"
}

PolicyActionJsonMerge

This entity represents an action that merges a JSON values from PolicyVariables into a Context data store key. JsonPatch library is used to merge provided PolicyVariables.

fieldtypecardinalitydescription
keyStringmandatoryThe key to use when saving the result value in the data store.
sourceIPolicyVariableRefOrValuemandatoryDefinition of a PolicyVariable. It is used as a source of the Json merge operation. Source value must be one of the following types (or castable to that type):
* Null
* JsonNode
* JsonObject
* JsonArray
mergeIPolicyVariableRefOrValuemandatoryDefinition of a PolicyVariable. It is used as a target value of the Json merge operation that will merged to the source value. Merge value must be one of the following types (or castable to that type):
* Null
* JsonNode
* JsonObject
* JsonArray
failOnMissingKeyBooleanoptionalFlag that determines should key already be defined in Context data store. Used for purposes when PolicyAction is strictly overriding existing value. Default value is false
failOnExistingKeyBooleanoptionalFlag that determines if key shouldn’t be defined in Context data store. Used for purposes when PolicyAction is strictly setting up new value. Default value is false
failOnNullSourceBooleanoptionalFlag that determines if action should fail if source PolicyVariable resolves to null. Default value is false
failOnNullMergeBooleanoptionalFlag that determines if action should fail if merge PolicyVariable resolves to null. Default value is false
destinationTypeStringoptionalSets value type of the result variable.
destinationFormatStringoptionalSets value format of the result variable

Examples

PolicyActionJsonMerge

{
    "key": "someJson",
    "source": {
        "type": "string",
        "value": "{\"foo\":\"bar\"}"
    },
    "merge": {
        "type": "string",
        "value": "{\"foo\":\"baz\"}"
    },
    "type": "jsonMerge"
}

Managed PolicyActionJsonMerge

{
    "id": "polAct1",
    "version": "1.2.3",
    "description": "This is a managed PolicyActionJsonMerge",
    "labels": [
        "label1"
    ],
    "key": "someJson",
    "source": {
        "id": "polVar1",
        "refType": "PolicyVariableRef"
    },
    "merge": {
        "type": "string",
        "value": "{\"foo\":\"baz\"}"
    },
    "failOnMissingKey": true,
    "failOnNullSource": true,
    "type": "jsonMerge"
}

PolicyActionJsonPatch

This entity represents an action that patches a JSON value from PolicyVariables into a Context data store key. JsonPatch library is used to patch provided PolicyVariable with defined JsonPatch definition.

fieldtypecardinalitydescription
keyStringmandatoryThe key to use when saving the result value in the data store.
sourceIPolicyVariableRefOrValuemandatoryDefinition of a PolicyVariable. It is used as a source of the Json patch operation. Source value must be one of the following types (or castable to that type):
* Null
* JsonNode
* JsonObject
* JsonArray
patchIPolicyVariableRefOrValuemandatoryDefinition of a PolicyVariable. It is used as a definition of the Json patch operation that will applied to the source value. Patch value must be JsonArray or Array type
failOnMissingKeyBooleanoptionalFlag that determines should key already be defined in Context data store. Used for purposes when PolicyAction is strictly overriding existing value. Default value is false
failOnExistingKeyBooleanoptionalFlag that determines if key shouldn’t be defined in Context data store. Used for purposes when PolicyAction is strictly setting up new value. Default value is false
failOnNullSourceBooleanoptionalFlag that determines if action should fail if source PolicyVariable resolves to null. Default value is false
castNullSourceToArrayBooleanoptionalFlag that determines if null source value should be casted to the empty array. Default value is false

Examples

PolicyActionJsonPatch

{
    "key": "someJson",
    "source": {
        "type": "string",
        "value": "{\"foo\":[\"bar\",\"baz\"],\"foo2\":\"baz\"}"
    },
    "patch": {
        "type": "string",
        "value": "[{\"op\":\"replace\",\"path\":\"/foo\",\"value\":[\"bar\"]}]"
    },
    "type": "jsonPatch"
}

Managed PolicyActionJsonPatch

{
    "id": "polAct1",
    "version": "1.2.3",
    "description": "This is a managed PolicyActionJsonPatch",
    "labels": [
        "label1"
    ],
    "key": "someJson",
    "source": {
        "id": "polVar1",
        "refType": "PolicyVariableRef"
    },
    "patch": {
        "type": "string",
        "value": "[{\"op\":\"replace\",\"path\":\"/foo\",\"value\":[\"bar\"]}]"
    },
    "failOnMissingKey": true,
    "failOnNullSource": true,
    "type": "jsonPatch"
}

PolicyActionRef

PolicyActionRef is entity that references a PolicyAction of any type. It contains following fields:

fieldtypecardinalitydescription
idStringmandatoryid of the managed PolicyAction
versionStringoptionalSemVer of the referenced PolicyAction. If it is left blank, latest version of a PolicyAction will be populated
refTypeStringmandatorydiscriminator that is used when deserializing catalog from JSON file. It has constant value of PolicyActionRef