udeServer.api 12 KB

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