forked from JointCloud/pcm-coordinator
added queryresources api
This commit is contained in:
parent
73a3e84745
commit
a2ae89e103
|
@ -937,6 +937,9 @@ service pcm {
|
|||
|
||||
@handler GetClusterBalanceByIdHandler
|
||||
get /schedule/getClusterBalanceById/:adapterId/:clusterId (GetClusterBalanceByIdReq) returns (GetClusterBalanceByIdResp)
|
||||
|
||||
@handler QueryResourcesHandler
|
||||
get /schedule/queryResources returns (QueryResourcesResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
|
|
|
@ -150,4 +150,10 @@ type (
|
|||
GetClusterBalanceByIdResp{
|
||||
Balance float64 `json:"balance"`
|
||||
}
|
||||
|
||||
QueryResourcesResp{
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
)
|
|
@ -1177,6 +1177,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/schedule/getClusterBalanceById/:adapterId/:clusterId",
|
||||
Handler: schedule.GetClusterBalanceByIdHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/schedule/queryResources",
|
||||
Handler: schedule.QueryResourcesHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package schedule
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
)
|
||||
|
||||
func QueryResourcesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := schedule.NewQueryResourcesLogic(r.Context(), svcCtx)
|
||||
resp, err := l.QueryResources()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package schedule
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type QueryResourcesLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewQueryResourcesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryResourcesLogic {
|
||||
return &QueryResourcesLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *QueryResourcesLogic) QueryResources() (resp *types.QueryResourcesResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -5870,6 +5870,12 @@ type GetClusterBalanceByIdResp struct {
|
|||
Balance float64 `json:"balance"`
|
||||
}
|
||||
|
||||
type QueryResourcesResp struct {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type CreateAlertRuleReq struct {
|
||||
CLusterId string `json:"clusterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
|
|
Loading…
Reference in New Issue