package http import ( "context" "fmt" "net/http" "time" "github.com/gin-gonic/gin" "gitlink.org.cn/cloudream/common/pkgs/logger" "gitlink.org.cn/cloudream/jcs-pub/client/internal/http/types" cliapi "gitlink.org.cn/cloudream/jcs-pub/client/sdk/api/v1" "gitlink.org.cn/cloudream/jcs-pub/common/ecode" clirpc "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc/client" ) type ClusterService struct { *Server } func (s *Server) Cluster() *ClusterService { return &ClusterService{ Server: s, } } func (s *ClusterService) Status(ctx *gin.Context) { log := logger.WithField("HTTP", "Cluster.Status") var req cliapi.ClusterStatus if err := ctx.ShouldBindQuery(&req); err != nil { log.Warnf("binding query: %s", err.Error()) ctx.JSON(http.StatusBadRequest, types.Failed(ecode.BadArgument, "missing argument or invalid argument")) return } _, cerr := s.svc.Cluster.MasterClient().ClusterApplyLog(context.TODO(), &clirpc.ClusterApplyLog{ Data: []byte(fmt.Sprintf("%v: %v", s.svc.Cluster.ID(), time.Now())), }) if cerr != nil { ctx.JSON(http.StatusOK, types.Failed(ecode.ErrorCode(cerr.Code), "%v", cerr.Message)) return } ctx.JSON(http.StatusOK, types.OK(cliapi.ClusterStatus{})) }