Create rule
- Print
- PDF
Create rule
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Summary
Creates a rule.
Request
Request URL
POST {CLOUD_IOT_CORE_API_URL}/rules
Content-Type: application/json; charset=utf-8
x-ncp-apigw-timestamp: {Timestamp}
x-ncp-iam-access-key: {Sub Account Access Key}
x-ncp-apigw-signature-v2: {API Gateway Signature}
Request body
{
"rule": {
"name": "string",
"description": "string",
"query": "string"
},
"actions": {
"matchActionList": [
{
"relatedProduct": "string",
"relatedProductAction": "json"
}
],
"errorAction": {
"relatedProduct": "string",
"relatedProductAction": "json"
}
}
}
Category | Required status | Type | Restrictions | Description |
---|---|---|---|---|
rule | Yes | rule | ||
rule.name | Yes | string | Less than 128 characters. Only lower and upper English letters, numbers, -, and _ are allowed. | Name of the rule |
rule.description | No | string | Less than 255 characters | Description of the rule |
rule.query | Yes | string | rule query rules | rule query |
actions | Yes | Action | ||
matchedActionList | Yes | Action to take when rule query is satisfied | ||
actions.matchedActionList[].relateProduct | Yes | string | Refer to relatedProduct below | Type of action to be linked |
actions.matchedActionList[].relateProductAction | Yes | json | Refer to relatedProductAction below | Details of action to be linked |
errorAction | No | When linking error actions, the relatedProduct, relatedProductAction fields are mandatory | Error action | |
errorAction.relateProduct | No | string | Refer to relatedProduct below | Type of action to be linked |
errorAction.relateProductAction | No | json | Refer to relatedProductAction below | Details of action to be linked |
relatedProduct
relatedProduct | Action name |
---|---|
REPUBLISH | Republish as a specified topic |
CLOUD_FUNCTIONS | Transfer data to Cloud Functions |
relatedProductAction
- REPUBLISH
{
"topic": "string"
}
Category | Required status | Type | Restrictions | Description |
---|---|---|---|---|
topic | Yes | string | Topic limitations | Republish topic |
- CLOUD_FUNCTIONS
{
"name": "string",
"batchTime": "integer"
}
Category | Required status | Type | Restrictions | Description |
---|---|---|---|---|
name | Yes | string | Name of IoT trigger registered in Cloud functions | |
batchTime | No | integer | Min: 5, Max: 600 | Cloud Functions batch Interval Time(Seconds) |
Request example
{
"rule": {
"name": "lux",
"description": "turn off",
"query": "select lux, bulb_id from \"myhome100/abc/+/abc\" where lux > -1"
},
"actions": {
"matchActionList": [
{
"relatedProduct": "REPUBLISH",
"relatedProductAction": {
"topic": "republish_a"
}
}
],
"errorAction": {
"relatedProduct": "REPUBLISH",
"relatedProductAction": {
"topic": "republish_a"
}
}
}
}
Response
Response body
{
"status": "string",
"body": {
"rule": {
"name": "string",
"description": "string",
"status": "string",
"query": "string",
"modifyTime": "localDateTime",
"registerTime": "localDateTime",
"filterTopic": "string"
},
"actions": {
"matchActionList": [
{
"type": "string",
"relatedProduct": "string",
"displayName": "string",
"modifyTime": "localDateTime",
"registerTime": "localDateTime",
"relatedProductAction": "json"
}
],
"errorAction": {
"type": "string",
"relatedProduct": "string",
"displayName": "string",
"modifyTime": "localDateTime",
"registerTime": "localDateTime",
"relatedProductAction": "json"
}
}
}
}
Category | Type | Description |
---|---|---|
status | string | Indicates whether response was successful |
body.rule.name | string | Name of the rule |
body.rule.description | string | Description of the rule |
body.rule.status | string | Rule status |
body.rule.query | string | rule query |
body.rule.modifyTime | localDateTime | Last modified date |
body.rule.registerTime | localDateTime | rule creation date |
body.rule.filterTopic | string | rule topic |
body.actions.matchActionList[].type | string | Action role (M: matchedAction, E: errorAction) |
body.actions.matchActionList[].relatedProduct | string | Action type |
body.actions.matchActionList[].displayName | string | Action primary name |
body.actions.matchActionList[].modifyTime | string | Action last modified date |
body.actions.matchActionList[].registerTime | string | Action creation date |
body.actions.matchActionList[].relatedProductAction | json | Action details |
body.actions.errorAction.type | string | Action role (M: matchedAction, E: errorAction) |
body.actions.errorAction.relatedProduct | string | Error action type |
body.actions.errorAction.displayName | string | Error action primary name |
body.actions.errorAction.modifyTime | string | Error action last modified date |
body.actions.errorAction.registerTime | string | Error action creation date |
body.actions.errorAction.relatedProductAction | json | Error action details |
Response example
{
"status": "SUCCESS",
"body": {
"rule": {
"name": "lux",
"description": "turn off",
"status": "ENABLE",
"query": "select lux, bulb_id from \"myhome100/abc/+/abc\" where lux > -1",
"modifyTime": "2020-09-27 12:52:08",
"registerTime": "2020-09-27 12:52:08",
"filterTopic": "myhome100/abc/+/abc"
},
"actions": {
"matchActionList": [
{
"type": "M",
"relatedProduct": "REPUBLISH",
"displayName": "republish_a",
"modifyTime": "2020-09-27 12:52:08",
"registerTime": "2020-09-27 12:52:08",
"relatedProductAction": {
"topic": "republish_a"
}
}
],
"errorAction": {
"type": "E",
"relatedProduct": "REPUBLISH",
"displayName": "republish_a",
"modifyTime": "2020-09-27 12:52:08",
"registerTime": "2020-09-27 12:52:08",
"relatedProductAction": {
"topic": "republish_a"
}
}
}
}
}
Was this article helpful?