rules.json Attributes

This page describes the JSON attributes for defining rule objects used in template-to-app-rules.json and app-to-template-rules.json. For background on how rules fit into the App Template Framework, see Work with App Template Framework Rules.

Rules files are made up of three sections: rules, constants, and macros.

Rules 

AttributePathRequiredDescription
rules(top-level)NoAn array of rules to define. Can be empty if no rules are needed.
descriptionrulesNoA description for the rule.
namerulesYesA unique name for a rule.
conditionrulesNoIf the condition is met, the rule runs. If the condition is not met, the rule does not run.
appliesTorulesYesAn array of assets the rule applies to, such as dashboards, recipes, schemas, and XMDs.
namerules.appliesToNoThe name of the asset. Can be * to apply the rule to all dashboards. Must match the name defined in the template-info for the asset. Best practice is to specify name. If null, defaults to * and the rule applies to all template assets.
typerules.appliesToNoThe type of asset: dashboard, workflow, lens, schema, or xmd. Best practice is to specify type. If null, defaults to * and the rule applies to all asset types.
actionsrulesYesAn array of actions the rule invokes. One or more action are required.
actionrules.actionsYesThe type of action to perform: set, add, delete, put, eval, or replace.
descriptionrules.actionsNoA description of the rule action, used for maintainability.
pathrules.actionsYesThe JSONPath to apply the action to.
valuerules.actionsNoThe value to place at the JSONPath. Required for set, add, and put actions.
indexrules.actionsNoThe index position for the action. Required for the add action only.
keyrules.actionsNoThe key for the action. Required for the put action only.
conditionrules.actionsNoIf the condition is met, the action runs. If the condition is not met, the action is skipped. Use this field to apply a condition to a single action instead of the whole rule.

Constants 

AttributePathRequiredDescription
constants(top-level)NoAn array of constants to define. Can be empty if no constants are needed.
nameconstantsYesA unique name for a constant, used to reference the constant in other places.
valueconstantsYesThe value of the constant.

Macros 

AttributePathRequiredDescription
macros(top-level)NoAn array of macro namespace objects. Can be empty if no macros are needed.
namespacemacrosYesA unique namespace that groups related macro definitions. Used with a macro’s name to call it, for example ${widget_util:findWidget(...)}.
definitionsmacrosYesAn array of macro definitions within the namespace.
namemacros.definitionsYesThe name of the macro.
descriptionmacros.definitionsNoA string that describes what the macro does.
parametersmacros.definitionsYesAn array of zero or more parameter names that the macro expects. Reference a parameter’s value with ${p.<parameterName>}.
actionsmacros.definitionsAn array of zero or more rule actions to perform as part of the macro, using the same action schema as rules.actions — see the Actions rows above. Omit if the macro only returns a computed value.
returnsmacros.definitionsNoAn expression or literal value to be returned from the macro. Omit if the macro only performs actions and doesn’t return a value.

See Also