所有文档

          物接入 IoT Hub

          创建带TSDB格式的规则

          方法 API 说明
          POST /v3/iot/rules/device/{deviceName}/format 创建带TSDB格式的转存规则

          请求参数

          DeviceFormatRuleRequest

          返回参数

          DeviceFormatRuleResponse

          请求示例

          POST /v3/iot/rules/device/myDeviceName/format HTTP/1.1
          Host: iotdm.gz.baidubce.com
          Authorization:{authorization}
          Content-Type: application/json; charset=utf-8
           
          {
              "name": "device xxxx to TSDB yyyy",
              "sources": [{
                  "description": "This is condition 1",
                  "name": "name",
                  "type": "string",
                  "condition": "<>",
                  "value": "aaa"
              }, {
                  "description": "",  // 可以为空
                  "name": "temperature",
                  "type": "number",
                  "condition": ">=",
                  "value": "20"
              }, {
                  "description": "This is condition 3",
                  "name": "speed",
                  "type": "number",
                  "condition": ">",
                  "value": "0"
              }],
              "destinations": [
                  {
                      "value": "test.tsdb.iot.gz.baidubce.com",
                      "kind": "TSDB"
                  }
              ],
              "format" : {
                  "mode" : "field",
                  "metric" : "newMetricName",
                  "tags" : {
                      "tag1" : "aaa"
                  }
              }
          }

          返回示例

          HTTP/1.1 200 OK
          Content-Type: application/json; charset=utf-8
          x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
           
          {
              "id": "63d92c1de2bd46e0b257c6df67b4a7e9",
              "deviceName": "myDeviceName",
              "name": "device xxxx to TSDB yyyy",
              "sources": [{
                  "description": "This is condition 1"
                  "name": "name",
                  "type": "string",
                  "displayName": "名字",
                  "unit": "count",
                  "defaultValue": "0",
                  "condition": "<>",
                  "value": "aaa",
                  "lastSaveTime": 0
              }, {
                  "description": "This is condition 2",
                  "name": "temperature",
                  "type": "number",
                  "displayName": "数量",
                  "unit": "piece",
                  "defaultValue": "1",
                  "condition": ">=",
                  "value": "20",
                  "lastSaveTime": 1494904250
              }, {
                  "description": "This is condition 3",
                  "name": "speed",
                  "type": "number",
                  "displayName": "速度",
                  "unit": "km/s",
                  "defaultValue": "60",
                  "condition": ">",
                  "value": "0",
                  "lastSaveTime": 1494904250
              }, {  // 这个规则是来自Schema里的新的属性,用户在之前的规则建立的时候并没有创建对应的规则。 如果创建的规则在Schema里没有对应的属性,则那条规则不会显示
                  "description": "",
                  "name": "temp",
                  "type": "number",
                  "displayName": "温度",
                  "unit": "c",
                  "defaultValue": "36",
                  "condition": "",
                  "value": "",
                  "lastSaveTime": 0
           
              }],
              "destinations": [
                  {
                      "uuid": "6653da99bf9a4e35ba4f997e000a699f",
                      "value": "test.tsdb.iot.gz.baidubce.com",
                      "kind": "TSDB"
                  }
              ],
              "format" : {
                  "mode" : "field",
                  "metric" : "newMetricName",
                  "tags" : {
                      "tag1" : "aaa"
                  }
              },
              "enable": true,
              "createTime": 1494904250,
              "updateTime": 1494904250
          }
          上一篇
          启用一条规则
          下一篇
          获取带TSDB格式的规则详情