diff --git a/api/cron_workflow.pb.go b/api/cron_workflow.pb.go index 9f52860..4da51e0 100644 --- a/api/cron_workflow.pb.go +++ b/api/cron_workflow.pb.go @@ -120,6 +120,132 @@ func (m *CreateCronWorkflowRequest) GetCronWorkflow() *CronWorkflow { return nil } +type ListCronWorkflowRequest struct { + Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` + PageSize int32 `protobuf:"varint,4,opt,name=pageSize,proto3" json:"pageSize,omitempty"` + Page int32 `protobuf:"varint,5,opt,name=page,proto3" json:"page,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListCronWorkflowRequest) Reset() { *m = ListCronWorkflowRequest{} } +func (m *ListCronWorkflowRequest) String() string { return proto.CompactTextString(m) } +func (*ListCronWorkflowRequest) ProtoMessage() {} +func (*ListCronWorkflowRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_989cccaad551a50c, []int{2} +} + +func (m *ListCronWorkflowRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListCronWorkflowRequest.Unmarshal(m, b) +} +func (m *ListCronWorkflowRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListCronWorkflowRequest.Marshal(b, m, deterministic) +} +func (m *ListCronWorkflowRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListCronWorkflowRequest.Merge(m, src) +} +func (m *ListCronWorkflowRequest) XXX_Size() int { + return xxx_messageInfo_ListCronWorkflowRequest.Size(m) +} +func (m *ListCronWorkflowRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListCronWorkflowRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListCronWorkflowRequest proto.InternalMessageInfo + +func (m *ListCronWorkflowRequest) GetNamespace() string { + if m != nil { + return m.Namespace + } + return "" +} + +func (m *ListCronWorkflowRequest) GetPageSize() int32 { + if m != nil { + return m.PageSize + } + return 0 +} + +func (m *ListCronWorkflowRequest) GetPage() int32 { + if m != nil { + return m.Page + } + return 0 +} + +type ListCronWorkflowsResponse struct { + Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` + CronWorkflows []*CronWorkflow `protobuf:"bytes,2,rep,name=cronWorkflows,proto3" json:"cronWorkflows,omitempty"` + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + Pages int32 `protobuf:"varint,4,opt,name=pages,proto3" json:"pages,omitempty"` + TotalCount int32 `protobuf:"varint,5,opt,name=totalCount,proto3" json:"totalCount,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListCronWorkflowsResponse) Reset() { *m = ListCronWorkflowsResponse{} } +func (m *ListCronWorkflowsResponse) String() string { return proto.CompactTextString(m) } +func (*ListCronWorkflowsResponse) ProtoMessage() {} +func (*ListCronWorkflowsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_989cccaad551a50c, []int{3} +} + +func (m *ListCronWorkflowsResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListCronWorkflowsResponse.Unmarshal(m, b) +} +func (m *ListCronWorkflowsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListCronWorkflowsResponse.Marshal(b, m, deterministic) +} +func (m *ListCronWorkflowsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListCronWorkflowsResponse.Merge(m, src) +} +func (m *ListCronWorkflowsResponse) XXX_Size() int { + return xxx_messageInfo_ListCronWorkflowsResponse.Size(m) +} +func (m *ListCronWorkflowsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListCronWorkflowsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListCronWorkflowsResponse proto.InternalMessageInfo + +func (m *ListCronWorkflowsResponse) GetCount() int32 { + if m != nil { + return m.Count + } + return 0 +} + +func (m *ListCronWorkflowsResponse) GetCronWorkflows() []*CronWorkflow { + if m != nil { + return m.CronWorkflows + } + return nil +} + +func (m *ListCronWorkflowsResponse) GetPage() int32 { + if m != nil { + return m.Page + } + return 0 +} + +func (m *ListCronWorkflowsResponse) GetPages() int32 { + if m != nil { + return m.Pages + } + return 0 +} + +func (m *ListCronWorkflowsResponse) GetTotalCount() int32 { + if m != nil { + return m.TotalCount + } + return 0 +} + type CronWorkflow struct { Schedule string `protobuf:"bytes,1,opt,name=schedule,proto3" json:"schedule,omitempty"` Timezone string `protobuf:"bytes,2,opt,name=timezone,proto3" json:"timezone,omitempty"` @@ -138,7 +264,7 @@ func (m *CronWorkflow) Reset() { *m = CronWorkflow{} } func (m *CronWorkflow) String() string { return proto.CompactTextString(m) } func (*CronWorkflow) ProtoMessage() {} func (*CronWorkflow) Descriptor() ([]byte, []int) { - return fileDescriptor_989cccaad551a50c, []int{2} + return fileDescriptor_989cccaad551a50c, []int{4} } func (m *CronWorkflow) XXX_Unmarshal(b []byte) error { @@ -218,6 +344,8 @@ func (m *CronWorkflow) GetWorkflowExecution() *WorkflowExecution { func init() { proto.RegisterType((*GetCronWorkflowRequest)(nil), "api.GetCronWorkflowRequest") proto.RegisterType((*CreateCronWorkflowRequest)(nil), "api.CreateCronWorkflowRequest") + proto.RegisterType((*ListCronWorkflowRequest)(nil), "api.ListCronWorkflowRequest") + proto.RegisterType((*ListCronWorkflowsResponse)(nil), "api.ListCronWorkflowsResponse") proto.RegisterType((*CronWorkflow)(nil), "api.CronWorkflow") } @@ -226,37 +354,45 @@ func init() { } var fileDescriptor_989cccaad551a50c = []byte{ - // 478 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc7, 0xe5, 0xa4, 0x1f, 0xe9, 0x12, 0x81, 0x32, 0x95, 0x52, 0xe3, 0x56, 0x28, 0xf2, 0x85, - 0x1c, 0x50, 0x4c, 0x8b, 0x28, 0x08, 0x09, 0x2e, 0x2d, 0x02, 0x55, 0x1c, 0x90, 0x7b, 0xe8, 0xb1, - 0xda, 0xac, 0x27, 0x61, 0x85, 0xbd, 0xbb, 0xec, 0xae, 0x5b, 0x0c, 0xea, 0x85, 0x43, 0x5f, 0x80, - 0x13, 0xcf, 0xc5, 0x2b, 0xf0, 0x20, 0x28, 0x1b, 0x3b, 0xc4, 0x75, 0x83, 0xe0, 0xe6, 0xbf, 0x7f, - 0xf3, 0xa5, 0x9d, 0xff, 0x90, 0x6d, 0xa6, 0xa5, 0x38, 0xbf, 0x94, 0xfa, 0xe3, 0x24, 0x95, 0x97, - 0x23, 0xa5, 0xa5, 0x95, 0xd0, 0xa6, 0x8a, 0x07, 0x7b, 0x53, 0x29, 0xa7, 0x29, 0x46, 0x54, 0xf1, - 0x88, 0x0a, 0x21, 0x2d, 0xb5, 0x5c, 0x0a, 0x33, 0x0f, 0x09, 0x76, 0x4b, 0xea, 0xd4, 0x38, 0x9f, - 0x44, 0x98, 0x29, 0x5b, 0x94, 0x70, 0xa7, 0xaa, 0x77, 0x6e, 0x31, 0x53, 0x29, 0xb5, 0x58, 0x82, - 0xbb, 0xf5, 0x46, 0x41, 0x37, 0x43, 0xab, 0x39, 0x9b, 0xab, 0xf0, 0x84, 0xf4, 0xdf, 0xa0, 0x3d, - 0xd2, 0x52, 0x9c, 0x95, 0x61, 0x31, 0x7e, 0xca, 0xd1, 0x58, 0xd8, 0x23, 0x5b, 0x82, 0x66, 0x68, - 0x14, 0x65, 0xe8, 0x7b, 0x03, 0x6f, 0xb8, 0x15, 0xff, 0xf9, 0x01, 0x40, 0xd6, 0x66, 0xc2, 0x6f, - 0x39, 0xe0, 0xbe, 0x43, 0x45, 0xee, 0x1f, 0x69, 0xa4, 0x16, 0xff, 0xbf, 0xdc, 0x53, 0xd2, 0x65, - 0x4b, 0x49, 0xae, 0xec, 0x9d, 0x83, 0xde, 0x88, 0x2a, 0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0x59, - 0x82, 0xe6, 0xe2, 0xc3, 0x97, 0xdf, 0x7e, 0xfe, 0xfa, 0xde, 0x7a, 0x16, 0x3e, 0x9c, 0x1d, 0x87, - 0x89, 0x2e, 0xf6, 0xc7, 0x68, 0xe9, 0x7e, 0xf4, 0x75, 0xe1, 0xa1, 0xab, 0xa8, 0x76, 0x56, 0x2f, - 0x6a, 0x4e, 0x81, 0x82, 0xdc, 0xbb, 0xe1, 0x73, 0xd8, 0x75, 0x4d, 0x6e, 0x77, 0xff, 0x6d, 0x13, - 0x1c, 0xba, 0x09, 0x1e, 0xc3, 0xe8, 0x1f, 0x27, 0x98, 0x93, 0xab, 0xf1, 0x86, 0xbb, 0xb4, 0x27, - 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x22, 0xa8, 0xb9, 0xf7, 0x03, 0x00, 0x00, + // 601 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xdd, 0x6e, 0xd3, 0x30, + 0x18, 0x55, 0x96, 0x75, 0x3f, 0x1f, 0x03, 0x54, 0x0f, 0x6d, 0x59, 0x36, 0x4d, 0x53, 0x6e, 0x98, + 0x10, 0x6a, 0xb6, 0x21, 0x36, 0x84, 0x04, 0x37, 0x1d, 0x02, 0x4d, 0xbb, 0x40, 0xe9, 0xc5, 0x2e, + 0x27, 0xd7, 0xfd, 0x5a, 0x2c, 0x12, 0x3b, 0xc4, 0xce, 0x46, 0x87, 0x76, 0x03, 0xd2, 0x5e, 0x80, + 0x07, 0xe0, 0x25, 0x78, 0x13, 0x5e, 0x81, 0x07, 0x41, 0x71, 0xd2, 0xac, 0x69, 0x5a, 0x34, 0xb8, + 0x8a, 0x8f, 0xcf, 0x67, 0x9f, 0xe3, 0xd8, 0xe7, 0x83, 0x55, 0x96, 0x48, 0x71, 0x7e, 0x29, 0x93, + 0x8f, 0xfd, 0x50, 0x5e, 0xb6, 0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0xcf, 0x26, 0xd9, 0xa0, 0xbe, 0xe0, 0xe0, 0x87, 0x0d, 0xab, 0xe3, 0x17, 0xd1, 0xc1, + 0xe4, 0x82, 0x33, 0x24, 0x37, 0x16, 0x90, 0x7a, 0x66, 0xc8, 0x76, 0xf1, 0x46, 0x66, 0x84, 0xc9, + 0xad, 0xbf, 0x21, 0xef, 0xd5, 0xd7, 0x5f, 0xbf, 0xbf, 0xcf, 0x1d, 0x79, 0x8f, 0xb3, 0xe6, 0xa1, + 0xfc, 0x8b, 0xfd, 0x2e, 0x6a, 0xba, 0xef, 0x7f, 0x29, 0xdf, 0xfc, 0xb5, 0x5f, 0x69, 0x3b, 0x2f, + 0x2b, 0x49, 0x22, 0x43, 0x78, 0x38, 0xd1, 0x07, 0xc8, 0xa6, 0x11, 0x99, 0xde, 0x1d, 0xa6, 0x39, + 0x38, 0x34, 0x0e, 0xf6, 0x48, 0xeb, 0x8e, 0x0e, 0x72, 0xe6, 0x9a, 0x7c, 0xb3, 0xa0, 0x59, 0xcb, + 0x16, 0xd9, 0x32, 0x02, 0x33, 0xd2, 0xed, 0x6e, 0x4f, 0x65, 0xcb, 0x44, 0x7a, 0x7b, 0xc6, 0xcb, + 0x13, 0xb2, 0x7b, 0x47, 0x2f, 0xaa, 0xbb, 0x60, 0xfa, 0xe1, 0xb3, 0x3f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xea, 0x3f, 0xb3, 0x0d, 0x9d, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -273,6 +409,7 @@ const _ = grpc.SupportPackageIsVersion6 type CronWorkflowServiceClient interface { CreateCronWorkflow(ctx context.Context, in *CreateCronWorkflowRequest, opts ...grpc.CallOption) (*CronWorkflow, error) GetCronWorkflow(ctx context.Context, in *GetCronWorkflowRequest, opts ...grpc.CallOption) (*CronWorkflow, error) + ListCronWorkflows(ctx context.Context, in *ListCronWorkflowRequest, opts ...grpc.CallOption) (*ListCronWorkflowsResponse, error) } type cronWorkflowServiceClient struct { @@ -301,10 +438,20 @@ func (c *cronWorkflowServiceClient) GetCronWorkflow(ctx context.Context, in *Get return out, nil } +func (c *cronWorkflowServiceClient) ListCronWorkflows(ctx context.Context, in *ListCronWorkflowRequest, opts ...grpc.CallOption) (*ListCronWorkflowsResponse, error) { + out := new(ListCronWorkflowsResponse) + err := c.cc.Invoke(ctx, "/api.CronWorkflowService/ListCronWorkflows", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // CronWorkflowServiceServer is the server API for CronWorkflowService service. type CronWorkflowServiceServer interface { CreateCronWorkflow(context.Context, *CreateCronWorkflowRequest) (*CronWorkflow, error) GetCronWorkflow(context.Context, *GetCronWorkflowRequest) (*CronWorkflow, error) + ListCronWorkflows(context.Context, *ListCronWorkflowRequest) (*ListCronWorkflowsResponse, error) } // UnimplementedCronWorkflowServiceServer can be embedded to have forward compatible implementations. @@ -317,6 +464,9 @@ func (*UnimplementedCronWorkflowServiceServer) CreateCronWorkflow(ctx context.Co func (*UnimplementedCronWorkflowServiceServer) GetCronWorkflow(ctx context.Context, req *GetCronWorkflowRequest) (*CronWorkflow, error) { return nil, status.Errorf(codes.Unimplemented, "method GetCronWorkflow not implemented") } +func (*UnimplementedCronWorkflowServiceServer) ListCronWorkflows(ctx context.Context, req *ListCronWorkflowRequest) (*ListCronWorkflowsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListCronWorkflows not implemented") +} func RegisterCronWorkflowServiceServer(s *grpc.Server, srv CronWorkflowServiceServer) { s.RegisterService(&_CronWorkflowService_serviceDesc, srv) @@ -358,6 +508,24 @@ func _CronWorkflowService_GetCronWorkflow_Handler(srv interface{}, ctx context.C return interceptor(ctx, in, info, handler) } +func _CronWorkflowService_ListCronWorkflows_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListCronWorkflowRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CronWorkflowServiceServer).ListCronWorkflows(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.CronWorkflowService/ListCronWorkflows", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CronWorkflowServiceServer).ListCronWorkflows(ctx, req.(*ListCronWorkflowRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _CronWorkflowService_serviceDesc = grpc.ServiceDesc{ ServiceName: "api.CronWorkflowService", HandlerType: (*CronWorkflowServiceServer)(nil), @@ -370,6 +538,10 @@ var _CronWorkflowService_serviceDesc = grpc.ServiceDesc{ MethodName: "GetCronWorkflow", Handler: _CronWorkflowService_GetCronWorkflow_Handler, }, + { + MethodName: "ListCronWorkflows", + Handler: _CronWorkflowService_ListCronWorkflows_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cron_workflow.proto", diff --git a/api/cron_workflow.pb.gw.go b/api/cron_workflow.pb.gw.go index 112c994..432fe26 100644 --- a/api/cron_workflow.pb.gw.go +++ b/api/cron_workflow.pb.gw.go @@ -177,6 +177,75 @@ func local_request_CronWorkflowService_GetCronWorkflow_0(ctx context.Context, ma } +var ( + filter_CronWorkflowService_ListCronWorkflows_0 = &utilities.DoubleArray{Encoding: map[string]int{"namespace": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_CronWorkflowService_ListCronWorkflows_0(ctx context.Context, marshaler runtime.Marshaler, client CronWorkflowServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListCronWorkflowRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace") + } + + protoReq.Namespace, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CronWorkflowService_ListCronWorkflows_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListCronWorkflows(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_CronWorkflowService_ListCronWorkflows_0(ctx context.Context, marshaler runtime.Marshaler, server CronWorkflowServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListCronWorkflowRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace") + } + + protoReq.Namespace, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_CronWorkflowService_ListCronWorkflows_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListCronWorkflows(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterCronWorkflowServiceHandlerServer registers the http handlers for service CronWorkflowService to "mux". // UnaryRPC :call CronWorkflowServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -222,6 +291,26 @@ func RegisterCronWorkflowServiceHandlerServer(ctx context.Context, mux *runtime. }) + mux.Handle("GET", pattern_CronWorkflowService_ListCronWorkflows_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_CronWorkflowService_ListCronWorkflows_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_CronWorkflowService_ListCronWorkflows_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -303,6 +392,26 @@ func RegisterCronWorkflowServiceHandlerClient(ctx context.Context, mux *runtime. }) + mux.Handle("GET", pattern_CronWorkflowService_ListCronWorkflows_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) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_CronWorkflowService_ListCronWorkflows_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_CronWorkflowService_ListCronWorkflows_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -310,10 +419,14 @@ var ( pattern_CronWorkflowService_CreateCronWorkflow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"apis", "v1beta1", "namespace", "cron_workflow"}, "", runtime.AssumeColonVerbOpt(true))) pattern_CronWorkflowService_GetCronWorkflow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"apis", "v1beta1", "namespace", "cron_workflow", "name"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_CronWorkflowService_ListCronWorkflows_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"apis", "v1beta1", "namespace", "cron_workflows"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_CronWorkflowService_CreateCronWorkflow_0 = runtime.ForwardResponseMessage forward_CronWorkflowService_GetCronWorkflow_0 = runtime.ForwardResponseMessage + + forward_CronWorkflowService_ListCronWorkflows_0 = runtime.ForwardResponseMessage ) diff --git a/api/cron_workflow.proto b/api/cron_workflow.proto index 538efca..9f1b598 100644 --- a/api/cron_workflow.proto +++ b/api/cron_workflow.proto @@ -21,6 +21,12 @@ service CronWorkflowService { get: "/apis/v1beta1/{namespace}/cron_workflow/{name}" }; } + + rpc ListCronWorkflows(ListCronWorkflowRequest) returns (ListCronWorkflowsResponse) { + option (google.api.http) = { + get: "/apis/v1beta1/{namespace}/cron_workflows" + }; + } } message GetCronWorkflowRequest { @@ -33,6 +39,21 @@ message CreateCronWorkflowRequest { CronWorkflow cronWorkflow = 2; } +message ListCronWorkflowRequest { + string namespace = 1; + int32 pageSize = 4; + int32 page = 5; +} + +message ListCronWorkflowsResponse { + int32 count = 1; + repeated CronWorkflow cronWorkflows = 2; + int32 page = 3; + int32 pages = 4; + int32 totalCount = 5; +} + + message CronWorkflow { string schedule = 1; string timezone = 2; diff --git a/pkg/cron_workflow.go b/pkg/cron_workflow.go index 2df7bb6..b36c116 100644 --- a/pkg/cron_workflow.go +++ b/pkg/cron_workflow.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc/codes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "regexp" + "sort" "strings" ) @@ -113,6 +114,41 @@ func (c *Client) GetCronWorkflow(namespace, name string) (cronWorkflow *CronWork return } +func (c *Client) ListCronWorkflows(namespace string) (cronWorkflows []*CronWorkflow, err error) { + cronWorkflowList, err := c.ArgoprojV1alpha1().CronWorkflows(namespace).List(ListOptions{}) + if err != nil { + log.WithFields(log.Fields{ + "Namespace": namespace, + "Error": err.Error(), + }).Error("CronWorkflows not found.") + return nil, util.NewUserError(codes.NotFound, "CronWorkflows not found.") + } + cwfs := cronWorkflowList.Items + sort.Slice(cwfs, func(i, j int) bool { + ith := cwfs[i].CreationTimestamp.Time + jth := cwfs[j].CreationTimestamp.Time + //Most recent first + return ith.After(jth) + }) + + for _, cwf := range cwfs { + cronWorkflows = append(cronWorkflows, &CronWorkflow{ + CreatedAt: cwf.CreationTimestamp.UTC(), + UID: string(cwf.ObjectMeta.UID), + Name: cwf.Name, + Schedule: cwf.Spec.Schedule, + Timezone: cwf.Spec.Timezone, + Suspend: cwf.Spec.Suspend, + ConcurrencyPolicy: string(cwf.Spec.ConcurrencyPolicy), + StartingDeadlineSeconds: cwf.Spec.StartingDeadlineSeconds, + SuccessfulJobsHistoryLimit: cwf.Spec.SuccessfulJobsHistoryLimit, + FailedJobsHistoryLimit: cwf.Spec.FailedJobsHistoryLimit, + WorkflowExecution: nil, + }) + } + return +} + func (c *Client) createCronWorkflow(namespace string, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (createdCronWorkflow *wfv1.CronWorkflow, err error) { if opts == nil { opts = &WorkflowExecutionOptions{} diff --git a/server/cron_workflow_server.go b/server/cron_workflow_server.go index 90a0c1d..47e4f03 100644 --- a/server/cron_workflow_server.go +++ b/server/cron_workflow_server.go @@ -6,6 +6,7 @@ import ( v1 "github.com/onepanelio/core/pkg" "github.com/onepanelio/core/pkg/util/ptr" "github.com/onepanelio/core/server/auth" + "math" ) type CronWorkflowServer struct{} @@ -94,3 +95,47 @@ func (c *CronWorkflowServer) GetCronWorkflow(ctx context.Context, req *api.GetCr } return apiCronWorkflow(cwf), nil } + +func (c *CronWorkflowServer) ListCronWorkflows(ctx context.Context, req *api.ListCronWorkflowRequest) (*api.ListCronWorkflowsResponse, error) { + client := ctx.Value("kubeClient").(*v1.Client) + allowed, err := auth.IsAuthorized(client, req.Namespace, "list", "argoproj.io", "cronworkflows", "") + if err != nil || !allowed { + return nil, err + } + + if req.PageSize <= 0 { + req.PageSize = 15 + } + + cronWorkflows, err := client.ListCronWorkflows(req.Namespace) + if err != nil { + return nil, err + } + var apiCronWorkflows []*api.CronWorkflow + for _, cwf := range cronWorkflows { + apiCronWorkflows = append(apiCronWorkflows, apiCronWorkflow(cwf)) + } + + pages := int32(math.Ceil(float64(len(apiCronWorkflows)) / float64(req.PageSize))) + if req.Page > pages { + req.Page = pages + } + + if req.Page <= 0 { + req.Page = 1 + } + + start := (req.Page - 1) * req.PageSize + end := start + req.PageSize + if end >= int32(len(apiCronWorkflows)) { + end = int32(len(apiCronWorkflows)) + } + + return &api.ListCronWorkflowsResponse{ + Count: end - start, + CronWorkflows: apiCronWorkflows[start:end], + Page: req.Page, + Pages: pages, + TotalCount: int32(len(apiCronWorkflows)), + }, nil +}