endpointhash 1.0
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
# softbus_daemon API 接口表
|
||||
|
||||
本文档汇总 `src/api/ipc_dbus` 当前对外接口,分为:
|
||||
本文档汇总 `src/api` 当前对外接口,分为:
|
||||
- D-Bus 直接方法
|
||||
- `executeCommand` JSON 命令接口
|
||||
- HTTP REST 接口
|
||||
|
||||
## 1) D-Bus 服务基础信息
|
||||
|
||||
@@ -53,15 +54,49 @@
|
||||
|
||||
| action | params 关键字段 | 成功 code | 失败 code | 说明 |
|
||||
|---|---|---:|---:|---|
|
||||
| `add_filter` | `id`, `endpoint?`, `deviceId?`, `stableKey?`, `condition?` | `0` | `4001` | 添加过滤规则 |
|
||||
| `add_filter` | `id`, `endpointHash?`, `deviceId?`, `stableKey?`, `condition?` | `0` | `4001` | 添加过滤规则 |
|
||||
| `remove_filter` | `id` | `0` | `4041` | 删除过滤规则 |
|
||||
| `add_transform_rule` | `id`, `endpoint?`, `deviceId?`, `stableKey?`, `scale?`, `offset?`, `unit?` | `0` | `4002` | 添加转换规则 |
|
||||
| `add_transform_rule` | `id`, `endpointHash?`, `deviceId?`, `stableKey?`, `scale?`, `offset?`, `unit?` | `0` | `4002` | 添加转换规则 |
|
||||
| `remove_transform_rule` | `id` | `0` | `4042` | 删除转换规则 |
|
||||
| `add_mapping_rule` | `compositeKey`, `domPath`, `scale?`, `offset?`, `unit?` | `0` | `4004` | 新增/更新映射规则 |
|
||||
| `remove_mapping_rule` | `compositeKey` | `0` | `4043` | 删除映射规则 |
|
||||
| `list_mapping_rules` | 无 | `0` | - | 返回映射规则列表 |
|
||||
| `discovery_start` | `ttlMs?` | `0` | - | 开启嗅探模式 |
|
||||
| `discovery_stop` | 无 | `0` | - | 关闭嗅探模式 |
|
||||
| `discovery_clear` | 无 | `0` | - | 清空发现池 |
|
||||
| `list_rules` | 无 | `0` | - | 返回规则计数状态 |
|
||||
| `get_status` | 无 | `0` | - | 返回规则计数状态 |
|
||||
| `get_status` | 无 | `0` | - | 返回规则计数 + discovery/mapping 状态 |
|
||||
| 其他未知 action | - | - | `4040` | 未知动作 |
|
||||
|
||||
## 5) 通用错误码约定(当前实现)
|
||||
## 5) HTTP REST 路由表(RestApiRoutes)
|
||||
|
||||
### 5.1 通用路由
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
|---|---|---|
|
||||
| `GET` | `/health` | 健康检查,返回 `{"ok": true}` |
|
||||
| `GET` | `/v1/status` | 透传 `get_status` 的状态响应 |
|
||||
| `POST` | `/v1/command` | 统一命令入口(请求体为 executeCommand JSON) |
|
||||
|
||||
### 5.2 Discovery 路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `POST` | `/api/v1/discovery/start` | body: `ttlMs?` | 开启嗅探;可设置自动关闭 TTL |
|
||||
| `POST` | `/api/v1/discovery/stop` | 无 | 关闭嗅探 |
|
||||
| `GET` | `/api/v1/discovery/status` | 无 | 获取发现池运行状态 |
|
||||
| `POST` | `/api/v1/discovery/clear` | 无 | 清空发现池样本 |
|
||||
| `GET` | `/api/v1/discovery/samples` | query: `offset?`, `limit?`, `endpointHash?`, `protocol?` | 拉取样本(按更新时间倒序,且过滤已映射 key) |
|
||||
|
||||
### 5.3 Mapping 路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `POST` | `/api/v1/mapping/bind` | body: `compositeKey`, `domPath`, `scale?`, `offset?`, `unit?` | 绑定或更新映射规则 |
|
||||
| `POST` | `/api/v1/mapping/unbind` | body: `compositeKey` | 删除映射规则 |
|
||||
| `GET` | `/api/v1/mapping/list` | 无 | 列出当前映射规则 |
|
||||
|
||||
## 6) 通用错误码约定(当前实现)
|
||||
|
||||
| code | message | 说明 |
|
||||
|---:|---|---|
|
||||
@@ -70,14 +105,19 @@
|
||||
| `4001` | `invalid_filter_rule` | 过滤规则参数非法 |
|
||||
| `4002` | `invalid_transform_rule` | 转换规则参数非法 |
|
||||
| `4003` | `invalid_action` | action 为空或分发器不可用 |
|
||||
| `4004` | `invalid_mapping_rule` | 映射规则参数非法 |
|
||||
| `4040` | `unknown_action` | action 未注册 |
|
||||
| `4041` | `filter_not_found` | 删除过滤规则时未找到 |
|
||||
| `4042` | `transform_rule_not_found` | 删除转换规则时未找到 |
|
||||
| `4043` | `mapping_rule_not_found` | 删除映射规则时未找到 |
|
||||
|
||||
## 6) 维护建议
|
||||
## 7) 维护建议
|
||||
|
||||
- 新增 action 时,同时更新:
|
||||
- `CommandDispatcher::dispatch(...)`
|
||||
- 本文档第 4 节 action 表
|
||||
- 新增 REST 路由时,同时更新:
|
||||
- `RestApiRoutes.cpp`
|
||||
- 本文档第 5 节路由表
|
||||
- 若扩展返回结构,保持 `code/message/data` 三元组不变,避免客户端兼容性问题。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user