ルールの作成
- 印刷する
- PDF
ルールの作成
- 印刷する
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
概要
ルールを作成します。
リクエスト
リクエスト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}
リクエストボディー
{
"rule": {
"name": "string",
"description": "string",
"query": "string"
},
"actions": {
"matchActionList": [
{
"relatedProduct": "string",
"relatedProductAction": "json"
}
],
"errorAction": {
"relatedProduct": "string",
"relatedProductAction": "json"
}
}
}
項目 | 必須の有無 | タイプ | 制約事項 | 説明 |
---|---|---|---|---|
rule | Yes | ルール | ||
rule.name | Yes | string | 128字以内のアルファベットの大文字小文字、数字、-、_のみ許可 | ルール名 |
rule.description | No | string | 255字以内 | ルール説明 |
rule.query | Yes | string | ルールクエリのルール | ルールクエリ |
actions | Yes | アクション | ||
matchedActionList | Yes | ルールクエリを満たす場合に実行するアクション | ||
actions.matchedActionList[].relateProduct | Yes | string | 下段のrelatedProductを参考 | 連携するアクションの種類 |
actions.matchedActionList[].relateProductAction | Yes | json | 下段のrelatedProductActionを参考 | 連携するアクションの詳細 |
errorAction | No | エラーアクションを連携する場合、relatedProduct、relatedProductActionフィールド必須 | エラーアクション | |
errorAction.relateProduct | No | string | 下段のrelatedProductを参考 | 連携するアクションの種類 |
errorAction.relateProductAction | No | json | 下段のrelatedProductActionを参考 | 連携するアクションの詳細 |
relatedProduct
relatedProduct | アクション名 |
---|---|
REPUBLISH | 指定したトピックに再発行 |
CLOUD_FUNCTIONS | Cloud Functionsにデータを転送 |
relatedProductAction
REPUBLISH
{
"topic": "string"
}
項目 | 必須の有無 | タイプ | 制約事項 | 説明 |
---|---|---|---|---|
topic | Yes | string | トピック制限 | 再発行トピック |
CLOUD_FUNCTIONS
{
"name": "string",
"batchTime": "integer"
}
項目 | 必須の有無 | タイプ | 制約事項 | 説明 |
---|---|---|---|---|
name | Yes | string | Cloud Functionsに登録されたIoT trigger名前 | |
batchTime | No | integer | Min: 5, Max: 600 | Cloud Functions batch interval (Seconds) |
リクエスト例
{
"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"
}
}
}
}
レスポンス
レスポンスボディ
{
"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"
}
}
}
}
項目 | タイプ | 説明 |
---|---|---|
status | string | レスポンスの成否 |
body.rule.name | string | ルール名 |
body.rule.description | string | ルール説明 |
body.rule.status | string | ルールの状態 |
body.rule.query | string | ルールクエリ |
body.rule.modifyTime | localDateTime | 最終修正日 |
body.rule.registerTime | localDateTime | ルールの作成日 |
body.rule.filterTopic | string | ルールトピック |
body.actions.matchActionList[].type | string | アクションロール(M: matchedAction、E: errorAction) |
body.actions.matchActionList[].relatedProduct | string | アクションの種類 |
body.actions.matchActionList[].displayName | string | アクションの代表名 |
body.actions.matchActionList[].modifyTime | string | アクションの最終修正日 |
body.actions.matchActionList[].registerTime | string | アクションの作成日 |
body.actions.matchActionList[].relatedProductAction | json | アクションの詳細 |
body.actions.errorAction.type | string | アクションロール(M: matchedAction、E: errorAction) |
body.actions.errorAction.relatedProduct | string | エラーアクションの種類 |
body.actions.errorAction.displayName | string | エラーアクションの代表名 |
body.actions.errorAction.modifyTime | string | エラーアクションの最終修正日 |
body.actions.errorAction.registerTime | string | エラーアクションの作成日 |
body.actions.errorAction.relatedProductAction | json | エラーアクションの詳細 |
レスポンス例
{
"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",
"version": 1
}
}
],
"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",
"version": 1
}
}
}
}
}
この記事は役に立ちましたか?