Rule Engine API
Rule Engine API provides HTTP API to control engine and its rules.
Get Rule Engine
GET sites/{site_id}/rule_engine
Returns information about the rule engine on the specified site.
Request
$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
Response
Rule engine information:
{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "ACTIVE",
"timezone": "UTC"
}
}
engineobject#Rule Engine information.
engine.idstring#Rule Engine ID.
engine.statestring#Can be
ACTIVEorSUSPENDED.
engine.timezonestring#The time zone is the same as the site's time zone.
Suspend Rule Engine
POST sites/{site_id}/rule_engine/suspend
Suspends the rule engine on the specified site.
Request
$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/suspend \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'
Response
Rule engine information:
{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "SUSPENDED",
"timezone": "UTC"
}
}
engineobject#Rule Engine information.
engine.idstring#Rule Engine ID.
engine.statestring#Can be
ACTIVEorSUSPENDED.
engine.timezonestring#The time zone is the same as the site's time zone.
Resume Rule Engine
POST sites/{site_id}/rule_engine/resume
Resumes a previously suspended rule engine on the specified site.
Request
$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/resume \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'
Response
Rule engine information:
{
"engine": {
"id": "abcdefg0-79f2-4e9e-a6f0-69a310ab110b",
"state": "ACTIVE",
"timezone": "UTC"
}
}
engineobject#Rule Engine information.
engine.idstring#Rule Engine ID.
engine.statestring#Can be
ACTIVEorSUSPENDED.
engine.timezonestring#The time zone is the same as the site's time zone.
Create Rule
POST sites/{site_id}/rule_engine/rules
Creates a new rule in the rule engine on the specified site.
Request
$ curl -X POST \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"slug": "start-generator-1",
"script": {
"code": "...",
"runtime_version": "V3"
},
"disable": false
}'
Body Parameters
namestringrequired#The name of the new rule.
scriptobjectrequired#The object describing rule script.
scriptobject#Rule script information.
script.codestring#Rule script code as base64 encoded string.
script.runtime_versionstring#V1orV3.
Response
Information about the created rule:
{
"rule": {
"id": "qwertyu1-23z4-5x6c-a6f0-69a310ab110b",
"slug": "start-generator-1",
"disabled": false,
"script": {
"code": "...",
"runtime_version": "V3"
},
"state": "STARTED"
}
}
ruleobject#Rule information.
rule.idstring#Rule ID.
rule.slugstring#Rule slug.
scriptobject#Rule script information.
script.codestring#Rule script code as base64 encoded string.
script.runtime_versionstring#V1orV3.
rule.disabledboolean#Indicates whether rule is enabled or disabled.
rule.statestring#Can be
STARTEDorSTOPPED.
List Rules
GET sites/{site_id}/rule_engine/rules
Returns all rules configured in the rule engine on the specified site.
Request
$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/rule_engine/rules \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'