iot/docs/endpoint.md
2023-08-07 17:29:48 +08:00

1.4 KiB
Raw Permalink Blame History

Endpoint管理

获取全部的Endpoint

method: GET
url: /endpoint/all

返回数据: 
[
    {
        "name": "名称",
        "title": "中电集团"
        "matcher": "匹配的正则表达式",
        "protocol": "http|https|websocket|mqtt|kafka",
        "config": "参考config格式说明" 
    }
]


创建Endpoint

method: POST
url: /endpoint/create
body: (content-type: application/json)
    {"name": $name, "matcher": $matcher, "title": $title, "protocol": "http|https|websocket|kafka|mqtt", "config": "参考config格式说明"}

说明:
    name是唯一的不同的终端名称代表不同的接受端

删除Endpoint

method: POST
url: /endpoint/delete
body: (content-type: application/json)
    {"name": $name}

config格式说明


    http|https
        {"url": "http(s)://xx.com"}

    websocket
        {"url": "ws://xx.com/ws"}

    kafka:
        {"bootstrap_server": ["localhost:9092"], "topic": "test", "username": "test", "password": "password1234"}
    
    mysql:
        {"host": "localhost", port: 3306, "username": "test", "password": "test1234", "database": "iot", "table_name": "north_data"}
    
    mqtt:
        {"host": "localhost", port: 1883, "username": "test", "password": "test1234", "topic": "CET/NX/${location_code}/upload", "qos": 0|1|2}

    topic中支持预定义变量: ${location_code}; 发送的时候会替换成对应的点位编码