udeServer.api 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. type CreateDirectoryReq {
  17. Id int64 `json:"id,optional"`
  18. ServiceId int64 `json:"serviceId,optional"`
  19. Directory string `json:"directory,optional"`
  20. }
  21. type UpdateDirectoryReq {
  22. Id int64 `path:"id"`
  23. ServiceId int64 `json:"serviceId,optional"`
  24. Directory string `json:"directory,optional"`
  25. }
  26. type DirectoryIdReq {
  27. Id int64 `path:"id"`
  28. }
  29. type DirectoryResp {
  30. Id int64 `json:"id"`
  31. ServiceId int64 `json:"serviceId"`
  32. Directory string `json:"directory"`
  33. }
  34. type ListDirectoryReq {
  35. Page int64 `form:"page,optional"`
  36. PageSize int64 `form:"pageSize,optional"`
  37. }
  38. type DirectoryListResp {
  39. List []DirectoryResp `json:"list"`
  40. Total int64 `json:"total"`
  41. }
  42. type CreateKeyReq {
  43. Name string `json:"name"`
  44. }
  45. type UpdateKeyReq {
  46. Id int64 `json:"id"`
  47. Status string `json:"status"`
  48. }
  49. type KeyIdReq {
  50. Id int64 `json:"id"`
  51. }
  52. type KeyResp {
  53. Id int64 `json:"id"`
  54. Iden string `json:"iden"`
  55. Name string `json:"name"`
  56. Content string `json:"content"`
  57. Status string `json:"status"`
  58. CreateAt string `json:"createAt"`
  59. }
  60. type ListKeysReq {
  61. Page int64 `json:"page,optional"`
  62. PageSize int64 `json:"pageSize,optional"`
  63. Name string `json:"name,optional"`
  64. Status string `json:"status,optional"`
  65. }
  66. type KeyListResp {
  67. List []KeyResp `json:"list"`
  68. Total int64 `json:"total"`
  69. }
  70. type CreateServiceReq {
  71. Id int64 `json:"id,optional"`
  72. Name string `json:"name,optional"`
  73. Ip string `json:"ip,optional"`
  74. Port int64 `json:"port,optional"`
  75. Iden string `json:"iden,optional"`
  76. KeyIden string `json:"keyIden,optional"`
  77. KeyAlgo string `json:"keyAlgo,optional"`
  78. Status string `json:"status,optional"`
  79. Directories []string `json:"directories,optional"`
  80. }
  81. type UpdateServiceReq {
  82. Id int64 `path:"id"`
  83. Name string `json:"name,optional"`
  84. Ip string `json:"ip,optional"`
  85. Port int64 `json:"port,optional"`
  86. Iden string `json:"iden,optional"`
  87. KeyIden string `json:"keyIden,optional"`
  88. KeyAlgo string `json:"keyAlgo,optional"`
  89. Status string `json:"status,optional"`
  90. }
  91. type ServiceIdReq {
  92. Id int64 `path:"id"`
  93. }
  94. type ServiceResp {
  95. Id int64 `json:"id"`
  96. Name string `json:"name"`
  97. Ip string `json:"ip"`
  98. Port int64 `json:"port"`
  99. Iden string `json:"iden"`
  100. KeyIden string `json:"keyIden"`
  101. KeyAlgo string `json:"keyAlgo"`
  102. Status string `json:"status"`
  103. CreateAt string `json:"createAt"`
  104. // 挂载通知失败等非致命警告,前端黄色提示
  105. MountWarning string `json:"mountWarning,optional"`
  106. }
  107. type ListServiceReq {
  108. Page int64 `form:"page,optional"`
  109. PageSize int64 `form:"pageSize,optional"`
  110. }
  111. type ServiceListResp {
  112. List []ServiceResp `json:"list"`
  113. Total int64 `json:"total"`
  114. }
  115. // 本地目录懒加载(udeServer 所在 Linux 主机文件系统,只列目录不列文件)
  116. type ListDirChildrenReq {
  117. Ip string `form:"ip"` // 目标 Linux 主机 IP
  118. Port string `form:"port"` // 目标主机 /api/v1 端口
  119. Path string `form:"path"` // 空或 "/" 表示根目录
  120. }
  121. type LocalDirNode {
  122. Name string `json:"name"` // 目录名,如 "usr"
  123. Path string `json:"path"` // 完整绝对路径,如 "/usr"
  124. IsDir bool `json:"isDir"` // 恒 true
  125. HasChildren bool `json:"hasChildren"` // 是否含子目录(前端据此决定是否显示展开箭头)
  126. }
  127. type DirChildrenResp {
  128. Nodes []LocalDirNode `json:"nodes"`
  129. }
  130. // ===== 审计日志(移植自 sdf-serve systemLog 模块)=====
  131. type SystemLog {
  132. Id int64 `json:"id"` // 主键
  133. Iden string `json:"iden"` // 日志标识
  134. TraceId string `json:"traceId"` // 全链路TraceId
  135. SpanId string `json:"spanId"` // 子链路SpanId
  136. ParentSpanId string `json:"parentSpanId"` // 父SpanId
  137. Type int `json:"type"` // 日志类型:1.系统日志;2.接口日志
  138. ServiceName string `json:"serviceName"` // 所属服务名称/模块名称
  139. UriPath string `json:"uriPath"` // 接口请求路径
  140. HttpMethod string `json:"httpMethod"` // 请求方法
  141. Method string `json:"method"` // 业务方法名
  142. Level string `json:"level"` // 日志级别
  143. AppKey string `json:"appKey"` // 调用接口应用标识
  144. UserId string `json:"userId"` // 系统用户ID
  145. UserName string `json:"userName"` // 系统用户名
  146. ClientIp string `json:"clientIp"` // 客户端IP
  147. RequestHeader string `json:"requestHeader"` // 请求头
  148. RequestBodyDigest string `json:"requestBodyDigest"` // 请求体摘要
  149. RequestBodyFileKey string `json:"requestBodyFileKey"` // 请求体FileKey
  150. ResponseCode int64 `json:"responseCode"` // 响应业务码
  151. ResponseBodyDigest string `json:"responseBodyDigest"` // 响应体摘要
  152. ResponseBodyFileKey string `json:"responseBodyFileKey"` // 响应体FileKey
  153. ErrorMsg string `json:"errorMsg"` // 错误信息
  154. DurationMs int64 `json:"durationMs"` // 请求耗时
  155. CreatedAt string `json:"createdAt"` // 日志写入时间
  156. Hmac string `json:"hmac"` // Hmac值
  157. AuditStatus int `json:"auditStatus"` // 审计状态:1.未审计;2.审计通过;3.审计异常
  158. }
  159. type SystemLogListReq {
  160. Iden string `json:"iden,optional"` // 日志标识
  161. Type int64 `json:"type,optional"` // 日志类型
  162. UserName string `json:"userName,optional"` // 用户名称
  163. AppKey string `json:"appKey,optional"` // 应用标识
  164. UriPath string `json:"uriPath,optional"` // 接口请求路径
  165. HttpMethod string `json:"httpMethod,optional"` // 请求方式
  166. CreatedStartTime string `json:"createdStartTime,optional"` // 写入开始时间
  167. CreatedEndTime string `json:"createdEndTime,optional"` // 写入结束时间
  168. ClientIp string `json:"clientIp,optional"` // 客户端IP
  169. ErrorMsg string `json:"errorMsg,optional"` // 错误信息
  170. AuditStatus string `json:"auditStatus,optional"` // 审计状态
  171. Page int64 `json:"page,optional"`
  172. PageSize int64 `json:"pageSize,optional"`
  173. }
  174. type SystemLogListResp {
  175. Total int64 `json:"total"`
  176. Logs []SystemLog `json:"logs"`
  177. }
  178. type SystemLogDetailReq {
  179. Iden string `json:"iden"`
  180. }
  181. type SystemLogDetailResp {
  182. SystemLog
  183. }
  184. type SystemLogAuditReq {
  185. Idens []string `json:"idens"`
  186. }
  187. type AuditResult {
  188. LogIden string `json:"logIden"`
  189. Valid bool `json:"valid"`
  190. Reason string `json:"reason"`
  191. }
  192. type SystemLogAuditResp {
  193. TotalCount int64 `json:"totalCount"`
  194. ValidCount int64 `json:"validCount"`
  195. InValidCount int64 `json:"inValidCount"`
  196. AuditResults []AuditResult `json:"auditResults"`
  197. }
  198. type SystemLogArchiveReq {
  199. Name string `json:"name"` // 归档任务名称
  200. Ids []int64 `json:"ids,optional"` // 日志ID集合
  201. StartDate string `json:"startDate,optional"` // 归档开始日期
  202. EndDate string `json:"endDate,optional"` // 归档结束日期
  203. }
  204. type SystemLogArchiveResp {
  205. Count int `json:"count"`
  206. }
  207. type SystemLogLinkReq {
  208. TraceId string `json:"traceId"`
  209. }
  210. type SystemLogLinkResp {
  211. LogLinks []SystemLog `json:"logLinks"`
  212. }
  213. type LogArchive {
  214. Id int64 `json:"id"`
  215. ArchiveName string `json:"archiveName"`
  216. RecordCount int64 `json:"recordCount"`
  217. ArchiveFileKey string `json:"archiveFileKey"`
  218. ArchiveMode int `json:"archiveMode"` // 归档模式:1.手动,2.自动
  219. BatchSize int `json:"batchSize"`
  220. ArchivedBy string `json:"archivedBy"`
  221. ArchivedAt string `json:"archivedAt"`
  222. }
  223. type LogArchiveListReq {
  224. ArchiveName string `json:"archiveName,optional"`
  225. ArchivedBy string `json:"archivedBy,optional"`
  226. ArchivedStartTime string `json:"archivedStartTime,optional"`
  227. ArchivedEndTime string `json:"archivedEndTime,optional"`
  228. Page int64 `json:"page,optional"`
  229. PageSize int64 `json:"pageSize,optional"`
  230. }
  231. type LogArchiveListResp {
  232. Total int64 `json:"total"`
  233. LogArchives []LogArchive `json:"logArchives"`
  234. }
  235. type LogArchiveDownloadReq {
  236. Ids []int64 `json:"ids"`
  237. }
  238. type LogArchiveRestoreReq {
  239. Ids []int64 `json:"ids"`
  240. }
  241. type LogArchiveRestoreResp {
  242. RestoreMsg string `json:"restoreMsg"`
  243. }
  244. type LogRestore {
  245. Id int64 `json:"id"`
  246. ArchiveId int64 `json:"archiveId"`
  247. RestoreStatus int `json:"restoreStatus"` // 1.成功,2.失败,3.恢复中
  248. RestoreMessage string `json:"restoreMessage"`
  249. RestoredBy string `json:"restoredBy"`
  250. RestoredAt string `json:"restoredAt"`
  251. }
  252. type LogRestoreListReq {
  253. RestoreStatus int64 `json:"restoreStatus,optional"`
  254. RestoreMessage string `json:"restoreMessage,optional"`
  255. Page int64 `json:"page,optional"`
  256. PageSize int64 `json:"pageSize,optional"`
  257. }
  258. type LogRestoreListResp {
  259. Total int64 `json:"total"`
  260. LogRestores []LogRestore `json:"logRestores"`
  261. }
  262. @server (
  263. prefix: /api/v1/systemlog
  264. group: systemlog
  265. )
  266. // 审计日志管理模块
  267. service udeServer-api {
  268. @doc "日志分页列表"
  269. @handler LogListHandler
  270. post /list (SystemLogListReq) returns (SystemLogListResp)
  271. @doc "日志详情"
  272. @handler LogDetailHandler
  273. post /detail (SystemLogDetailReq) returns (SystemLogDetailResp)
  274. @doc "日志审计(校验Hmac防篡改)"
  275. @handler LogAuditHandler
  276. post /audit (SystemLogAuditReq) returns (SystemLogAuditResp)
  277. @doc "日志归档"
  278. @handler LogArchiveHandler
  279. post /archive (SystemLogArchiveReq) returns (SystemLogArchiveResp)
  280. @doc "查看完整链路"
  281. @handler LogLinkHandler
  282. post /link (SystemLogLinkReq) returns (SystemLogLinkResp)
  283. }
  284. @server (
  285. prefix: /api/v1/logarchive
  286. group: systemlog
  287. )
  288. // 归档管理模块
  289. service udeServer-api {
  290. @doc "归档列表"
  291. @handler LogArchiveListHandler
  292. post /list (LogArchiveListReq) returns (LogArchiveListResp)
  293. @doc "归档打包下载(zip)"
  294. @handler LogArchiveDownloadHandler
  295. post /download (LogArchiveDownloadReq)
  296. @doc "归档恢复"
  297. @handler LogArchiveRestoreHandler
  298. post /restore (LogArchiveRestoreReq) returns (LogArchiveRestoreResp)
  299. }
  300. @server (
  301. prefix: /api/v1/logrestore
  302. group: systemlog
  303. )
  304. // 恢复记录模块
  305. service udeServer-api {
  306. @doc "恢复记录列表"
  307. @handler LogRestoreListHandler
  308. post /list (LogRestoreListReq) returns (LogRestoreListResp)
  309. }
  310. @server (
  311. prefix: /api/v1
  312. )
  313. service udeServer-api {
  314. @handler UdeServerHandler
  315. get /from/:name (Request) returns (Response)
  316. @handler DbPingHandler
  317. get /db/ping returns (DbPingResponse)
  318. @handler CreateDirectoryHandler
  319. post /directories (CreateDirectoryReq) returns (DirectoryResp)
  320. @handler ListDirectoriesHandler
  321. get /directories (ListDirectoryReq) returns (DirectoryListResp)
  322. @handler GetDirectoryHandler
  323. get /directories/:id (DirectoryIdReq) returns (DirectoryResp)
  324. @handler UpdateDirectoryHandler
  325. put /directories/:id (UpdateDirectoryReq) returns (DirectoryResp)
  326. @handler DeleteDirectoryHandler
  327. delete /directories/:id (DirectoryIdReq) returns (DeleteResp)
  328. @handler CreateKeyHandler
  329. post /keys/create (CreateKeyReq) returns (KeyResp)
  330. @handler ListKeysHandler
  331. post /keys/list (ListKeysReq) returns (KeyListResp)
  332. @handler GetKeyHandler
  333. post /keys/detail (KeyIdReq) returns (KeyResp)
  334. @handler UpdateKeyHandler
  335. post /keys/update (UpdateKeyReq) returns (KeyResp)
  336. @handler DeleteKeyHandler
  337. post /keys/delete (KeyIdReq) returns (DeleteResp)
  338. @handler CreateServiceHandler
  339. post /services (CreateServiceReq) returns (ServiceResp)
  340. @handler ListServicesHandler
  341. get /services (ListServiceReq) returns (ServiceListResp)
  342. @handler GetServiceHandler
  343. get /services/:id (ServiceIdReq) returns (ServiceResp)
  344. @handler UpdateServiceHandler
  345. put /services/:id (UpdateServiceReq) returns (ServiceResp)
  346. @handler DeleteServiceHandler
  347. delete /services/:id (ServiceIdReq) returns (DeleteResp)
  348. @handler BrushServiceHandler
  349. post /services/:id/brush (ServiceIdReq) returns (DeleteResp)
  350. @handler ListDirChildrenHandler
  351. get /dirs/children (ListDirChildrenReq) returns (DirChildrenResp)
  352. }