4 division
This commit is contained in:
@@ -66,85 +66,33 @@
|
||||
| `discovery_clear` | 无 | `0` | - | 清空发现池 |
|
||||
| `list_rules` | 无 | `0` | - | 返回规则计数状态 |
|
||||
| `get_status` | 无 | `0` | - | 返回规则计数 + discovery/mapping 状态 |
|
||||
| `get_rules_status` | 无 | `0` | - | 规则 + 映射计数与 `mappingCatalogVersion` |
|
||||
| `get_discovery_status` | 无 | `0` | - | discovery 状态 JSON |
|
||||
| `list_discovery_samples` | `offset?`, `limit?`, `endpointHash?`, `protocol?` | `0` | - | 返回 `samples` 数组 |
|
||||
| `get_pipeline_status` | 无 | `0` | `5003` | PipelineEngine `status()`;不可用时 `pipeline_unavailable` |
|
||||
| `get_pipeline_counters` | 无 | `0` | `5003` | 计数 JSON |
|
||||
| `get_pipeline_config` | 无 | `0` | `5003` | 运行时配置 JSON |
|
||||
| `clear_pipeline_counters` | 无 | `0` | `5003` | 清零后返回计数 JSON |
|
||||
| `get_device_tree` | 无 | `0` | `5003` | 返回 `tree` |
|
||||
| `list_devices` | 无 | `0` | - | 返回 `devices` |
|
||||
| `get_device` | `deviceId` | `0` | `4044` | 单设备 JSON;未找到 `device_not_found` |
|
||||
| `patch_device_tree_node` | `id`, `patch`(字段同设备树节点) | `0` | `4045`/`5003` | 更新节点并协调;`node_not_found` |
|
||||
| `get_plugins` | 无 | `0` | - | 合并 protocol/framer/mapper 插件列表 |
|
||||
| `get_plugins_protocols` | 无 | `0` | - | `protocols` |
|
||||
| `get_plugins_mappers` | 无 | `0` | - | `mappers` |
|
||||
| `list_metadata` | 无 | `0` | `5004` | `metadatas` + `catalogVersion` |
|
||||
| `get_metadata` | `metadataId` | `0` | `4046`/`5004` | 单条 metadata;`metadata_not_found` |
|
||||
| `upsert_metadata` | `payload`(须含 `metadataId`) | `0` | `4005`/`5004` | 写回字典文件,返回新 `catalogVersion` |
|
||||
| `delete_metadata` | `metadataId` | `0` | `4046`/`5004` | 删除并递增 `catalogVersion` |
|
||||
| `list_profiles` | 无 | `0` | - | `profiles` + `catalogVersion` |
|
||||
| `list_profiles_for_device` | `deviceId` | `0` | - | 按设备过滤的 `profiles` |
|
||||
| 其他未知 action | - | - | `4040` | 未知动作 |
|
||||
|
||||
## 5) HTTP REST 路由表(RestApiRoutes)
|
||||
## 5) 控制面入口(无 HTTP)
|
||||
|
||||
### 5.1 通用路由
|
||||
`softbus_daemon` 不再内置 HTTP 服务。浏览器侧请使用 **`softbus_orchestrator_py`**(`python -m softbus_orchestrator`):提供治理 REST、`/v1/command` 与 `/api/v1/*` 到 D-Bus 的 HTTP 兼容层,以及 DAG ingress。运维能力在进程内仍通过 **`executeCommand`** 转发到 `com.softbus.Daemon`。
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
|---|---|---|
|
||||
| `GET` | `/health` | 健康检查,返回 `{"ok": true}` |
|
||||
| `GET` | `/v1/status` | 透传 `get_status` 的状态响应 |
|
||||
| `POST` | `/v1/command` | 统一命令入口(请求体为 executeCommand JSON) |
|
||||
|
||||
### 5.2 设备树 / 设备路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `GET` | `/api/v1/device-tree` | 无 | 返回当前设备树快照 |
|
||||
| `GET` | `/api/v1/devices` | 无 | 返回当前运行态设备列表 |
|
||||
| `GET` | `/api/v1/devices/{id}` | path: `id(int)` | 返回指定运行态设备详情 |
|
||||
| `PATCH` | `/api/v1/device-tree/nodes/{id}` | body: 任意可变节点字段子集 | 部分更新设备树节点;当前至少保护 `id`、`params.stableKey`、`params.online`、`params.lastSeenTs` |
|
||||
|
||||
### 5.3 规则管理路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `GET` | `/api/v1/rules/status` | 无 | 返回动态规则计数状态 |
|
||||
| `POST` | `/api/v1/rules/filter` | body: `id`, `endpointHash?`, `deviceId?`, `stableKey?`, `condition?` | 新增过滤规则 |
|
||||
| `DELETE` | `/api/v1/rules/filter/{id}` | path: `id` | 删除过滤规则 |
|
||||
| `POST` | `/api/v1/rules/transform` | body: `id`, `endpointHash?`, `deviceId?`, `stableKey?`, `scale?`, `offset?`, `unit?` | 新增转换规则 |
|
||||
| `DELETE` | `/api/v1/rules/transform/{id}` | path: `id` | 删除转换规则 |
|
||||
|
||||
- 说明:
|
||||
- `transform` 规则已经在 `PipelineEngine::applyTransformAndEnrich(...)` 中生效。
|
||||
- `filter` 路由当前主要提供“注册表管理”能力;动态 filter 规则尚未真正接入 `PipelineEngine::stage3Filter(...)` 的执行链路。
|
||||
|
||||
### 5.4 Pipeline 路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `GET` | `/api/v1/pipeline/status` | 无 | 返回 pipeline 运行状态、session 数量、队列容量、插件摘要与 counters |
|
||||
| `GET` | `/api/v1/pipeline/counters` | 无 | 返回 `in/out/drop/error/mergeDrop` 计数器快照 |
|
||||
| `GET` | `/api/v1/pipeline/config` | 无 | 返回当前运行时配置快照 |
|
||||
|
||||
- 说明:`/v1/status` 仍然是 control-plane 摘要(规则 + discovery + mapping),不等同于 `/api/v1/pipeline/status`。
|
||||
|
||||
### 5.5 插件 / 协议能力路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `GET` | `/api/v1/plugins` | 无 | 返回 parser / framer / mapper 三类逻辑插件的统一列表 |
|
||||
| `GET` | `/api/v1/plugins/protocols` | 无 | 返回按协议聚合后的能力快照(parser/framer/mapper pluginId) |
|
||||
| `GET` | `/api/v1/plugins/mappers` | 无 | 返回 mapper 插件列表 |
|
||||
|
||||
### 5.6 Metadata / Profile 路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `GET` | `/api/v1/metadata` | 无 | 返回 `data`(字典数组)与可选 `catalogVersion`(根级字段) |
|
||||
| `GET` | `/api/v1/metadata/{metadataId}` | path: `metadataId` | 返回指定 metadata 详情(含可选 `catalogVersion`) |
|
||||
| `GET` | `/api/v1/profiles` | 无 | 返回 `data` 与可选 `catalogVersion` |
|
||||
| `GET` | `/api/v1/profiles/{deviceId}` | path: `deviceId` | 返回指定 `deviceId` 关联的全部 profile(含可选 `catalogVersion`) |
|
||||
|
||||
### 5.7 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.8 Mapping 路由
|
||||
|
||||
| 方法 | 路径 | 请求参数 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `POST` | `/api/v1/mapping/bind` | body: `compositeKey`, `domPath`, `scale?`, `offset?`, `unit?`, `metadataId?`, `pointId?`, `catalogVersion?`, `updatedBy?` | 绑定或更新映射规则并写入 `runtime_mappings.json` |
|
||||
| `POST` | `/api/v1/mapping/unbind` | body: `compositeKey` | 删除映射规则并持久化 |
|
||||
| `GET` | `/api/v1/mapping/list` | 无 | 返回 `items` 与 `mappingCatalogVersion` |
|
||||
治理 **`graph_catalog.json`**:`POST /api/v1/graphs` 按 **`graphId` 幂等 upsert**(合并字段,未传 `versions` 时保留已有版本);**拓扑与 `nodes`/`edges`** 应通过 **`POST /api/v1/graphs/{graph_id}/versions`** 追加版本体;若 `graph_id` 尚不存在,该接口会**自动创建**图壳再写入版本。**Pipeline 与 DOM 的可视化绑定** 若需统一图模型,需在产品与 daemon 侧另行定义配置 schema(当前无单一 REST)。
|
||||
|
||||
## 6) 通用错误码约定(当前实现)
|
||||
|
||||
@@ -161,14 +109,17 @@
|
||||
| `4042` | `transform_rule_not_found` | 删除转换规则时未找到 |
|
||||
| `4043` | `mapping_rule_not_found` | 删除映射规则时未找到 |
|
||||
| `5002` | `persist_mappings_failed` | 映射规则内存更新成功但写入 `runtime_mappings.json` 失败 |
|
||||
| `5003` | `pipeline_unavailable` / `device_tree_unavailable` | Pipeline 或设备树模型未就绪 |
|
||||
| `5004` | `metadata_*` | 元数据字典读写/解析/保存失败 |
|
||||
| `4005` | `invalid_metadata` | `upsert_metadata` 缺少 `metadataId` |
|
||||
| `4044` | `device_not_found` | `get_device` 未找到 |
|
||||
| `4045` | `node_not_found` | `patch_device_tree_node` 未找到节点 |
|
||||
| `4046` | `metadata_not_found` | `get_metadata` / `delete_metadata` 未找到 |
|
||||
|
||||
## 7) 维护建议
|
||||
|
||||
- 新增 action 时,同时更新:
|
||||
- `CommandDispatcher::dispatch(...)`
|
||||
- 本文档第 4 节 action 表
|
||||
- 新增 REST 路由时,同时更新:
|
||||
- `RestApiRoutes.cpp`
|
||||
- 本文档第 5 节路由表
|
||||
- 若扩展返回结构,保持 `code/message/data` 三元组不变,避免客户端兼容性问题。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user