Files
notes/work/移动杭研/业务梳理/IBS+/网关 API 文档.md
T
2026-03-01 01:43:46 +08:00

665 lines
16 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
【金山文档 | WPS云文档】 网关 API 文档
https://kdocs.cn/l/cboRgHwJiGUI
# 网关实例 API 文档
## 1. 分页查询网关实例列表
接口地址: `GET /gateway/instance/list`
请求参数:
`?pageNum=1&pageSize=10&ip=127&port=8080&healthStatus=false&syncStatus=false&enabled=false`
- `pageNum` (可选):页码,默认1
- `pageSize` (可选):每页大小,默认10
- `ip`(可选):网关实例IP,支持模糊
- `port`(可选):网关实例端口
- `healthStatus`(可选):健康状态 true 和 false
- `syncStatus`(可选):配置同步状态 true 和 false
- `enabled`(可选):是否启用 true 和 false
响应示例:
```json
{
"total": 1,
"rows": [
{
"id": 1,
"ip": "127.0.0.1",
"port": "8080",
"healthStatus": false,
"healthCheckTime": "2025-07-29 15:36:29",
"syncStatus": false,
"syncTime": null,
"enabled": false
}
],
"code": 200,
"msg": "查询成功"
}
```
## 2. 配置同步接口
接口地址
`POST /gateway/instance/sync/{instanceId}`
响应示例
```json
{
"id": 10001,
"status": true,
"time": "2024-05-18 14:33:55"
}
```
## 3. 状态刷新接口
接口地址
`GET /gateway/instance/refresh/{instanceId}`
响应示例
```json
{
"id": 10001,
"status": true,
"time": "2024-05-18 14:33:55"
}
```
## 4. 配置查询接口
接口地址
`GET /gateway/instance/config/detail/{instanceId}`
响应示例
```
待补充
```
# 网关服务实例管理 API 文档
## 1. 分页查询网关服务实例
接口地址: `GET /gateway/service-instance/list`
请求参数:
- `name` (可选): 服务实例名称,支持模糊搜索
- `mode` (可选): 转发模式,0-负载均衡,1-静态地址
- `pageNum` (可选): 页码,默认1
- `pageSize` (可选): 每页大小,默认10
响应示例:
```json
{
"total": 2,
"rows": [
{
"serviceId": 2,
"name": "mock-uri",
"mode": 0,
"uris": [
{
"id": 2,
"serviceId": 2,
"uri": "https://mock.p.cdn.10086.cn",
"enabled": 1
}
]
},
{
"serviceId": 1,
"name": "portal-dev",
"mode": 0,
"uris": [
{
"id": 1,
"serviceId": 1,
"uri": "http://127.0.0.1:8080",
"enabled": 1
}
]
}
],
"code": 200,
"msg": "查询成功"
}
```
## 2. 批量更新网关服务实例
接口地址: `POST /gateway/service-instance/batch-update`
请求体示例:
```json
{
"deleteServiceIds": [
// 3,
5
],
"addServiceInstances": [
// {
// "name": "new-service5",
// "mode": 0,
// "uris": [
// {
// "uri": "http://new-service.com",
// "enabled": 1
// }
// ]
// }
],
"updateServiceInstances": [
{
"serviceId": 3,
"name": "updated-portal-dev",
"mode": 1,
"uris": [
{
"uri": "http://updated.127.0.0.1:8080",
"enabled": 1
},
{
"uri": "http://backup.127.0.0.1:8080",
"enabled": 0
}
]
}
]
}
```
响应示例:
```json
{
"code": 200,
"msg": "批量更新服务实例配置成功",
"data": null
}
{
"code": 400,
"msg": "批量更新服务实例配置失败: 服务实例名称已存在: new-service",
"data": null
}
{
"code": 200,
"msg": "批量更新服务实例配置成功",
"data": null
}
```
## 3. 获取服务实例ID和名称对应关系
接口地址: `GET /gateway/service-instance/id-name-map`
响应示例:
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"1": "portal-dev",
"2": "mock-uri",
"3": "updated-portal-dev"
}
}
```
# 网关路由配置管理 API 文档
## 1. 分页查询网关路由配置
接口地址:`GET /gateway/config/list`
请求参数:
- `routeName` (可选): 路由名称,支持模糊搜索
- `serviceId` (可选): 服务实例ID
- `enabled` (可选): 是否启用,true-启用,false-禁用
- `pageNum` (可选): 页码,默认1
- `pageSize` (可选): 每页大小,默认10
**响应示例:**
```json
{
"code": 200,
"msg": "查询成功",
"total": 2,
"rows": [
{
"routeId": 1,
"routeName": "portal-api",
"serviceId": 1,
"serviceName": "portal-dev",
"remark": "门户API路由",
"order": 0,
"enabled": true,
"paths": ["/api/portal/**", "/portal/**"],
"methods": ["GET", "POST"],
"requestParams": [
{"version": "v1"},
{"source": "web"}
],
"createTime": "2024-01-15 10:30:00",
"updateTime": "2024-01-15 10:30:00"
},
{
"routeId": 2,
"routeName": "user-service",
"serviceId": 2,
"serviceName": "mock-uri",
"remark": "用户服务路由",
"order": 1,
"enabled": true,
"paths": ["/api/user/**"],
"methods": ["GET", "POST", "PUT", "DELETE"],
"requestParams": [],
"createTime": "2024-01-15 11:00:00",
"updateTime": "2024-01-15 11:00:00"
}
]
}
```
## 2. 批量更新网关路由配置
接口地址:`POST /gateway/config/batch-update`
请求体示例:
```json
{
"deleteRouteIds": [
3
],
"addRoutes": [
{
"routeName": "new-api-route5",
"serviceId": 3,
"remark": "新增API路由",
"priority": 0,
"enabled": true,
"paths": [
{
"path": "/api/new/**"
}
],
"methods": [
{
"method": "GET"
},
{
"method": "POST"
}
],
"params": [
{
"paramName": "version",
"paramValue": "v2"
}
]
}
],
"updateRoutes": [
{
"routeId": 4,
"routeName": "updated-portal-api4",
"serviceId": 2,
"remark": "更新后的门户API路由",
"priority": 1,
"enabled": false,
"paths": [
{
"path": "/api/portal/v2/**"
},
{
"path": "/portal/new/**"
}
],
"methods": [
{
"method": "GET"
},
{
"method": "POST"
},
{
"method": "PUT"
}
],
"params": [
{
"paramName": "version",
"paramValue": "v2"
},
{
"paramName": "client",
"paramValue": "web"
}
]
}
]
}
```
响应示例:
```json
{
"code": 200,
"msg": "批量更新路由配置成功",
"data": null
}
```
# 获取网关转发记录
## 1. 分页查询网关转发记录列表
接口地址:`GET /gateway/record/list`
请求参数:
- `pageNum` (可选):页码,默认1
- `pageSize` (可选):每页大小,默认10
- `uuid` (可选):请求UUID
- `requestUrl` (可选):接口路径,支持模糊搜索
- `method` (可选):请求方法,如GET、POST等
- `targetEndpoint` (可选):目的地址
- `httpCode` (可选):请求响应码
- `traceId` (可选):链路追踪ID
- `gatewayEndpoint` (可选):网关地址
- `routeId` (可选):请求匹配的路由ID
- `routeName` (可选):路由名称
- `requestTimeStart` (可选):请求开始时间,格式:yyyy-MM-dd HH:mm:ss
- `requestTimeEnd` (可选):请求结束时间,格式:yyyy-MM-dd HH:mm:ss
- `minCostTime` (可选):最小耗时(ms)
- `maxCostTime` (可选):最大耗时(ms)
响应示例:
```json
{
"total": 2,
"rows": [
{
"recordId": 91041,
"uuid": "4c091ee8-8fc6-4796-8b4e-34f3cc2bda15",
"requestTime": "2025-07-29 15:15:03",
"requestUrl": "/api/v1/payment/callback",
"method": "GET",
"targetEndpoint": "192.168.1.102:8080",
"httpCode": 400,
"traceId": "4c091ee88fc64796",
"gatewayEndpoint": "192.168.208.18:8087",
"routeId": 2,
"routeName": "IBS->BBoss",
"costTime": 67
},
{
"recordId": 70130,
"uuid": "925d255e-26b0-45a9-9944-3e37b195f38c",
"requestTime": "2025-07-29 15:12:42",
"requestUrl": "/api/v1/user/logout",
"method": "PUT",
"targetEndpoint": "192.168.1.100:8080",
"httpCode": 200,
"traceId": "925d255e26b045a9",
"gatewayEndpoint": "192.168.208.16:8087",
"routeId": 2,
"routeName": "IBS->BBoss",
"costTime": 394
}
],
"code": 200,
"msg": "查询成功"
}
```
## 2. 根据记录ID获取详情信息
接口地址:`GET /gateway/record/detail/{recordId}`
路径参数:
- `recordId`:记录ID
响应示例:
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"requestParam": "{aaa=[111, 222], bbb=[333]}",
"requestBody": "{\r\n \"content\": {\r\n \"ECID\": \"ECID1695801457\",\r\n \"OrderType\": \"2\", // 1:试用申请 2:业务开通 3:试用变更 4:试用暂停 5:试用恢复 6:业务注销 7:试用删除\r\n \"ProductID\": \"AA11131040\",\r\n \"ProvID\": \"000\", // 主办省代码\r\n \"TrialNo\": \"TEST20241111001\",\r\n // \"Domain\": [\r\n // \"www.zphconflict10241513.com.99.cdnhwcqir15.com\",\r\n // ],\r\n \"BusiType\": \"1\", // 1、点播下载网页类; 4、直播类; 试用单/开通单必传\r\n // \"ECNumber\": \"13810151511\",\r\n // \"ECMail\": \"123@123.com\",\r\n // \"InfoSecurityTable\": \"info_security_file2.xlsx\"\r\n }\r\n}",
"requestHeaders": "[Content-Type:\"application/json\", User-Agent:\"PostmanRuntime/7.29.2\", Accept:\"*/*\", Postman-Token:\"cdc4bd2d-e7bc-481d-a390-02e848131c24\", Host:\"127.0.0.1:8087\", Accept-Encoding:\"gzip, deflate, br\", Connection:\"keep-alive\", Content-Length:\"705\"]",
"responseBody": "{\n\t\"providePartyID\":\"CDNP9950\",\n\t\"response\":{\n\t\t\"rspCode\":\"00000\",\n\t\t\"rspDesc\":\"成功\"\n\t},\n\t\"result\":\"{\\\"ResCode\\\":\\\"00\\\",\\\"ResDetail\\\":\\\"成功\\\"}\",\n\t\"transIDH\":\"1612\",\n\t\"transIDHTime\":\"20250724172043\"\n}",
"responseHeaders": "[Access-Control-Allow-Methods:\"POST, GET, OPTIONS\", Access-Control-Max-Age:\"3600\", Access-Control-Allow-Headers:\"content-type,x-requested-with,Authorization, x-request-with,x-ui-request,lang,x-csrf-token,csrf-token\", Access-Control-Allow-Credentials:\"true\", X-Content-Type-Options:\"nosniff\", X-XSS-Protection:\"1; mode=block\", Cache-Control:\"no-cache, no-store, max-age=0, must-revalidate\", Pragma:\"no-cache\", Expires:\"0\", Content-Type:\"application/json\", Content-Length:\"205\", Date:\"Thu, 24 Jul 2025 09:20:43 GMT\"]"
}
}
```
错误响应示例:
```json
{
"code": 500,
"msg": "记录不存在或详情信息为空",
"data": null
}
```
## 3. 获取数据看板统计信息
接口地址:`GET /gateway/record/dashboard`
请求参数:
- `startTime` (必填):开始时间,格式:yyyy-MM-dd
- `endTime` (必填):结束时间,格式:yyyy-MM-dd
请求示例:
`?startTime=2025-07-24&endTime=2025-07-31`
响应示例:
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"totalRequestCount": 137116,
"requestCount": 0,
"requestCountChange": -418,
"requestCountRatio": -100.00,
"successRate": 0,
"successRateChange": -58.85,
"successRateRatio": -100.00,
"avgCostTime": 0.00,
"avgCostTimeChange": -3043.73,
"avgCostTimeRatio": -100.00
}
}
```
## 4. 获取曲线图数据
接口地址:`POST /gateway/record/chart`
请求体示例:
```json
{
"startTime": "2025-01-01",
"endTime": "2025-07-31",
"timeGranularity": "1MONTH",
"requestUrl": "/api/v2/sync/BBOSS/PreCheckServ",
"method": "GET",
"targetEndpoint": "127.0.0.1:8080",
"httpCode": 200,
"gatewayEndpoint": "192.168.208.16:8087",
"minCostTime": 2000,
"maxCostTime": 5000,
"routeId": 1
}
```
请求参数说明:
- `startTime` (必填):查询开始时间,格式:yyyy-MM-dd
- `endTime` (必填):查询结束时间,格式:yyyy-MM-dd
- `timeGranularity` (必填):时间粒度,可选值:
- `5MIN`5分钟
- `1HOUR`1小时
- `1DAY`1天
- `1WEEK`1周
- `1MONTH`1月
- `requestUrl` (可选):接口路径过滤条件
- `method` (可选):请求方法过滤条件
- `targetEndpoint` (可选):目的地址过滤条件
- `httpCode` (可选):请求响应码过滤条件
- `gatewayEndpoint` (可选):网关地址过滤条件
- `minCostTime` (可选):最小耗时(ms)过滤条件
- `maxCostTime` (可选):最大耗时(ms)过滤条件
- `routeId` (可选):路由ID过滤条件
响应示例:
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"dataPoints": [
{
"timePoint": "2025-02-01 00:00:00",
"count2xx": 2,
"count4xx": 0,
"count5xx": 0,
"count3xx": 0,
"avgCostTime": 3557.00
},
{
"timePoint": "2025-04-01 00:00:00",
"count2xx": 3,
"count4xx": 0,
"count5xx": 0,
"count3xx": 0,
"avgCostTime": 3791.33
},
{
"timePoint": "2025-05-01 00:00:00",
"count2xx": 1,
"count4xx": 0,
"count5xx": 0,
"count3xx": 0,
"avgCostTime": 4858.00
},
{
"timePoint": "2025-06-01 00:00:00",
"count2xx": 1,
"count4xx": 0,
"count5xx": 0,
"count3xx": 0,
"avgCostTime": 3668.00
}
]
}
}
```
响应字段说明:
- `timePoint`:时间点(时间轴X轴)
- `count2xx`2xx状态码请求次数
- `count3xx`3xx状态码请求次数
- `count4xx`4xx状态码请求次数
- `count5xx`5xx状态码请求次数
- `avgCostTime`:平均耗时(ms),保留2位小数
## 5. 获取去重的请求URL列表
接口地址:`GET /gateway/record/request-urls`
请求参数:无
响应示例:
```json
{
"code": 200,
"msg": "操作成功",
"data": [
"/api/v1/order/cancel",
"/api/v1/order/create",
"/api/v1/order/query",
"/api/v1/order/update",
"/api/v1/payment/callback",
"/api/v1/payment/create",
"/api/v1/payment/query",
"/api/v1/product/detail",
"/api/v1/product/list",
"/api/v1/product/search",
"/api/v1/system/config",
"/api/v1/system/health",
"/api/v1/system/monitor",
"/api/v1/user/login",
"/api/v1/user/logout",
"/api/v1/user/profile",
"/api/v2/sync/BBOSS/PauseResultServ",
"/api/v2/sync/BBOSS/PreCheckServ",
"/api/v2/sync/BBOSS/QueryServ",
"/api/v2/sync/BBOSS/UpdateServ"
]
}
```
响应字段说明:
- `data`:去重后的请求URL列表
## 6. 获取去重的目标端点列表
接口地址:`GET /gateway/record/target-endpoints`
请求参数:无
响应示例:
```json
{
"code": 200,
"msg": "操作成功",
"data": [
"127.0.0.1:8080",
"127.0.0.1:8081",
"127.0.0.1:8082",
"192.168.1.100:8080",
"192.168.1.101:8080",
"192.168.1.102:8080",
"mock.p.cdn.10086.cn:443"
]
}
```
响应字段说明:
- `data`:去重后的目标端点列表