创建转发目标配置
开发中POST
/api/v1/forwarding/targetMQTT Configuration
字段 | JSON 键名 | 类型 | 验证规则 | 描述 |
---|---|---|---|---|
Host | host | string | required, max=255 | 主机名/IP |
Port | port | int | required, min=1, max=65535 | 端口 |
Topic | topic | string | required, max=255 | 发布Topic |
QoS | qos | int | min=0, max=2 | QoS |
MQTTVersion | mqtt_version | string | required, max=10 | MQTT Version |
ClientID | client_id | *string | omitempty, max=255 | Clinet ID (可选) |
Username | username | *string | omitempty, max=128 | 用户名 (可选) |
Password | password | *string | omitempty, max=128 | 密码 (可选) |
URL Configuration
字段 | JSON 键名 | 类型 | 验证规则 | 描述 |
---|---|---|---|---|
URL | url | string | required, url | URL地址 |
EnableHMAC | enable_hmac | bool | - | 是否启用消息加密 |
Secret | secret | *string | required_if=EnableHMAC true, min=8, max=128, alphanum | Secret密钥 |
请求参数
Body 参数application/json
name
string
配置名称
forwarding_rule_id
string
转发规则ID
type
integer
目标类型
1-MQTT 2-URL
description
string
描述
config
object
配置详情
JSON对象,具体查看说明
示例
{
"name": "MQTT Broker Alpha",
"forwarding_rule_id": "rule123456",
"type": 1,
"description": "Primary MQTT broker for data forwarding",
"config": {}
}
示例代码
返回响应
成功(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
code
integer
必需
message
string
必需
data
object
必需
id
string
必需
name
string
必需
forwarding_rule_id
string
必需
type
integer
必需
description
string
必需
config
object
必需
created_at
string
必需
updated_at
string
必需
示例
{
"code": 200,
"message": "转发目标配置创建成功",
"data": {
"id": "62c158dc-0d3e-aeac-9bff-f53b3628da6f",
"name": "MQTT Broker Alpha",
"forwarding_rule_id": "9b9404fb-c1d5-645a-17f3-4bc83b580fbb",
"type": 1,
"description": "Primary MQTT broker for data forwarding",
"config": {
"broker": "mqtt.example.com",
"port": 1883,
"client_id": "forwarder_client_001",
"username": "mqtt_user",
"password": "mqtt_password",
"topic": "data/forwarded",
"qos": 1,
"retain": false,
"use_ssl": false
},
"created_at": "2024-10-18T16:45:39.406049+08:00",
"updated_at": "2024-10-18T16:45:39.406049+08:00"
}
}
最后修改时间: 2 个月前