打印

edgexfoundry notifications 通知

[复制链接]
560|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
keer_zu|  楼主 | 2020-12-16 13:31 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 keer_zu 于 2020-12-18 11:57 编辑

#申请原创# 1、 订阅通知
   
   要想获得通知,需要事先向edgexfoundry平台注册
   
   POST TO http://localhost:48060/api/v1/subscription
   (会保存在notifications 数据库subscription表中)


   {
     "slug": "sys-admin",
     "receiver": "System Administrator",
     "subscribedCategories": [
       "SECURITY",
       "HW_HEALTH",
       "SW_HEALTH"
     ],
     "subscribedLabels": [
       "Dell",
       "IoT",
       "test"
     ],
     "channels": [
       {
         "type": "REST",
         "url": "http://localhost:8080/receiveData/receiveData.do"
       },
       {
         "type": "EMAIL",
         "mailAddresses": [
           "15599633@qq.com"
       }
   }
   
   用postman工具提交如下:





subscribedCategories可取值为:SECURITY, HW_HEALTH, SW_HEALTH
   subscribedLabels可取值:metadata , export
   只要有一个满足,就执行通知,如下:
   subscriptions = subscriptionDAO
             .findBySubscribedCategoriesInIgnoreCaseOrSubscribedLabelsInIgnoreCase(category, labels);
   2、手工生成通知
   POST TO http://localhost:48060/api/v1/notification
   (会保存在notifications 数据库notifications表中)


   2.1 restful格式
   {
     "slug": "notice-test-003",
     "sender": "System Management",
     "category": "SECURITY",
     "severity": "NORMAL",
     "contentType": "application/json",
     "content": "{\"pushed\":0,\"device\":\"livingroomthermostat\",\"readings\":[{\"pushed\":0,\"name\":\"temperature\",\"value\":\"72\",\"device\":\"livingroomthermostat\",\"id\":\"5bac4a0b6862bdd543eb5821\",\"created\":1538017803672,\"modified\":1538017803672,\"origin\":1471806386919},{\"pushed\":0,\"name\":\"humidity\",\"value\":\"58\",\"device\":\"livingroomthermostat\",\"id\":\"5bac4a0b6862bdd543eb5822\",\"created\":1538017803676,\"modified\":1538017803676,\"origin\":1471806386919}],\"id\":\"5bac4a0b6862bdd543eb5823\",\"created\":1538017803679,\"modified\":1538017803679,\"origin\":1471806386919}" ,
     "labels": [
       "cool",
       "test"
     ]
   }
   postman工具提交:


通知结果:




2.2 普通风格的
   {
     "slug": "notice-test-004",
     "sender": "System Management",
     "category": "SECURITY",
     "severity": "NORMAL",
     "content": "fdfdfdfdfdfdfdd" ,
   "contentType": "text/plain",
     "labels": [
       "cool",
       "test"
     ]
   }

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:qq群:49734243 Email:zukeqiang@gmail.com

1353

主题

12440

帖子

53

粉丝