MCPcopy Create free account
hub / github.com/StackStorm/st2 / RuleAPI

Class RuleAPI

st2common/st2common/models/api/rule.py:86–232  ·  view source on GitHub ↗

Attribute: trigger_type: Trigger that trips this rule. Of the form {'id':'1234', 'name':'trigger-1'}. Only 1 of the id or name is required and if both are specified name is ignored. criteria: Criteria used to further restrict the trigger that applies to this rule.

Source from the content-addressed store, hash-verified

84
85
86class RuleAPI(BaseAPI, APIUIDMixin):
87 """
88 Attribute:
89 trigger_type: Trigger that trips this rule. Of the form {'id':'1234', 'name':'trigger-1'}.
90 Only 1 of the id or name is required and if both are specified name is ignored.
91 criteria: Criteria used to further restrict the trigger that applies to this rule.
92 e.g.
93 { "trigger.from" :
94 { "pattern": "@gmail.com$"
95 , "type": "matchregex" }
96 , "trigger.subject" :
97 { "pattern": "RE:"
98 , "operator": "contain" }
99 }
100 action: Specification of the action to execute and the mappings to apply.
101 expected arguments are name, parameters.
102 e.g.
103 "action":
104 { "name": "st2.action.foo"
105 , "parameters":
106 { "command": "{{ system.foo }}"
107 , "args": "--email {{ trigger.from }} --subject \'{{ user[stanley].ALERT_SUBJECT }}\'"}
108 }
109 status: enabled or disabled. If disabled occurrence of the trigger
110 does not lead to execution of a action and vice-versa.
111 """
112
113 model = RuleDB
114 schema = {
115 "type": "object",
116 "properties": {
117 "id": {"type": "string", "default": None},
118 "ref": {
119 "description": (
120 "System computed user friendly reference for the rule. "
121 "Provided value will be overridden by computed value."
122 ),
123 "type": "string",
124 },
125 "uid": {"type": "string"},
126 "name": {"type": "string", "required": True},
127 "pack": {"type": "string", "default": DEFAULT_PACK_NAME},
128 "description": {"type": "string"},
129 "type": RuleTypeSpec.schema,
130 "trigger": {
131 "type": "object",
132 "required": True,
133 "properties": {
134 "type": {"type": "string", "required": True},
135 "description": {"type": "string", "require": False},
136 "parameters": {"type": "object", "default": {}},
137 "ref": {"type": "string", "required": False},
138 },
139 "additionalProperties": True,
140 },
141 "criteria": {"type": "object", "default": {}},
142 "action": {
143 "type": "object",

Calls

no outgoing calls