udeServer.api 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. Path string `form:"path"` // 空或 "/" 表示根目录
  116. }
  117. type LocalDirNode {
  118. Name string `json:"name"` // 目录名,如 "usr"
  119. Path string `json:"path"` // 完整绝对路径,如 "/usr"
  120. IsDir bool `json:"isDir"` // 恒 true
  121. HasChildren bool `json:"hasChildren"` // 是否含子目录(前端据此决定是否显示展开箭头)
  122. }
  123. type DirChildrenResp {
  124. Nodes []LocalDirNode `json:"nodes"`
  125. }
  126. // 自动检测 SMB 共享的目录树
  127. type ScanDirectoriesReq {
  128. Ip string `json:"ip"`
  129. Port string `json:"port,optional"`
  130. Share string `json:"share,optional"` // 留空读 config.DefaultShare
  131. }
  132. type DirectoryNode {
  133. Name string `json:"name"`
  134. SmbPath string `json:"smbPath"` // SMB 路径: \\ip\share\dir
  135. LocalMount string `json:"localMount"` // 真实挂载点: /var/ude/mnt/svc-123/data
  136. IsDir bool `json:"isDir"`
  137. Children []DirectoryNode `json:"children,optional"`
  138. }
  139. @server (
  140. prefix: /api/v1
  141. )
  142. service udeServer-api {
  143. @handler UdeServerHandler
  144. get /from/:name (Request) returns (Response)
  145. @handler DbPingHandler
  146. get /db/ping returns (DbPingResponse)
  147. @handler CreateDirectoryHandler
  148. post /directories (CreateDirectoryReq) returns (DirectoryResp)
  149. @handler ListDirectoriesHandler
  150. get /directories (ListDirectoryReq) returns (DirectoryListResp)
  151. @handler GetDirectoryHandler
  152. get /directories/:id (DirectoryIdReq) returns (DirectoryResp)
  153. @handler UpdateDirectoryHandler
  154. put /directories/:id (UpdateDirectoryReq) returns (DirectoryResp)
  155. @handler DeleteDirectoryHandler
  156. delete /directories/:id (DirectoryIdReq) returns (DeleteResp)
  157. @handler CreateKeyHandler
  158. post /keys/create (CreateKeyReq) returns (KeyResp)
  159. @handler ListKeysHandler
  160. post /keys/list (ListKeysReq) returns (KeyListResp)
  161. @handler GetKeyHandler
  162. post /keys/detail (KeyIdReq) returns (KeyResp)
  163. @handler UpdateKeyHandler
  164. post /keys/update (UpdateKeyReq) returns (KeyResp)
  165. @handler DeleteKeyHandler
  166. post /keys/delete (KeyIdReq) returns (DeleteResp)
  167. @handler CreateServiceHandler
  168. post /services (CreateServiceReq) returns (ServiceResp)
  169. @handler ListServicesHandler
  170. get /services (ListServiceReq) returns (ServiceListResp)
  171. @handler GetServiceHandler
  172. get /services/:id (ServiceIdReq) returns (ServiceResp)
  173. @handler UpdateServiceHandler
  174. put /services/:id (UpdateServiceReq) returns (ServiceResp)
  175. @handler DeleteServiceHandler
  176. delete /services/:id (ServiceIdReq) returns (DeleteResp)
  177. @handler BrushServiceHandler
  178. post /services/:id/brush (ServiceIdReq) returns (DeleteResp)
  179. @handler ListDirChildrenHandler
  180. get /dirs/children (ListDirChildrenReq) returns (DirChildrenResp)
  181. }