-
Notifications
You must be signed in to change notification settings - Fork 16
Rule Management
This API is used to manage Rules. A Rule is an association between one or more device's components, a set of conditions for those components, and a number of actions that have to be triggered in case those conditions are met.
|Type|Target|Description| |-----|:--:|--------------------|---------| |"mail"|["[email protected]"]|Array of recipients' email addresses| |"http"|["http://www.example.com"]|Array of HTTP endpoints where request should be sent. They should expect and accept POST requests.|
To receive alerts as requests to HTTP endpoint, set "type" in actions section to "http" and "target" in the same section to desired endpoint. Additionally you can add custom HTTP headers to received alerts. To do this, add "http_headers" object to "actions" section if chosen action type is http. Example:
"actions": [
{
"type": "http",
"target": [
"http://test.com"
],
"http_headers":
{
"header1": "value1",
"header2": "value2"
}
}]
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
Content-Type | HTTP Header | Type of body content | application/json |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
Request
POST /accounts/{accountId}/rules
{
"name": "Test Rule",
"description": "This is a test rule",
"priority": "Medium",
"type": "Regular",
"status": "Active",
"resetType": "Automatic",
"actions": [
{
"type": "mail",
"target": [
"[email protected]"
]
}
],
"population": {
"ids": [ "685.1.1.1" ],
"attributes": null
},
"conditions": {
"operator": "OR",
"values": [
{
"component": {
"dataType": "Number",
"name": "Temp.01.1"
},
"type": "basic",
"values": [ "25" ],
"operator": ">"
}
]
}
}
Response 201 CREATED (application/json)
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
Content-Type | HTTP Header | Type of body content | application/json |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
ruleId | URL Slug | The ID of a Rule | 6831 |
Request
POST /accounts/{accountId}/rules/clone/{ruleId}
Response 200 OK (application/json)
If rule doesn't exist it create a new one. Cannot be used for update of a draft rule.
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
Content-Type | HTTP Header | Type of body content | application/json |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
ruleId | URL Slug | The ID of a Rule | 6831 |
Request
PUT /accounts/{accountId}/rules/{ruleId}
{
"name": "Test Rule",
"description": "This is a test rule",
"priority": "Medium",
"type": "Regular",
"status": "Active",
"actions": [
{
"type": "http",
"target": [
"http://test.com"
],
"http_headers":
{
"header1": "value1",
"header2": "value2"
}
}
],
"conditions": {
"operator": "OR",
"values": [
{
"component": {
"dataType": "Number",
"name": "Temp.01.1"
},
"type": "basic",
"values": [
"25"
],
"operator": ">"
}
]
},
"resetType": "Automatic",
"population": {
"ids": [
"685.1.1.1"
],
"attributes": null
}
}
Response 200 OK
{
"externalId": "6831",
"domainId": "0d66c8b6-9f4d-4551-a9c8-d356c2dd033d",
"creationDate": 1411129409587,
"lastUpdateDate": 1411127836926,
"status": "Active",
"actions": [
{
"type": "mail",
"target": [
"[email protected]"
]
}
],
"id": "541c2041b3700bcbe9c76fc4"
}
Get a list of all rules for the specified account.
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
Request
GET /accounts/{accountId}/rules
Response 200 OK (application/json)
[
{
"externalId": 6831,
"name": "rule2",
"description": "test rule",
"owner": "[email protected]",
"naturalLanguage": "temperatura Equal 45 Or ",
"type": "Regular",
"creationDate": 1411119645083,
"lastUpdateDate": 1411119645083,
"resetType": "Manual",
"priority": "Low",
"status": "Active",
"population": {},
"conditions": {
"operator": "OR",
"values": []
}
}
]
Get specific rule details for the account.
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
ruleId | URL Slug | The ID of a Rule | 9bd17edc04e3a07f636af4b7be72a0967c19f0ac |
Request
GET /accounts/{accountId}/rules/{ruleId}
Response 200 OK (application/json)
{
"id": "541c09dd63de1a9f63216f63",
"creationDate": 1411123677425,
"domainId": "0d66c8b6-9f4d-4551-a9c8-d356c2dd033d",
"externalId": "9bd17edc04e3a07f636af4b7be72a0967c19f0ac",
"lastUpdateDate": 1411123677425,
"name": "draft2",
"owner": "[email protected]",
"status": "Draft"
}
Create a rule with a status - "Draft" for the specified account.
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
Content-Type | HTTP Header | Type of body content | application/json |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
Request
PUT /accounts/{accountId}/rules/draft
{
"name": "draftRule",
}
Response 200 OK (application/json)
{
"id": "541c09dd63de1a9f63216f63",
"creationDate": 1411123677425,
"domainId": "0d66c8b6-9f4d-4551-a9c8-d356c2dd033d",
"externalId": "9bd17edc04e3a07f636af4b7be72a0967c19f0ac",
"lastUpdateDate": 1411123677425,
"name": "draftRule",
"owner": "[email protected]",
"status": "Draft"
}
Update the status of the rule. Cannot be used for changing the status of draft rule. Status value should be one of the following: ["Active", "Archived", "On-hold"]
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
Content-Type | HTTP Header | Type of body content | application/json |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
ruleId | URL Slug | The ID of a Rule | 2c6cbf002516cf81913471da4d41daed212bde8f |
Request
PUT /accounts/{accountId}/rules/status
{
"status": "Archived",
}
Response 200 OK (application/json)
{
"id": "541bfa1eb3700bcbe9c76fc2",
"actions": [
{
"type": "mail",
"target": [
"[email protected]"
]
}
],
"creationDate": 1411119645083,
"domainId": "0d66c8b6-9f4d-4551-a9c8-d356c2dd033d",
"externalId": "6831",
"lastUpdateDate": 1411127836926,
"status": "Archived"
}
Delete a specific draft rule for account
Param | Type | Description | Value |
---|---|---|---|
Authorization | HTTP Header | Access Token | Authorization: Bearer eyJ0eX... |
accountId | URL Slug | The ID of an Account | 534da46c820cb9f74a0d3de6 |
ruleId | URL Slug | The ID of a Rule | 2c6cbf002516cf81913471da4d41daed212bde8f |
Request
DELETE /accounts/{accountId}/rules/draft/{ruleId}
Response 204 OK
- Home
-
Overview
- Rule Engine
- Service Hub
- Dashboard
- Data Backend
- Integration of Analytics
- IoT Agent
- Using Docker
- Authentication and Authorization
- Rest API
- Configuration
- Build