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.
| Attribute | Path | Required | Description |
|---|---|---|---|
rules | (top-level) | No | An array of rules to define. Can be empty if no rules are needed. |
description | rules | No | A description for the rule. |
name | rules | Yes | A unique name for a rule. |
condition | rules | No | If the condition is met, the rule runs. If the condition is not met, the rule does not run. |
appliesTo | rules | Yes | An array of assets the rule applies to, such as dashboards, recipes, schemas, and XMDs. |
name | rules.appliesTo | No | The 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. |
type | rules.appliesTo | No | The 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. |
actions | rules | Yes | An array of actions the rule invokes. One or more action are required. |
action | rules.actions | Yes | The type of action to perform: set, add, delete, put, eval, or replace. |
description | rules.actions | No | A description of the rule action, used for maintainability. |
path | rules.actions | Yes | The JSONPath to apply the action to. |
value | rules.actions | No | The value to place at the JSONPath. Required for set, add, and put actions. |
index | rules.actions | No | The index position for the action. Required for the add action only. |
key | rules.actions | No | The key for the action. Required for the put action only. |
condition | rules.actions | No | If 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. |
| Attribute | Path | Required | Description |
|---|---|---|---|
constants | (top-level) | No | An array of constants to define. Can be empty if no constants are needed. |
name | constants | Yes | A unique name for a constant, used to reference the constant in other places. |
value | constants | Yes | The value of the constant. |
| Attribute | Path | Required | Description |
|---|---|---|---|
macros | (top-level) | No | An array of macro namespace objects. Can be empty if no macros are needed. |
namespace | macros | Yes | A unique namespace that groups related macro definitions. Used with a macro’s name to call it, for example ${widget_util:findWidget(...)}. |
definitions | macros | Yes | An array of macro definitions within the namespace. |
name | macros.definitions | Yes | The name of the macro. |
description | macros.definitions | No | A string that describes what the macro does. |
parameters | macros.definitions | Yes | An array of zero or more parameter names that the macro expects. Reference a parameter’s value with ${p.<parameterName>}. |
actions | macros.definitions | An 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. | |
returns | macros.definitions | No | An 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