overlord.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package http
  2. import (
  3. "go-common/app/admin/main/cache/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. // @params OverlordReq
  7. // @router get /x/admin/cache/overlord/clusters
  8. // @response OverlordResp
  9. func overlordClusters(ctx *bm.Context) {
  10. req := new(model.OverlordReq)
  11. if err := ctx.Bind(req); err != nil {
  12. return
  13. }
  14. ctx.JSON(srv.OverlordClusters(ctx, req))
  15. }
  16. // @params OverlordReq
  17. // @router get /x/admin/cache/overlord/ops/names
  18. // @response EmpResp
  19. func overlordOpsClusterNames(ctx *bm.Context) {
  20. req := new(model.OverlordReq)
  21. if err := ctx.Bind(req); err != nil {
  22. return
  23. }
  24. ctx.JSON(srv.OpsClusterNames(ctx, req))
  25. }
  26. // @params OverlordReq
  27. // @router get /x/admin/cache/overlord/ops/nodes
  28. // @response EmpResp
  29. func overlordOpsNodes(ctx *bm.Context) {
  30. req := new(model.OverlordReq)
  31. if err := ctx.Bind(req); err != nil {
  32. return
  33. }
  34. ctx.JSON(srv.OpsClusterNodes(ctx, req))
  35. }
  36. // @params OverlordReq
  37. // @router get /x/admin/cache/overlord/import/ops/cluster
  38. // @response EmpResp
  39. func overlordImportCluster(ctx *bm.Context) {
  40. req := new(model.OverlordReq)
  41. if err := ctx.Bind(req); err != nil {
  42. return
  43. }
  44. ctx.JSON(srv.ImportOpsCluster(ctx, req))
  45. }
  46. // @params OverlordReq
  47. // @router get /x/admin/cache/overlord/new/ops/node
  48. // @response EmpResp
  49. func overlordClusterNewNode(ctx *bm.Context) {
  50. req := new(model.OverlordReq)
  51. if err := ctx.Bind(req); err != nil {
  52. return
  53. }
  54. ctx.JSON(srv.ImportOpsNode(ctx, req))
  55. }
  56. // @params OverlordReq
  57. // @router get /x/admin/cache/overlord/replace/ops/node
  58. // @response EmpResp
  59. func overlordClusterReplaceNode(ctx *bm.Context) {
  60. req := new(model.OverlordReq)
  61. if err := ctx.Bind(req); err != nil {
  62. return
  63. }
  64. ctx.JSON(srv.ReplaceOpsNode(ctx, req))
  65. }
  66. // @params OverlordReq
  67. // @router get /x/admin/cache/overlord/cluster/del
  68. // @response EmpResp
  69. func overlordDelCluster(ctx *bm.Context) {
  70. req := new(model.OverlordReq)
  71. if err := ctx.Bind(req); err != nil {
  72. return
  73. }
  74. ctx.JSON(srv.DelOverlordCluster(ctx, req))
  75. }
  76. // @params OverlordReq
  77. // @router get /x/admin/cache/overlord/node/del
  78. // @response EmpResp
  79. func overlordDelNode(ctx *bm.Context) {
  80. req := new(model.OverlordReq)
  81. if err := ctx.Bind(req); err != nil {
  82. return
  83. }
  84. ctx.JSON(srv.DelOverlordNode(ctx, req))
  85. }
  86. // @params OverlordReq
  87. // @router get /x/admin/cache/overlord/app/clusters
  88. // @response OverlordResp
  89. func overlordAppClusters(ctx *bm.Context) {
  90. req := new(model.OverlordReq)
  91. if err := ctx.Bind(req); err != nil {
  92. return
  93. }
  94. req.Cookie = ctx.Request.Header.Get("Cookie")
  95. ctx.JSON(srv.OverlordAppClusters(ctx, req))
  96. }
  97. // @params OverlordReq
  98. // @router get /x/admin/cache/overlord/app/can/bind/clusters
  99. // @response OverlordResp
  100. func overlordAppNeedClusters(ctx *bm.Context) {
  101. req := new(model.OverlordReq)
  102. if err := ctx.Bind(req); err != nil {
  103. return
  104. }
  105. ctx.JSON(srv.OverlordAppCanBindClusters(ctx, req))
  106. }
  107. // @params OverlordReq
  108. // @router get /x/admin/cache/overlord/app/cluster/bind
  109. // @response OverlordResp
  110. func overlordAppClusterBind(ctx *bm.Context) {
  111. req := new(model.OverlordReq)
  112. if err := ctx.Bind(req); err != nil {
  113. return
  114. }
  115. req.Cookie = ctx.Request.Header.Get("Cookie")
  116. ctx.JSON(srv.OverlordAppClusterBind(ctx, req))
  117. }
  118. // @params OverlordReq
  119. // @router get /x/admin/cache/overlord/app/cluster/del
  120. // @response OverlordResp
  121. func overlordAppClusterDel(ctx *bm.Context) {
  122. req := new(model.OverlordReq)
  123. if err := ctx.Bind(req); err != nil {
  124. return
  125. }
  126. req.Cookie = ctx.Request.Header.Get("Cookie")
  127. ctx.JSON(srv.OverlordAppClusterDel(ctx, req))
  128. }
  129. // @params OverlordReq
  130. // @router get /x/admin/cache/overlord/app/appids
  131. // @response OverlordResp
  132. func overlordAppAppIDs(ctx *bm.Context) {
  133. req := new(model.OverlordReq)
  134. if err := ctx.Bind(req); err != nil {
  135. return
  136. }
  137. req.Cookie = ctx.Request.Header.Get("Cookie")
  138. ctx.JSON(srv.OverlordAppAppIDs(ctx, req))
  139. }
  140. func overlordToml(ctx *bm.Context) {
  141. req := new(model.OverlordReq)
  142. if err := ctx.Bind(req); err != nil {
  143. return
  144. }
  145. resp, err := srv.OverlordToml(ctx, req)
  146. if err != nil {
  147. ctx.Status(500)
  148. return
  149. }
  150. ctx.Writer.Write(resp)
  151. }