udeServer.api 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. syntax = "v1"
  2. type Request {
  3. Name string `path:"name,options=you|me"`
  4. }
  5. type Response {
  6. Message string `json:"message"`
  7. }
  8. type DbPingResponse {
  9. Ok bool `json:"ok"`
  10. Version string `json:"version"`
  11. Database string `json:"database"`
  12. }
  13. type DeleteResp {
  14. Ok bool `json:"ok"`
  15. // 联动卸载失败等非致命警告(删除本身已成功),前端弹黄色警告;
  16. // 目录/密钥删除等其他共用本结构体的接口不填此字段。
  17. UnmountWarning string `json:"unmountWarning,optional"`
  18. }
  19. type CreateDirectoryReq {
  20. Id int64 `json:"id,optional"`
  21. ServiceId int64 `json:"serviceId,optional"`
  22. Directory string `json:"directory,optional"`
  23. }
  24. type UpdateDirectoryReq {
  25. Id int64 `path:"id"`
  26. ServiceId int64 `json:"serviceId,optional"`
  27. Directory string `json:"directory,optional"`
  28. }
  29. type DirectoryIdReq {
  30. Id int64 `path:"id"`
  31. }
  32. type DirectoryResp {
  33. Id int64 `json:"id"`
  34. ServiceId int64 `json:"serviceId"`
  35. Directory string `json:"directory"`
  36. }
  37. type ListDirectoryReq {
  38. Page int64 `form:"page,optional"`
  39. PageSize int64 `form:"pageSize,optional"`
  40. }
  41. type DirectoryListResp {
  42. List []DirectoryResp `json:"list"`
  43. Total int64 `json:"total"`
  44. }
  45. type CreateKeyReq {
  46. Name string `json:"name"`
  47. }
  48. type UpdateKeyReq {
  49. Id int64 `json:"id"`
  50. Status string `json:"status"`
  51. }
  52. type KeyIdReq {
  53. Id int64 `json:"id"`
  54. }
  55. type KeyResp {
  56. Id int64 `json:"id"`
  57. Iden string `json:"iden"`
  58. Name string `json:"name"`
  59. Content string `json:"content"`
  60. Status string `json:"status"`
  61. CreateAt string `json:"createAt"`
  62. }
  63. type ListKeysReq {
  64. Page int64 `json:"page,optional"`
  65. PageSize int64 `json:"pageSize,optional"`
  66. Name string `json:"name,optional"`
  67. Status string `json:"status,optional"`
  68. }
  69. type KeyListResp {
  70. List []KeyResp `json:"list"`
  71. Total int64 `json:"total"`
  72. }
  73. type CreateServiceReq {
  74. Id int64 `json:"id,optional"`
  75. Name string `json:"name,optional"`
  76. Ip string `json:"ip,optional"`
  77. Port int64 `json:"port,optional"`
  78. Iden string `json:"iden,optional"`
  79. KeyIden string `json:"keyIden,optional"`
  80. KeyAlgo string `json:"keyAlgo,optional"`
  81. Status string `json:"status,optional"`
  82. // 一键刷库:0=否(默认),1=创建后自动下发刷库
  83. Brush int64 `json:"brush,optional"`
  84. Directories []string `json:"directories,optional"`
  85. }
  86. type UpdateServiceReq {
  87. Id int64 `path:"id"`
  88. Name string `json:"name,optional"`
  89. Ip string `json:"ip,optional"`
  90. Port int64 `json:"port,optional"`
  91. Iden string `json:"iden,optional"`
  92. KeyIden string `json:"keyIden,optional"`
  93. KeyAlgo string `json:"keyAlgo,optional"`
  94. Status string `json:"status,optional"`
  95. // 一键刷库:0=否(默认),1=是。编辑只落库改配置,不追溯触发刷库(刷库编排仅在创建流程)
  96. Brush int64 `json:"brush,optional"`
  97. // 编辑时全量提交保护目录列表(nil=未提交不动目录;空数组=清空;非空=全量重写)
  98. Directories []string `json:"directories,optional"`
  99. }
  100. type ServiceIdReq {
  101. Id int64 `path:"id"`
  102. }
  103. type ServiceResp {
  104. Id int64 `json:"id"`
  105. Name string `json:"name"`
  106. Ip string `json:"ip"`
  107. Port int64 `json:"port"`
  108. Iden string `json:"iden"`
  109. KeyIden string `json:"keyIden"`
  110. KeyAlgo string `json:"keyAlgo"`
  111. Status string `json:"status"`
  112. CreateAt string `json:"createAt"`
  113. // 挂载状态: mounted=已挂载 unmounted=未挂载 failed=挂载失败
  114. MountStatus string `json:"mountStatus,optional"`
  115. // 挂载通知失败等非致命警告,前端黄色提示
  116. MountWarning string `json:"mountWarning,optional"`
  117. // 一键刷库配置:0=否(默认),1=是
  118. Brush int64 `json:"brush"`
  119. }
  120. type ListServiceReq {
  121. Page int64 `form:"page,optional"`
  122. PageSize int64 `form:"pageSize,optional"`
  123. }
  124. type ServiceListResp {
  125. List []ServiceResp `json:"list"`
  126. Total int64 `json:"total"`
  127. }
  128. // 本地目录懒加载(udeServer 所在 Linux 主机文件系统,只列目录不列文件)
  129. type ListDirChildrenReq {
  130. Ip string `form:"ip"` // 目标 Linux 主机 IP
  131. Port string `form:"port"` // 目标主机 /api/v1 端口
  132. Path string `form:"path"` // 空或 "/" 表示根目录
  133. Iden string `form:"iden,optional"` // 接入标识:转发外挂时作为 X-TOKEN 头的值;外挂 /path/lists 已免鉴权,未选接入标识(空值)也放行
  134. }
  135. type LocalDirNode {
  136. Name string `json:"name"` // 目录名,如 "usr"
  137. Path string `json:"path"` // 完整绝对路径,如 "/usr"
  138. IsDir bool `json:"isDir"` // 恒 true
  139. HasChildren bool `json:"hasChildren"` // 是否含子目录(前端据此决定是否显示展开箭头)
  140. }
  141. type DirChildrenResp {
  142. Nodes []LocalDirNode `json:"nodes"`
  143. }
  144. // ===== 审计日志(移植自 sdf-serve systemLog 模块)=====
  145. type SystemLog {
  146. Id int64 `json:"id"` // 主键
  147. Iden string `json:"iden"` // 日志标识
  148. TraceId string `json:"traceId"` // 全链路TraceId
  149. SpanId string `json:"spanId"` // 子链路SpanId
  150. ParentSpanId string `json:"parentSpanId"` // 父SpanId
  151. Type int `json:"type"` // 日志类型:1.系统日志;2.接口日志
  152. ServiceName string `json:"serviceName"` // 所属服务名称/模块名称
  153. UriPath string `json:"uriPath"` // 接口请求路径
  154. HttpMethod string `json:"httpMethod"` // 请求方法
  155. Method string `json:"method"` // 业务方法名
  156. Level string `json:"level"` // 日志级别
  157. AppKey string `json:"appKey"` // 调用接口应用标识
  158. UserId string `json:"userId"` // 系统用户ID
  159. UserName string `json:"userName"` // 系统用户名
  160. ClientIp string `json:"clientIp"` // 客户端IP
  161. RequestHeader string `json:"requestHeader"` // 请求头
  162. RequestBodyDigest string `json:"requestBodyDigest"` // 请求体摘要
  163. RequestBodyFileKey string `json:"requestBodyFileKey"` // 请求体FileKey
  164. ResponseCode int64 `json:"responseCode"` // 响应业务码
  165. ResponseBodyDigest string `json:"responseBodyDigest"` // 响应体摘要
  166. ResponseBodyFileKey string `json:"responseBodyFileKey"` // 响应体FileKey
  167. ErrorMsg string `json:"errorMsg"` // 错误信息
  168. DurationMs int64 `json:"durationMs"` // 请求耗时
  169. CreatedAt string `json:"createdAt"` // 日志写入时间
  170. Hmac string `json:"hmac"` // Hmac值
  171. AuditStatus int `json:"auditStatus"` // 审计状态:1.未审计;2.审计通过;3.审计异常
  172. }
  173. type SystemLogListReq {
  174. Iden string `json:"iden,optional"` // 日志标识
  175. Type int64 `json:"type,optional"` // 日志类型
  176. UserName string `json:"userName,optional"` // 用户名称
  177. AppKey string `json:"appKey,optional"` // 应用标识
  178. UriPath string `json:"uriPath,optional"` // 接口请求路径
  179. HttpMethod string `json:"httpMethod,optional"` // 请求方式
  180. CreatedStartTime string `json:"createdStartTime,optional"` // 写入开始时间
  181. CreatedEndTime string `json:"createdEndTime,optional"` // 写入结束时间
  182. ClientIp string `json:"clientIp,optional"` // 客户端IP
  183. ErrorMsg string `json:"errorMsg,optional"` // 错误信息
  184. AuditStatus string `json:"auditStatus,optional"` // 审计状态
  185. Page int64 `json:"page,optional"`
  186. PageSize int64 `json:"pageSize,optional"`
  187. }
  188. type SystemLogListResp {
  189. Total int64 `json:"total"`
  190. Logs []SystemLog `json:"logs"`
  191. }
  192. type SystemLogDetailReq {
  193. Iden string `json:"iden"`
  194. }
  195. type SystemLogDetailResp {
  196. SystemLog
  197. }
  198. type SystemLogAuditReq {
  199. Idens []string `json:"idens"`
  200. }
  201. type AuditResult {
  202. LogIden string `json:"logIden"`
  203. Valid bool `json:"valid"`
  204. Reason string `json:"reason"`
  205. }
  206. type SystemLogAuditResp {
  207. TotalCount int64 `json:"totalCount"`
  208. ValidCount int64 `json:"validCount"`
  209. InValidCount int64 `json:"inValidCount"`
  210. AuditResults []AuditResult `json:"auditResults"`
  211. }
  212. type SystemLogArchiveReq {
  213. Name string `json:"name"` // 归档任务名称
  214. Ids []int64 `json:"ids,optional"` // 日志ID集合
  215. StartDate string `json:"startDate,optional"` // 归档开始日期
  216. EndDate string `json:"endDate,optional"` // 归档结束日期
  217. }
  218. type SystemLogArchiveResp {
  219. Count int `json:"count"`
  220. }
  221. type SystemLogLinkReq {
  222. TraceId string `json:"traceId"`
  223. }
  224. type SystemLogLinkResp {
  225. LogLinks []SystemLog `json:"logLinks"`
  226. }
  227. type LogArchive {
  228. Id int64 `json:"id"`
  229. ArchiveName string `json:"archiveName"`
  230. RecordCount int64 `json:"recordCount"`
  231. ArchiveFileKey string `json:"archiveFileKey"`
  232. ArchiveMode int `json:"archiveMode"` // 归档模式:1.手动,2.自动
  233. BatchSize int `json:"batchSize"`
  234. ArchivedBy string `json:"archivedBy"`
  235. ArchivedAt string `json:"archivedAt"`
  236. }
  237. type LogArchiveListReq {
  238. ArchiveName string `json:"archiveName,optional"`
  239. ArchivedBy string `json:"archivedBy,optional"`
  240. ArchivedStartTime string `json:"archivedStartTime,optional"`
  241. ArchivedEndTime string `json:"archivedEndTime,optional"`
  242. Page int64 `json:"page,optional"`
  243. PageSize int64 `json:"pageSize,optional"`
  244. }
  245. type LogArchiveListResp {
  246. Total int64 `json:"total"`
  247. LogArchives []LogArchive `json:"logArchives"`
  248. }
  249. type LogArchiveDownloadReq {
  250. Ids []int64 `json:"ids"`
  251. }
  252. type LogArchiveRestoreReq {
  253. Ids []int64 `json:"ids"`
  254. }
  255. type LogArchiveRestoreResp {
  256. RestoreMsg string `json:"restoreMsg"`
  257. }
  258. type LogRestore {
  259. Id int64 `json:"id"`
  260. ArchiveId int64 `json:"archiveId"`
  261. RestoreStatus int `json:"restoreStatus"` // 1.成功,2.失败,3.恢复中
  262. RestoreMessage string `json:"restoreMessage"`
  263. RestoredBy string `json:"restoredBy"`
  264. RestoredAt string `json:"restoredAt"`
  265. }
  266. type LogRestoreListReq {
  267. RestoreStatus int64 `json:"restoreStatus,optional"`
  268. RestoreMessage string `json:"restoreMessage,optional"`
  269. Page int64 `json:"page,optional"`
  270. PageSize int64 `json:"pageSize,optional"`
  271. }
  272. type LogRestoreListResp {
  273. Total int64 `json:"total"`
  274. LogRestores []LogRestore `json:"logRestores"`
  275. }
  276. @server (
  277. prefix: /api/v1/systemLog
  278. group: systemlog
  279. )
  280. // 审计日志管理模块
  281. service udeServer-api {
  282. @doc "日志分页列表"
  283. @handler LogListHandler
  284. post /list (SystemLogListReq) returns (SystemLogListResp)
  285. @doc "日志详情"
  286. @handler LogDetailHandler
  287. post /detail (SystemLogDetailReq) returns (SystemLogDetailResp)
  288. @doc "日志审计(校验Hmac防篡改)"
  289. @handler LogAuditHandler
  290. post /audit (SystemLogAuditReq) returns (SystemLogAuditResp)
  291. @doc "日志归档"
  292. @handler LogArchiveHandler
  293. post /archive (SystemLogArchiveReq) returns (SystemLogArchiveResp)
  294. @doc "查看完整链路"
  295. @handler LogLinkHandler
  296. post /link (SystemLogLinkReq) returns (SystemLogLinkResp)
  297. }
  298. @server (
  299. prefix: /api/v1/logArchive
  300. group: systemlog
  301. )
  302. // 归档管理模块
  303. service udeServer-api {
  304. @doc "归档列表"
  305. @handler LogArchiveListHandler
  306. post /list (LogArchiveListReq) returns (LogArchiveListResp)
  307. @doc "归档打包下载(zip)"
  308. @handler LogArchiveDownloadHandler
  309. post /download (LogArchiveDownloadReq)
  310. @doc "归档恢复"
  311. @handler LogArchiveRestoreHandler
  312. post /restore (LogArchiveRestoreReq) returns (LogArchiveRestoreResp)
  313. }
  314. @server (
  315. prefix: /api/v1/logRestore
  316. group: systemlog
  317. )
  318. // 恢复记录模块
  319. service udeServer-api {
  320. @doc "恢复记录列表"
  321. @handler LogRestoreListHandler
  322. post /list (LogRestoreListReq) returns (LogRestoreListResp)
  323. }
  324. @server (
  325. prefix: /api/v1
  326. )
  327. service udeServer-api {
  328. @handler UdeServerHandler
  329. get /from/:name (Request) returns (Response)
  330. @handler DbPingHandler
  331. get /db/ping returns (DbPingResponse)
  332. @handler CreateDirectoryHandler
  333. post /directories (CreateDirectoryReq) returns (DirectoryResp)
  334. @handler ListDirectoriesHandler
  335. get /directories (ListDirectoryReq) returns (DirectoryListResp)
  336. @handler GetDirectoryHandler
  337. get /directories/:id (DirectoryIdReq) returns (DirectoryResp)
  338. @handler UpdateDirectoryHandler
  339. put /directories/:id (UpdateDirectoryReq) returns (DirectoryResp)
  340. @handler DeleteDirectoryHandler
  341. delete /directories/:id (DirectoryIdReq) returns (DeleteResp)
  342. @handler CreateKeyHandler
  343. post /keys/create (CreateKeyReq) returns (KeyResp)
  344. @handler ListKeysHandler
  345. post /keys/list (ListKeysReq) returns (KeyListResp)
  346. @handler GetKeyHandler
  347. post /keys/detail (KeyIdReq) returns (KeyResp)
  348. @handler UpdateKeyHandler
  349. post /keys/update (UpdateKeyReq) returns (KeyResp)
  350. @handler DeleteKeyHandler
  351. post /keys/delete (KeyIdReq) returns (DeleteResp)
  352. @handler CreateServiceHandler
  353. post /services (CreateServiceReq) returns (ServiceResp)
  354. @handler ListServicesHandler
  355. get /services (ListServiceReq) returns (ServiceListResp)
  356. @handler GetServiceHandler
  357. get /services/:id (ServiceIdReq) returns (ServiceResp)
  358. @handler UpdateServiceHandler
  359. put /services/:id (UpdateServiceReq) returns (ServiceResp)
  360. @handler DeleteServiceHandler
  361. delete /services/:id (ServiceIdReq) returns (DeleteResp)
  362. @handler BrushServiceHandler
  363. post /services/:id/brush (ServiceIdReq) returns (DeleteResp)
  364. // 启用服务联动挂载:逐保护目录调外挂 /api/fuseMount,成功后 status=启用、mount_status=mounted
  365. @handler MountServiceHandler
  366. post /services/:id/mount (ServiceIdReq) returns (ServiceResp)
  367. // 停用服务联动卸载:逐保护目录调外挂 /api/fuseUnMount,成功后 status=停用、mount_status=unmounted
  368. @handler UnmountServiceHandler
  369. post /services/:id/unmount (ServiceIdReq) returns (ServiceResp)
  370. @handler ListDirChildrenHandler
  371. get /dirs/children (ListDirChildrenReq) returns (DirChildrenResp)
  372. }
  373. // ===== 应用凭证(移植自 sdf-serve applicationCredentials 模块)=====
  374. type ApplicationCredentials {
  375. Id int64 `json:"id"`
  376. CredIden string `json:"credIden"`
  377. Name string `json:"name"`
  378. ApiKey string `json:"apiKey"`
  379. ApiSecret string `json:"apiSecret"` // 掩码后的密钥,原文走下发接口
  380. Status int `json:"status"` // 启用状态:1.启用;2.禁用
  381. Description string `json:"description"`
  382. CreatedBy string `json:"createdBy"`
  383. CreatedAt string `json:"createdAt"`
  384. UpdatedBy string `json:"updatedBy"`
  385. UpdatedAt string `json:"updatedAt"`
  386. }
  387. type ApplicationCredentialsAddReq {
  388. Name string `json:"name"` // 应用名称
  389. Status int `json:"status,optional"` // 应用状态(1启用,2禁用),缺省启用
  390. Description string `json:"description,optional"` // 应用描述
  391. }
  392. type ApplicationCredentialsAddResp {
  393. Iden string `json:"iden"` // 应用凭证标识
  394. }
  395. type ApplicationCredentialsDeleteReq {
  396. Id int64 `json:"id"`
  397. }
  398. type ApplicationCredentialsDeleteResp {
  399. Iden string `json:"iden"` // 应用凭证标识
  400. }
  401. type ApplicationCredentialsDistributeReq {
  402. Id int64 `json:"id"`
  403. }
  404. type ApplicationCredentialsDistributeResp {
  405. ApiSecret string `json:"apiSecret"` // 应用凭证密钥(明文,仅下发接口返回)
  406. }
  407. type ApplicationCredentialsResetReq {
  408. Id int64 `json:"id"`
  409. }
  410. type ApplicationCredentialsResetResp {
  411. Iden string `json:"iden"` // 应用凭证标识
  412. }
  413. type ApplicationCredentialsUpdateStatusReq {
  414. Id int64 `json:"id"`
  415. }
  416. type ApplicationCredentialsUpdateStatusResp {
  417. Iden string `json:"iden"` // 应用凭证标识
  418. }
  419. type ApplicationListReq {
  420. Status int64 `json:"status,optional"` // 启用状态筛选
  421. CredIden string `json:"credIden,optional"` // 应用凭证标识筛选
  422. Name string `json:"name,optional"` // 应用名称模糊筛选
  423. Page int64 `json:"page,optional"`
  424. PageSize int64 `json:"pageSize,optional"`
  425. }
  426. type ApplicationListResp {
  427. Total int64 `json:"total"`
  428. ApplicationLists []ApplicationCredentials `json:"applicationLists"`
  429. }
  430. @server (
  431. prefix: /api/v1/applicationCredentials
  432. group: application
  433. )
  434. // 应用凭证管理模块
  435. service udeServer-api {
  436. @doc "添加应用凭证"
  437. @handler AddApplicationHandler
  438. post /addApplication (ApplicationCredentialsAddReq) returns (ApplicationCredentialsAddResp)
  439. @doc "应用凭证列表"
  440. @handler ApplicationListHandler
  441. post /applicationList (ApplicationListReq) returns (ApplicationListResp)
  442. @doc "删除应用凭证"
  443. @handler DeleteApplicationHandler
  444. post /deleteApplication (ApplicationCredentialsDeleteReq) returns (ApplicationCredentialsDeleteResp)
  445. @doc "下发应用凭证密钥"
  446. @handler DistributeApiSecretHandler
  447. post /distributeApiSecret (ApplicationCredentialsDistributeReq) returns (ApplicationCredentialsDistributeResp)
  448. @doc "重置应用凭证密钥"
  449. @handler ResetApplicationHandler
  450. post /resetApplication (ApplicationCredentialsResetReq) returns (ApplicationCredentialsResetResp)
  451. @doc "切换应用凭证状态(启用/禁用互换)"
  452. @handler UpdateApplicationStatusHandler
  453. post /updateApplicationStatus (ApplicationCredentialsUpdateStatusReq) returns (ApplicationCredentialsUpdateStatusResp)
  454. }