udeServer.api 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. 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. @server (
  129. prefix: /api/v1
  130. )
  131. service udeServer-api {
  132. @handler UdeServerHandler
  133. get /from/:name (Request) returns (Response)
  134. @handler DbPingHandler
  135. get /db/ping returns (DbPingResponse)
  136. @handler CreateDirectoryHandler
  137. post /directories (CreateDirectoryReq) returns (DirectoryResp)
  138. @handler ListDirectoriesHandler
  139. get /directories (ListDirectoryReq) returns (DirectoryListResp)
  140. @handler GetDirectoryHandler
  141. get /directories/:id (DirectoryIdReq) returns (DirectoryResp)
  142. @handler UpdateDirectoryHandler
  143. put /directories/:id (UpdateDirectoryReq) returns (DirectoryResp)
  144. @handler DeleteDirectoryHandler
  145. delete /directories/:id (DirectoryIdReq) returns (DeleteResp)
  146. @handler CreateKeyHandler
  147. post /keys/create (CreateKeyReq) returns (KeyResp)
  148. @handler ListKeysHandler
  149. post /keys/list (ListKeysReq) returns (KeyListResp)
  150. @handler GetKeyHandler
  151. post /keys/detail (KeyIdReq) returns (KeyResp)
  152. @handler UpdateKeyHandler
  153. post /keys/update (UpdateKeyReq) returns (KeyResp)
  154. @handler DeleteKeyHandler
  155. post /keys/delete (KeyIdReq) returns (DeleteResp)
  156. @handler CreateServiceHandler
  157. post /services (CreateServiceReq) returns (ServiceResp)
  158. @handler ListServicesHandler
  159. get /services (ListServiceReq) returns (ServiceListResp)
  160. @handler GetServiceHandler
  161. get /services/:id (ServiceIdReq) returns (ServiceResp)
  162. @handler UpdateServiceHandler
  163. put /services/:id (UpdateServiceReq) returns (ServiceResp)
  164. @handler DeleteServiceHandler
  165. delete /services/:id (ServiceIdReq) returns (DeleteResp)
  166. @handler BrushServiceHandler
  167. post /services/:id/brush (ServiceIdReq) returns (DeleteResp)
  168. @handler ListDirChildrenHandler
  169. get /dirs/children (ListDirChildrenReq) returns (DirChildrenResp)
  170. }