From 73c9de7e8a342c95bbde5393bef0aeb38534482f Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Fri, 8 Apr 2022 16:09:20 +0800 Subject: [PATCH] Create Pod on multiple cloud Signed-off-by: zhouqunjie <450705171@qq.com> --- adaptor/pod_adaptor/server/pod/list.go | 23 +++ common/server/server_pod.go | 9 ++ idl/pbpod/pod.proto | 22 +++ lan_trans/idl/demo/demo.pb.gw.go | 10 +- lan_trans/idl/pbecs/ecs.pb.gw.go | 30 ++-- lan_trans/idl/pbpod/pod.pb.gw.go | 145 +++++++++++++++--- lan_trans/idl/pbpod/pod_grpc.pb.go | 38 +++++ .../openapiv2/idl/demo/demo.swagger.json | 9 +- .../openapiv2/idl/pbecs/ecs.swagger.json | 9 +- .../openapiv2/idl/pbpod/pod.swagger.json | 97 ++++++++++-- .../idl/pbtenant/tenant.swagger.json | 9 +- 11 files changed, 326 insertions(+), 75 deletions(-) diff --git a/adaptor/pod_adaptor/server/pod/list.go b/adaptor/pod_adaptor/server/pod/list.go index dd9b441..c5338c1 100644 --- a/adaptor/pod_adaptor/server/pod/list.go +++ b/adaptor/pod_adaptor/server/pod/list.go @@ -13,6 +13,29 @@ import ( "github.com/pkg/errors" ) +func CreatePods(ctx context.Context, req *pbpod.CreatePodsReq) (*pbpod.CreatePodsResp, error) { + var ( + pods []*pbpod.PodInstance + requestIds []string + ) + for k := range req.CreatePodReq { + resp, _ := CreatePod(ctx, req.CreatePodReq[k]) + pods[k] = resp.Pods[0] + requestIds[k] = resp.RequestId + } + + isFinished := false + if len(pods) > 0 { + isFinished = true + } + + return &pbpod.CreatePodsResp{ + Pods: pods, + Finished: isFinished, + RequestId: requestIds, + }, nil +} + func CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) { var ( pod poder.Poder diff --git a/common/server/server_pod.go b/common/server/server_pod.go index dcb1996..f180983 100644 --- a/common/server/server_pod.go +++ b/common/server/server_pod.go @@ -11,6 +11,15 @@ import ( "google.golang.org/grpc/status" ) +func (s *Server) CreatePods(ctx context.Context, req *pbpod.CreatePodsReq) (*pbpod.CreatePodsResp, error) { + resp, err := pod.CreatePods(ctx, req) + if err != nil { + glog.Errorf("CreatePods error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} + func (s *Server) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) { resp, err := pod.CreatePod(ctx, req) if err != nil { diff --git a/idl/pbpod/pod.proto b/idl/pbpod/pod.proto index 3fb3340..07ddabe 100644 --- a/idl/pbpod/pod.proto +++ b/idl/pbpod/pod.proto @@ -40,6 +40,20 @@ message PodInstance { } +message CreatePodsReq { + // 云类型 + repeated CreatePodReq createPodReq = 1; +} + +message CreatePodsResp { + // Pod集合 + repeated PodInstance pods = 1; + // 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询 + bool finished = 2; + // 请求id,出现问题后提供给云厂商,排查问题 + repeated string request_id = 3; +} + message CreatePodReq { // 云类型 pbtenant.CloudProvider provider = 1; @@ -194,6 +208,14 @@ message ListPodAllReq{} service PodService { + // 创建Pods + rpc CreatePods(CreatePodsReq) returns (CreatePodsResp) { + option (google.api.http) = { + post : "/apis/pod/createMulti" + body : "*" + }; + } + // 创建Pod rpc CreatePod(CreatePodReq) returns (CreatePodResp) { option (google.api.http) = { diff --git a/lan_trans/idl/demo/demo.pb.gw.go b/lan_trans/idl/demo/demo.pb.gw.go index 66ed1dc..5fedd6b 100644 --- a/lan_trans/idl/demo/demo.pb.gw.go +++ b/lan_trans/idl/demo/demo.pb.gw.go @@ -77,12 +77,13 @@ func RegisterDemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_DemoService_Echo_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_DemoService_Echo_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -139,12 +140,13 @@ func RegisterDemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_DemoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_DemoService_Echo_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/lan_trans/idl/pbecs/ecs.pb.gw.go b/lan_trans/idl/pbecs/ecs.pb.gw.go index 95d6355..425292e 100644 --- a/lan_trans/idl/pbecs/ecs.pb.gw.go +++ b/lan_trans/idl/pbecs/ecs.pb.gw.go @@ -145,12 +145,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail", runtime.WithHTTPPathPattern("/apis/ecs/detail")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_EcsService_ListEcsDetail_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -168,12 +169,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs", runtime.WithHTTPPathPattern("/apis/ecs")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_EcsService_ListEcs_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_EcsService_ListEcs_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -191,12 +193,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll", runtime.WithHTTPPathPattern("/apis/ecs/all")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_EcsService_ListEcsAll_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -253,12 +256,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail", runtime.WithHTTPPathPattern("/apis/ecs/detail")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EcsService_ListEcsDetail_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -273,12 +277,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs", runtime.WithHTTPPathPattern("/apis/ecs")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_EcsService_ListEcs_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EcsService_ListEcs_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -293,12 +298,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll", runtime.WithHTTPPathPattern("/apis/ecs/all")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EcsService_ListEcsAll_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/lan_trans/idl/pbpod/pod.pb.gw.go b/lan_trans/idl/pbpod/pod.pb.gw.go index a688fc7..8aed6f3 100644 --- a/lan_trans/idl/pbpod/pod.pb.gw.go +++ b/lan_trans/idl/pbpod/pod.pb.gw.go @@ -31,6 +31,40 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = metadata.Join +func request_PodService_CreatePods_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreatePodsReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreatePods(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_PodService_CreatePods_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreatePodsReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreatePods(ctx, &protoReq) + return msg, metadata, err + +} + func request_PodService_CreatePod_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq CreatePodReq var metadata runtime.ServerMetadata @@ -229,18 +263,43 @@ func local_request_PodService_ListPodAll_0(ctx context.Context, marshaler runtim // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPodServiceHandlerFromEndpoint instead. func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PodServiceServer) error { + mux.Handle("POST", pattern_PodService_CreatePods_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/CreatePods", runtime.WithHTTPPathPattern("/apis/pod/createMulti")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PodService_CreatePods_0(ctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_CreatePods_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_PodService_CreatePod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/CreatePod") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/CreatePod", runtime.WithHTTPPathPattern("/apis/pod/create")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_PodService_CreatePod_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_PodService_CreatePod_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -258,12 +317,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/DeletePod") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/DeletePod", runtime.WithHTTPPathPattern("/apis/pod/delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_PodService_DeletePod_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_PodService_DeletePod_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -281,12 +341,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/UpdatePod") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/UpdatePod", runtime.WithHTTPPathPattern("/apis/pod/update")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_PodService_UpdatePod_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_PodService_UpdatePod_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -304,12 +365,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail", runtime.WithHTTPPathPattern("/apis/pod/detail")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_PodService_ListPodDetail_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_PodService_ListPodDetail_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -327,12 +389,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPod") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPod", runtime.WithHTTPPathPattern("/apis/pod")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_PodService_ListPod_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_PodService_ListPod_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -350,12 +413,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodAll") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodAll", runtime.WithHTTPPathPattern("/apis/pod/all")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_PodService_ListPodAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_PodService_ListPodAll_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -408,16 +472,38 @@ func RegisterPodServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn // "PodServiceClient" to call the correct interceptors. func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PodServiceClient) error { - mux.Handle("POST", pattern_PodService_CreatePod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_PodService_CreatePods_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/CreatePod") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/CreatePods", runtime.WithHTTPPathPattern("/apis/pod/createMulti")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_PodService_CreatePod_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_PodService_CreatePods_0(ctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_CreatePods_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_PodService_CreatePod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/CreatePod", runtime.WithHTTPPathPattern("/apis/pod/create")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PodService_CreatePod_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -432,12 +518,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/DeletePod") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/DeletePod", runtime.WithHTTPPathPattern("/apis/pod/delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_PodService_DeletePod_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_PodService_DeletePod_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -452,12 +539,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/UpdatePod") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/UpdatePod", runtime.WithHTTPPathPattern("/apis/pod/update")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_PodService_UpdatePod_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_PodService_UpdatePod_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -472,12 +560,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail", runtime.WithHTTPPathPattern("/apis/pod/detail")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_PodService_ListPodDetail_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_PodService_ListPodDetail_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -492,12 +581,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPod") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPod", runtime.WithHTTPPathPattern("/apis/pod")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_PodService_ListPod_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_PodService_ListPod_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -512,12 +602,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodAll") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodAll", runtime.WithHTTPPathPattern("/apis/pod/all")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_PodService_ListPodAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_PodService_ListPodAll_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -532,6 +623,8 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, } var ( + pattern_PodService_CreatePods_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "createMulti"}, "")) + pattern_PodService_CreatePod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "create"}, "")) pattern_PodService_DeletePod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "delete"}, "")) @@ -546,6 +639,8 @@ var ( ) var ( + forward_PodService_CreatePods_0 = runtime.ForwardResponseMessage + forward_PodService_CreatePod_0 = runtime.ForwardResponseMessage forward_PodService_DeletePod_0 = runtime.ForwardResponseMessage diff --git a/lan_trans/idl/pbpod/pod_grpc.pb.go b/lan_trans/idl/pbpod/pod_grpc.pb.go index 1e74f9b..dd11b5b 100644 --- a/lan_trans/idl/pbpod/pod_grpc.pb.go +++ b/lan_trans/idl/pbpod/pod_grpc.pb.go @@ -22,6 +22,8 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type PodServiceClient interface { + // 创建Pods + CreatePods(ctx context.Context, in *CreatePodsReq, opts ...grpc.CallOption) (*CreatePodsResp, error) // 创建Pod CreatePod(ctx context.Context, in *CreatePodReq, opts ...grpc.CallOption) (*CreatePodResp, error) // 删除Pod @@ -44,6 +46,15 @@ func NewPodServiceClient(cc grpc.ClientConnInterface) PodServiceClient { return &podServiceClient{cc} } +func (c *podServiceClient) CreatePods(ctx context.Context, in *CreatePodsReq, opts ...grpc.CallOption) (*CreatePodsResp, error) { + out := new(CreatePodsResp) + err := c.cc.Invoke(ctx, "/pbpod.PodService/CreatePods", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *podServiceClient) CreatePod(ctx context.Context, in *CreatePodReq, opts ...grpc.CallOption) (*CreatePodResp, error) { out := new(CreatePodResp) err := c.cc.Invoke(ctx, "/pbpod.PodService/CreatePod", in, out, opts...) @@ -102,6 +113,8 @@ func (c *podServiceClient) ListPodAll(ctx context.Context, in *ListPodAllReq, op // All implementations must embed UnimplementedPodServiceServer // for forward compatibility type PodServiceServer interface { + // 创建Pods + CreatePods(context.Context, *CreatePodsReq) (*CreatePodsResp, error) // 创建Pod CreatePod(context.Context, *CreatePodReq) (*CreatePodResp, error) // 删除Pod @@ -121,6 +134,9 @@ type PodServiceServer interface { type UnimplementedPodServiceServer struct { } +func (UnimplementedPodServiceServer) CreatePods(context.Context, *CreatePodsReq) (*CreatePodsResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePods not implemented") +} func (UnimplementedPodServiceServer) CreatePod(context.Context, *CreatePodReq) (*CreatePodResp, error) { return nil, status.Errorf(codes.Unimplemented, "method CreatePod not implemented") } @@ -152,6 +168,24 @@ func RegisterPodServiceServer(s grpc.ServiceRegistrar, srv PodServiceServer) { s.RegisterService(&PodService_ServiceDesc, srv) } +func _PodService_CreatePods_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePodsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PodServiceServer).CreatePods(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbpod.PodService/CreatePods", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PodServiceServer).CreatePods(ctx, req.(*CreatePodsReq)) + } + return interceptor(ctx, in, info, handler) +} + func _PodService_CreatePod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(CreatePodReq) if err := dec(in); err != nil { @@ -267,6 +301,10 @@ var PodService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "pbpod.PodService", HandlerType: (*PodServiceServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "CreatePods", + Handler: _PodService_CreatePods_Handler, + }, { MethodName: "CreatePod", Handler: _PodService_CreatePod_Handler, diff --git a/lan_trans/openapiv2/idl/demo/demo.swagger.json b/lan_trans/openapiv2/idl/demo/demo.swagger.json index a969e31..d7db3be 100644 --- a/lan_trans/openapiv2/idl/demo/demo.swagger.json +++ b/lan_trans/openapiv2/idl/demo/demo.swagger.json @@ -68,14 +68,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json b/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json index cba0d0e..017208a 100644 --- a/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json +++ b/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json @@ -303,14 +303,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/lan_trans/openapiv2/idl/pbpod/pod.swagger.json b/lan_trans/openapiv2/idl/pbpod/pod.swagger.json index 56b3588..8ca8800 100644 --- a/lan_trans/openapiv2/idl/pbpod/pod.swagger.json +++ b/lan_trans/openapiv2/idl/pbpod/pod.swagger.json @@ -37,7 +37,7 @@ "parameters": [ { "name": "provider", - "description": "云名称.\n\n - ali: 0 - 阿里云\n - tencent: 1 - 腾讯云 腾讯EK目前转内测,接口无法调用,暂时搁置\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", + "description": "云名称\n\n - ali: 0 - 阿里云\n - tencent: 1 - 腾讯云 腾讯EK目前转内测,接口无法调用,暂时搁置\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", "in": "query", "required": false, "type": "string", @@ -111,6 +111,39 @@ ] } }, + "/apis/pod/createMulti": { + "post": { + "summary": "创建Pods", + "operationId": "PodService_CreatePods", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbpodCreatePodsResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbpodCreatePodsReq" + } + } + ], + "tags": [ + "PodService" + ] + } + }, "/apis/pod/delete": { "post": { "summary": "删除Pod", @@ -165,7 +198,7 @@ "parameters": [ { "name": "provider", - "description": "云名称.\n\n - ali: 0 - 阿里云\n - tencent: 1 - 腾讯云 腾讯EK目前转内测,接口无法调用,暂时搁置\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", + "description": "云名称\n\n - ali: 0 - 阿里云\n - tencent: 1 - 腾讯云 腾讯EK目前转内测,接口无法调用,暂时搁置\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", "in": "query", "required": false, "type": "string", @@ -179,14 +212,14 @@ }, { "name": "accountName", - "description": "账户名称,根据config.yaml中的配置,默认为第一个配置的账户.", + "description": "账户名称,根据config.yaml中的配置,默认为第一个配置的账户", "in": "query", "required": false, "type": "string" }, { "name": "regionId", - "description": "区域Id,参考 tenant.proto 中的各个云的区域.", + "description": "区域Id,参考 tenant.proto 中的各个云的区域", "in": "query", "required": false, "type": "integer", @@ -194,7 +227,7 @@ }, { "name": "regionName", - "description": "区域名称,各云厂商自定义的region name.", + "description": "区域名称,各云厂商自定义的region name", "in": "query", "required": false, "type": "integer", @@ -202,7 +235,7 @@ }, { "name": "podId", - "description": "podID.", + "description": "podID", "in": "query", "required": false, "type": "integer", @@ -210,7 +243,7 @@ }, { "name": "pageNumber", - "description": "分页相关参数,页码.", + "description": "分页相关参数,页码", "in": "query", "required": false, "type": "integer", @@ -218,7 +251,7 @@ }, { "name": "pageSize", - "description": "分页相关参数,每页数量.", + "description": "分页相关参数,每页数量", "in": "query", "required": false, "type": "integer", @@ -226,14 +259,14 @@ }, { "name": "nextToken", - "description": "分页相关参数,下一页的token.", + "description": "分页相关参数,下一页的token", "in": "query", "required": false, "type": "string" }, { "name": "namespace", - "description": "namespace.", + "description": "namespace", "in": "query", "required": false, "type": "string" @@ -357,6 +390,41 @@ } } }, + "pbpodCreatePodsReq": { + "type": "object", + "properties": { + "createPodReq": { + "type": "array", + "items": { + "$ref": "#/definitions/pbpodCreatePodReq" + }, + "title": "云类型" + } + } + }, + "pbpodCreatePodsResp": { + "type": "object", + "properties": { + "pods": { + "type": "array", + "items": { + "$ref": "#/definitions/pbpodPodInstance" + }, + "title": "Pod集合" + }, + "finished": { + "type": "boolean", + "title": "查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询" + }, + "requestId": { + "type": "array", + "items": { + "type": "string" + }, + "title": "请求id,出现问题后提供给云厂商,排查问题" + } + } + }, "pbpodDeletePodReq": { "type": "object", "properties": { @@ -605,14 +673,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json b/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json index 636ce73..0a73b35 100644 --- a/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json +++ b/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json @@ -15,14 +15,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object",