From 365ea3d3a0ae5b3ca990215329857622c7072f16 Mon Sep 17 00:00:00 2001 From: jlandowner Date: Thu, 3 Aug 2023 02:13:12 +0900 Subject: [PATCH] Add use-role-filter option on dashboard GetxTemplate API --- .../__snapshots__/template_handler_test.snap | 97 ++++++- internal/dashboard/auth_middleware.go | 15 + internal/dashboard/template_handler.go | 18 +- internal/dashboard/template_handler_test.go | 53 ++-- pkg/kosmo/template.go | 10 +- pkg/kosmo/template_test.go | 2 +- pkg/kosmo/test/test_util.go | 22 ++ .../template_service.connect.go | 25 +- .../dashboard/v1alpha1/template_service.pb.go | 263 +++++++++++++----- .../v1alpha1/template_service.pb.validate.go | 214 ++++++++++++++ proto/gen/index.md | 36 ++- .../dashboard/v1alpha1/template_service.proto | 12 +- .../v1alpha1/template_service_connectweb.ts | 8 +- .../dashboard/v1alpha1/template_service_pb.ts | 74 +++++ .../organisms/UserAddonsChangeDialog.tsx | 2 +- .../src/views/organisms/UserModule.tsx | 10 +- .../src/views/organisms/WorkspaceModule.tsx | 2 +- 17 files changed, 732 insertions(+), 131 deletions(-) diff --git a/internal/dashboard/__snapshots__/template_handler_test.snap b/internal/dashboard/__snapshots__/template_handler_test.snap index c9e80bf7..5738e87a 100644 --- a/internal/dashboard/__snapshots__/template_handler_test.snap +++ b/internal/dashboard/__snapshots__/template_handler_test.snap @@ -1,11 +1,11 @@ -['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: admin-user, empty 1'] +['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: admin-user, empty, 1'] SnapShot = """ { \"message\": \"No items found\" } """ -['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: admin-user, not empty 1'] +['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: admin-user, not empty, 1'] SnapShot = """ { \"items\": [ @@ -41,14 +41,14 @@ SnapShot = """ } """ -['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: normal-user, empty 1'] +['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: normal-user, empty, 1'] SnapShot = """ { \"message\": \"No items found\" } """ -['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: normal-user, not empty 1'] +['Dashboard server [Template] [GetUserAddonTemplates] ✅ success in normal context: Entry: normal-user, not empty, 1'] SnapShot = """ { \"items\": [ @@ -84,17 +84,17 @@ SnapShot = """ } """ -['Dashboard server [Template] [GetUserAddonTemplates] ❌ fail with an unexpected error at list: Entry: admin-user, not empty 1'] +['Dashboard server [Template] [GetUserAddonTemplates] ❌ fail with an unexpected error at list: Entry: admin-user, not empty, 1'] SnapShot = 'internal: failed to list UserAddon Templates' -['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: admin-user, empty 1'] +['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: admin-user, empty, 1'] SnapShot = """ { \"message\": \"No items found\" } """ -['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: admin-user, not empty 1'] +['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: admin-user, not empty, 1'] SnapShot = """ { \"items\": [ @@ -123,19 +123,93 @@ SnapShot = """ \"default_value\": \"FUGAfuga\" } ] + }, + { + \"name\": \"template3\" } ] } """ -['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: normal-user, empty 1'] +['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: normal-user, empty, 1'] SnapShot = """ { \"message\": \"No items found\" } """ -['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: normal-user, not empty 1'] +['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: normal-user, not empty, 1'] +SnapShot = """ +{ + \"items\": [ + { + \"name\": \"template1\", + \"required_vars\": [ + { + \"var_name\": \"{{HOGE}}\", + \"default_value\": \"HOGEhoge\" + }, + { + \"var_name\": \"{{FUGA}}\", + \"default_value\": \"FUGAfuga\" + } + ] + }, + { + \"name\": \"template2\", + \"required_vars\": [ + { + \"var_name\": \"{{HOGE}}\", + \"default_value\": \"HOGEhoge\" + }, + { + \"var_name\": \"{{FUGA}}\", + \"default_value\": \"FUGAfuga\" + } + ] + }, + { + \"name\": \"template3\" + } + ] +} +""" + +['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: normal-user, not empty, use_role_filter:true 1'] +SnapShot = """ +{ + \"items\": [ + { + \"name\": \"template1\", + \"required_vars\": [ + { + \"var_name\": \"{{HOGE}}\", + \"default_value\": \"HOGEhoge\" + }, + { + \"var_name\": \"{{FUGA}}\", + \"default_value\": \"FUGAfuga\" + } + ] + }, + { + \"name\": \"template2\", + \"required_vars\": [ + { + \"var_name\": \"{{HOGE}}\", + \"default_value\": \"HOGEhoge\" + }, + { + \"var_name\": \"{{FUGA}}\", + \"default_value\": \"FUGAfuga\" + } + ] + } + ] +} +""" + +['Dashboard server [Template] [GetWorkspaceTemplates] ✅ success in normal context: Entry: role-user, not empty, 1'] SnapShot = """ { \"items\": [ @@ -164,10 +238,13 @@ SnapShot = """ \"default_value\": \"FUGAfuga\" } ] + }, + { + \"name\": \"template3\" } ] } """ -['Dashboard server [Template] [GetWorkspaceTemplates] ❌ fail with an unexpected error at list: Entry: admin-user, not empty 1'] +['Dashboard server [Template] [GetWorkspaceTemplates] ❌ fail with an unexpected error at list: Entry: admin-user, not empty, 1'] SnapShot = 'internal: failed to list WorkspaceTemplates' diff --git a/internal/dashboard/auth_middleware.go b/internal/dashboard/auth_middleware.go index 710fe66c..7516e745 100644 --- a/internal/dashboard/auth_middleware.go +++ b/internal/dashboard/auth_middleware.go @@ -198,6 +198,21 @@ func validateCallerHasAdminForAllRoles(tryRoleNames []string) func(map[string]st } } +func validateCallerHasAdminForAtLeastOneRole(tryRoleNames []cosmov1alpha1.UserRole) func(map[string]string) error { + return func(callerGroupRoleMap map[string]string) error { + for _, r := range tryRoleNames { + tryAccessGroup, _ := r.GetGroupAndRole() + callerRoleForTriedGroup := callerGroupRoleMap[tryAccessGroup] + + // Allow if caller has at least one administrative privilege for tried group. + if callerRoleForTriedGroup == cosmov1alpha1.AdminRoleName { + return nil + } + } + return fmt.Errorf("denied to access") + } +} + var passAllAdmin = func(map[string]string) error { return nil } diff --git a/internal/dashboard/template_handler.go b/internal/dashboard/template_handler.go index 955d6f48..41db6438 100644 --- a/internal/dashboard/template_handler.go +++ b/internal/dashboard/template_handler.go @@ -7,12 +7,12 @@ import ( "strings" connect_go "github.com/bufbuild/connect-go" - "google.golang.org/protobuf/types/known/emptypb" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/utils/pointer" cosmov1alpha1 "github.com/cosmo-workspace/cosmo/api/v1alpha1" "github.com/cosmo-workspace/cosmo/pkg/clog" + "github.com/cosmo-workspace/cosmo/pkg/kosmo" "github.com/cosmo-workspace/cosmo/pkg/kubeutil" dashv1alpha1 "github.com/cosmo-workspace/cosmo/proto/gen/dashboard/v1alpha1" "github.com/cosmo-workspace/cosmo/proto/gen/dashboard/v1alpha1/dashboardv1alpha1connect" @@ -26,16 +26,20 @@ func (s *Server) TemplateServiceHandler(mux *http.ServeMux) { mux.Handle(path, s.contextMiddleware(handler)) } -func (s *Server) GetWorkspaceTemplates(ctx context.Context, req *connect_go.Request[emptypb.Empty]) (*connect_go.Response[dashv1alpha1.GetWorkspaceTemplatesResponse], error) { +func (s *Server) GetWorkspaceTemplates(ctx context.Context, req *connect_go.Request[dashv1alpha1.GetWorkspaceTemplatesRequest]) (*connect_go.Response[dashv1alpha1.GetWorkspaceTemplatesResponse], error) { log := clog.FromContext(ctx).WithCaller() user := callerFromContext(ctx) - tmpls, err := s.Klient.ListWorkspaceTemplates(ctx, user) + tmpls, err := s.Klient.ListWorkspaceTemplates(ctx) if err != nil { return nil, ErrResponse(log, err) } + if req.Msg.UseRoleFilter != nil && *req.Msg.UseRoleFilter { + tmpls = kosmo.FilterTemplates(ctx, tmpls, user) + } + addonTmpls := make([]*dashv1alpha1.Template, 0, len(tmpls)) for _, v := range tmpls { addonTmpls = append(addonTmpls, convertTemplateToDashv1alpha1Template(v)) @@ -52,16 +56,20 @@ func (s *Server) GetWorkspaceTemplates(ctx context.Context, req *connect_go.Requ return connect_go.NewResponse(res), nil } -func (s *Server) GetUserAddonTemplates(ctx context.Context, req *connect_go.Request[emptypb.Empty]) (*connect_go.Response[dashv1alpha1.GetUserAddonTemplatesResponse], error) { +func (s *Server) GetUserAddonTemplates(ctx context.Context, req *connect_go.Request[dashv1alpha1.GetUserAddonTemplatesRequest]) (*connect_go.Response[dashv1alpha1.GetUserAddonTemplatesResponse], error) { log := clog.FromContext(ctx).WithCaller() user := callerFromContext(ctx) - tmpls, err := s.Klient.ListUserAddonTemplates(ctx, user) + tmpls, err := s.Klient.ListUserAddonTemplates(ctx) if err != nil { return nil, ErrResponse(log, err) } + if req.Msg.UseRoleFilter != nil && *req.Msg.UseRoleFilter { + tmpls = kosmo.FilterTemplates(ctx, tmpls, user) + } + addonTmpls := make([]*dashv1alpha1.Template, len(tmpls)) for i, v := range tmpls { tmpl := convertTemplateToDashv1alpha1Template(v) diff --git a/internal/dashboard/template_handler_test.go b/internal/dashboard/template_handler_test.go index b0c29dd0..38a97f1b 100644 --- a/internal/dashboard/template_handler_test.go +++ b/internal/dashboard/template_handler_test.go @@ -8,23 +8,25 @@ import ( . "github.com/cosmo-workspace/cosmo/pkg/snap" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "google.golang.org/protobuf/types/known/emptypb" + "k8s.io/utils/pointer" cosmov1alpha1 "github.com/cosmo-workspace/cosmo/api/v1alpha1" + dashboardv1alpha1 "github.com/cosmo-workspace/cosmo/proto/gen/dashboard/v1alpha1" "github.com/cosmo-workspace/cosmo/proto/gen/dashboard/v1alpha1/dashboardv1alpha1connect" ) var _ = Describe("Dashboard server [Template]", func() { var ( - userSession string - adminSession string - client dashboardv1alpha1connect.TemplateServiceClient + userSession string + roleUserSession string + adminSession string + client dashboardv1alpha1connect.TemplateServiceClient ) BeforeEach(func() { userSession = test_CreateLoginUserSession("normal-user", "お名前", nil, "password") + roleUserSession = test_CreateLoginUserSession("role-user", "お名前", []cosmov1alpha1.UserRole{{Name: "my-role"}}, "password") adminSession = test_CreateLoginUserSession("admin-user", "アドミン", []cosmov1alpha1.UserRole{cosmov1alpha1.PrivilegedRole}, "password") client = dashboardv1alpha1connect.NewTemplateServiceClient(http.DefaultClient, "http://localhost:8888") }) @@ -37,18 +39,21 @@ var _ = Describe("Dashboard server [Template]", func() { Describe("[GetWorkspaceTemplates]", func() { - run_test := func(loginUser string, testCase string) { + run_test := func(loginUser string, testCase string, req *dashboardv1alpha1.GetWorkspaceTemplatesRequest) { if testCase == "not empty" { testUtil.CreateTemplate(cosmov1alpha1.TemplateLabelEnumTypeWorkspace, "template1") testUtil.CreateTemplate(cosmov1alpha1.TemplateLabelEnumTypeWorkspace, "template2") + testUtil.CreateTemplateForUserRole(cosmov1alpha1.TemplateLabelEnumTypeWorkspace, "template3", "my-role") } session := userSession if loginUser == "admin-user" { session = adminSession + } else if loginUser == "role-user" { + session = roleUserSession } By("---------------test start----------------") ctx := context.Background() - res, err := client.GetWorkspaceTemplates(ctx, NewRequestWithSession(&emptypb.Empty{}, session)) + res, err := client.GetWorkspaceTemplates(ctx, NewRequestWithSession(req, session)) if err == nil { Ω(res.Msg).To(MatchSnapShot()) } else { @@ -60,24 +65,26 @@ var _ = Describe("Dashboard server [Template]", func() { DescribeTable("✅ success in normal context:", run_test, - Entry(nil, "admin-user", "empty"), - Entry(nil, "admin-user", "not empty"), - Entry(nil, "normal-user", "empty"), - Entry(nil, "normal-user", "not empty"), + Entry(nil, "admin-user", "empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{}), + Entry(nil, "admin-user", "not empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{}), + Entry(nil, "normal-user", "empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{}), + Entry(nil, "normal-user", "not empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{}), + Entry(nil, "normal-user", "not empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{UseRoleFilter: pointer.Bool(true)}), + Entry(nil, "role-user", "not empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{}), ) DescribeTable("❌ fail with an unexpected error at list:", - func(user string, testCase string) { + func(user string, testCase string, req *dashboardv1alpha1.GetWorkspaceTemplatesRequest) { clientMock.SetListError((*Server).GetWorkspaceTemplates, errors.New("template list error")) - run_test(user, testCase) + run_test(user, testCase, req) }, - Entry(nil, "admin-user", "not empty"), + Entry(nil, "admin-user", "not empty", &dashboardv1alpha1.GetWorkspaceTemplatesRequest{}), ) }) Describe("[GetUserAddonTemplates]", func() { - run_test := func(loginUser string, testCase string) { + run_test := func(loginUser string, testCase string, req *dashboardv1alpha1.GetUserAddonTemplatesRequest) { if testCase == "not empty" { testUtil.CreateTemplate(cosmov1alpha1.TemplateLabelEnumTypeUserAddon, "useraddon1") testUtil.CreateTemplate(cosmov1alpha1.TemplateLabelEnumTypeUserAddon, "useraddon2") @@ -88,7 +95,7 @@ var _ = Describe("Dashboard server [Template]", func() { } By("---------------test start----------------") ctx := context.Background() - res, err := client.GetUserAddonTemplates(ctx, NewRequestWithSession(&emptypb.Empty{}, session)) + res, err := client.GetUserAddonTemplates(ctx, NewRequestWithSession(req, session)) if err == nil { Ω(res.Msg).To(MatchSnapShot()) } else { @@ -100,18 +107,18 @@ var _ = Describe("Dashboard server [Template]", func() { DescribeTable("✅ success in normal context:", run_test, - Entry(nil, "admin-user", "empty"), - Entry(nil, "admin-user", "not empty"), - Entry(nil, "normal-user", "empty"), - Entry(nil, "normal-user", "not empty"), + Entry(nil, "admin-user", "empty", &dashboardv1alpha1.GetUserAddonTemplatesRequest{}), + Entry(nil, "admin-user", "not empty", &dashboardv1alpha1.GetUserAddonTemplatesRequest{}), + Entry(nil, "normal-user", "empty", &dashboardv1alpha1.GetUserAddonTemplatesRequest{}), + Entry(nil, "normal-user", "not empty", &dashboardv1alpha1.GetUserAddonTemplatesRequest{}), ) DescribeTable("❌ fail with an unexpected error at list:", - func(user string, testCase string) { + func(user string, testCase string, req *dashboardv1alpha1.GetUserAddonTemplatesRequest) { clientMock.SetListError((*Server).GetUserAddonTemplates, errors.New("template list error")) - run_test(user, testCase) + run_test(user, testCase, req) }, - Entry(nil, "admin-user", "not empty"), + Entry(nil, "admin-user", "not empty", &dashboardv1alpha1.GetUserAddonTemplatesRequest{}), ) }) }) diff --git a/pkg/kosmo/template.go b/pkg/kosmo/template.go index 9c1f4afc..d4ed3895 100644 --- a/pkg/kosmo/template.go +++ b/pkg/kosmo/template.go @@ -12,7 +12,7 @@ import ( "github.com/cosmo-workspace/cosmo/pkg/kubeutil" ) -func filterTemplates(ctx context.Context, tmpls []cosmov1alpha1.TemplateObject, u *cosmov1alpha1.User) []cosmov1alpha1.TemplateObject { +func FilterTemplates(ctx context.Context, tmpls []cosmov1alpha1.TemplateObject, u *cosmov1alpha1.User) []cosmov1alpha1.TemplateObject { filteredTmpls := make([]cosmov1alpha1.TemplateObject, 0, len(tmpls)) for _, v := range tmpls { if IsAllowedToUseTemplate(ctx, u, v) { @@ -70,23 +70,23 @@ func HasRequiredAddons(ctx context.Context, u *cosmov1alpha1.User, tmpl cosmov1a return false } -func (c *Client) ListWorkspaceTemplates(ctx context.Context, u *cosmov1alpha1.User) ([]cosmov1alpha1.TemplateObject, error) { +func (c *Client) ListWorkspaceTemplates(ctx context.Context) ([]cosmov1alpha1.TemplateObject, error) { log := clog.FromContext(ctx).WithCaller() if tmpls, err := kubeutil.ListTemplateObjectsByType(ctx, c, []string{cosmov1alpha1.TemplateLabelEnumTypeWorkspace}); err != nil { log.Error(err, "failed to list WorkspaceTemplates") return nil, NewInternalServerError("failed to list WorkspaceTemplates", err) } else { - return filterTemplates(ctx, tmpls, u), nil + return tmpls, nil } } -func (c *Client) ListUserAddonTemplates(ctx context.Context, u *cosmov1alpha1.User) ([]cosmov1alpha1.TemplateObject, error) { +func (c *Client) ListUserAddonTemplates(ctx context.Context) ([]cosmov1alpha1.TemplateObject, error) { log := clog.FromContext(ctx).WithCaller() if tmpls, err := kubeutil.ListTemplateObjectsByType(ctx, c, []string{cosmov1alpha1.TemplateLabelEnumTypeUserAddon}); err != nil { log.Error(err, "failed to list UserAddon Templates") return nil, NewInternalServerError("failed to list UserAddon Templates", err) } else { - return filterTemplates(ctx, tmpls, u), nil + return tmpls, nil } } diff --git a/pkg/kosmo/template_test.go b/pkg/kosmo/template_test.go index 51d36e0b..0853203c 100644 --- a/pkg/kosmo/template_test.go +++ b/pkg/kosmo/template_test.go @@ -264,7 +264,7 @@ func Test_filterTemplates(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := filterTemplates(context.TODO(), tt.args.tmpls, tt.args.user); !reflect.DeepEqual(got, tt.want) { + if got := FilterTemplates(context.TODO(), tt.args.tmpls, tt.args.user); !reflect.DeepEqual(got, tt.want) { t.Errorf("filterTemplates() = %v, want %v", got, tt.want) t.Errorf(cmp.Diff(got, tt.want)) } diff --git a/pkg/kosmo/test/test_util.go b/pkg/kosmo/test/test_util.go index 7ea18c74..09f805b4 100644 --- a/pkg/kosmo/test/test_util.go +++ b/pkg/kosmo/test/test_util.go @@ -64,6 +64,28 @@ spec: }, time.Second*5, time.Millisecond*100).Should(Succeed()) } +func (c *TestUtil) CreateTemplateForUserRole(templateType, templateName, userrole string) { + ctx := context.Background() + tmpl := cosmov1alpha1.Template{ + ObjectMeta: metav1.ObjectMeta{ + Name: templateName, + Labels: map[string]string{ + cosmov1alpha1.TemplateLabelKeyType: templateType, + }, + Annotations: map[string]string{ + cosmov1alpha1.TemplateAnnKeyUserRoles: userrole, + }, + }, + } + err := c.kosmoClient.Create(ctx, &tmpl) + Expect(err).ShouldNot(HaveOccurred()) + + Eventually(func() error { + err := c.kosmoClient.Get(ctx, client.ObjectKey{Name: templateName}, &cosmov1alpha1.Template{}) + return err + }, time.Second*5, time.Millisecond*100).Should(Succeed()) +} + func (c *TestUtil) CreateClusterTemplate(templateType string, templateName string) { ctx := context.Background() tmpl := cosmov1alpha1.ClusterTemplate{ diff --git a/proto/gen/dashboard/v1alpha1/dashboardv1alpha1connect/template_service.connect.go b/proto/gen/dashboard/v1alpha1/dashboardv1alpha1connect/template_service.connect.go index 08c4d820..bd8a975c 100644 --- a/proto/gen/dashboard/v1alpha1/dashboardv1alpha1connect/template_service.connect.go +++ b/proto/gen/dashboard/v1alpha1/dashboardv1alpha1connect/template_service.connect.go @@ -13,7 +13,6 @@ import ( errors "errors" connect_go "github.com/bufbuild/connect-go" v1alpha1 "github.com/cosmo-workspace/cosmo/proto/gen/dashboard/v1alpha1" - emptypb "google.golang.org/protobuf/types/known/emptypb" http "net/http" strings "strings" ) @@ -49,9 +48,9 @@ const ( // TemplateServiceClient is a client for the dashboard.v1alpha1.TemplateService service. type TemplateServiceClient interface { // List templates typed useraddon - GetUserAddonTemplates(context.Context, *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) + GetUserAddonTemplates(context.Context, *connect_go.Request[v1alpha1.GetUserAddonTemplatesRequest]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) // List templates typed workspace - GetWorkspaceTemplates(context.Context, *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) + GetWorkspaceTemplates(context.Context, *connect_go.Request[v1alpha1.GetWorkspaceTemplatesRequest]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) } // NewTemplateServiceClient constructs a client for the dashboard.v1alpha1.TemplateService service. @@ -64,12 +63,12 @@ type TemplateServiceClient interface { func NewTemplateServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) TemplateServiceClient { baseURL = strings.TrimRight(baseURL, "/") return &templateServiceClient{ - getUserAddonTemplates: connect_go.NewClient[emptypb.Empty, v1alpha1.GetUserAddonTemplatesResponse]( + getUserAddonTemplates: connect_go.NewClient[v1alpha1.GetUserAddonTemplatesRequest, v1alpha1.GetUserAddonTemplatesResponse]( httpClient, baseURL+TemplateServiceGetUserAddonTemplatesProcedure, opts..., ), - getWorkspaceTemplates: connect_go.NewClient[emptypb.Empty, v1alpha1.GetWorkspaceTemplatesResponse]( + getWorkspaceTemplates: connect_go.NewClient[v1alpha1.GetWorkspaceTemplatesRequest, v1alpha1.GetWorkspaceTemplatesResponse]( httpClient, baseURL+TemplateServiceGetWorkspaceTemplatesProcedure, opts..., @@ -79,26 +78,26 @@ func NewTemplateServiceClient(httpClient connect_go.HTTPClient, baseURL string, // templateServiceClient implements TemplateServiceClient. type templateServiceClient struct { - getUserAddonTemplates *connect_go.Client[emptypb.Empty, v1alpha1.GetUserAddonTemplatesResponse] - getWorkspaceTemplates *connect_go.Client[emptypb.Empty, v1alpha1.GetWorkspaceTemplatesResponse] + getUserAddonTemplates *connect_go.Client[v1alpha1.GetUserAddonTemplatesRequest, v1alpha1.GetUserAddonTemplatesResponse] + getWorkspaceTemplates *connect_go.Client[v1alpha1.GetWorkspaceTemplatesRequest, v1alpha1.GetWorkspaceTemplatesResponse] } // GetUserAddonTemplates calls dashboard.v1alpha1.TemplateService.GetUserAddonTemplates. -func (c *templateServiceClient) GetUserAddonTemplates(ctx context.Context, req *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) { +func (c *templateServiceClient) GetUserAddonTemplates(ctx context.Context, req *connect_go.Request[v1alpha1.GetUserAddonTemplatesRequest]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) { return c.getUserAddonTemplates.CallUnary(ctx, req) } // GetWorkspaceTemplates calls dashboard.v1alpha1.TemplateService.GetWorkspaceTemplates. -func (c *templateServiceClient) GetWorkspaceTemplates(ctx context.Context, req *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) { +func (c *templateServiceClient) GetWorkspaceTemplates(ctx context.Context, req *connect_go.Request[v1alpha1.GetWorkspaceTemplatesRequest]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) { return c.getWorkspaceTemplates.CallUnary(ctx, req) } // TemplateServiceHandler is an implementation of the dashboard.v1alpha1.TemplateService service. type TemplateServiceHandler interface { // List templates typed useraddon - GetUserAddonTemplates(context.Context, *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) + GetUserAddonTemplates(context.Context, *connect_go.Request[v1alpha1.GetUserAddonTemplatesRequest]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) // List templates typed workspace - GetWorkspaceTemplates(context.Context, *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) + GetWorkspaceTemplates(context.Context, *connect_go.Request[v1alpha1.GetWorkspaceTemplatesRequest]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) } // NewTemplateServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -124,10 +123,10 @@ func NewTemplateServiceHandler(svc TemplateServiceHandler, opts ...connect_go.Ha // UnimplementedTemplateServiceHandler returns CodeUnimplemented from all methods. type UnimplementedTemplateServiceHandler struct{} -func (UnimplementedTemplateServiceHandler) GetUserAddonTemplates(context.Context, *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) { +func (UnimplementedTemplateServiceHandler) GetUserAddonTemplates(context.Context, *connect_go.Request[v1alpha1.GetUserAddonTemplatesRequest]) (*connect_go.Response[v1alpha1.GetUserAddonTemplatesResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("dashboard.v1alpha1.TemplateService.GetUserAddonTemplates is not implemented")) } -func (UnimplementedTemplateServiceHandler) GetWorkspaceTemplates(context.Context, *connect_go.Request[emptypb.Empty]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) { +func (UnimplementedTemplateServiceHandler) GetWorkspaceTemplates(context.Context, *connect_go.Request[v1alpha1.GetWorkspaceTemplatesRequest]) (*connect_go.Response[v1alpha1.GetWorkspaceTemplatesResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("dashboard.v1alpha1.TemplateService.GetWorkspaceTemplates is not implemented")) } diff --git a/proto/gen/dashboard/v1alpha1/template_service.pb.go b/proto/gen/dashboard/v1alpha1/template_service.pb.go index 6b310367..a883cccc 100644 --- a/proto/gen/dashboard/v1alpha1/template_service.pb.go +++ b/proto/gen/dashboard/v1alpha1/template_service.pb.go @@ -13,7 +13,7 @@ package dashboardv1alpha1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" + _ "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) @@ -25,6 +25,53 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type GetUserAddonTemplatesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UseRoleFilter *bool `protobuf:"varint,1,opt,name=use_role_filter,json=useRoleFilter,proto3,oneof" json:"use_role_filter,omitempty"` +} + +func (x *GetUserAddonTemplatesRequest) Reset() { + *x = GetUserAddonTemplatesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserAddonTemplatesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserAddonTemplatesRequest) ProtoMessage() {} + +func (x *GetUserAddonTemplatesRequest) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserAddonTemplatesRequest.ProtoReflect.Descriptor instead. +func (*GetUserAddonTemplatesRequest) Descriptor() ([]byte, []int) { + return file_dashboard_v1alpha1_template_service_proto_rawDescGZIP(), []int{0} +} + +func (x *GetUserAddonTemplatesRequest) GetUseRoleFilter() bool { + if x != nil && x.UseRoleFilter != nil { + return *x.UseRoleFilter + } + return false +} + type GetUserAddonTemplatesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -37,7 +84,7 @@ type GetUserAddonTemplatesResponse struct { func (x *GetUserAddonTemplatesResponse) Reset() { *x = GetUserAddonTemplatesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[0] + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -50,7 +97,7 @@ func (x *GetUserAddonTemplatesResponse) String() string { func (*GetUserAddonTemplatesResponse) ProtoMessage() {} func (x *GetUserAddonTemplatesResponse) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[0] + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -63,7 +110,7 @@ func (x *GetUserAddonTemplatesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserAddonTemplatesResponse.ProtoReflect.Descriptor instead. func (*GetUserAddonTemplatesResponse) Descriptor() ([]byte, []int) { - return file_dashboard_v1alpha1_template_service_proto_rawDescGZIP(), []int{0} + return file_dashboard_v1alpha1_template_service_proto_rawDescGZIP(), []int{1} } func (x *GetUserAddonTemplatesResponse) GetMessage() string { @@ -80,6 +127,53 @@ func (x *GetUserAddonTemplatesResponse) GetItems() []*Template { return nil } +type GetWorkspaceTemplatesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UseRoleFilter *bool `protobuf:"varint,1,opt,name=use_role_filter,json=useRoleFilter,proto3,oneof" json:"use_role_filter,omitempty"` +} + +func (x *GetWorkspaceTemplatesRequest) Reset() { + *x = GetWorkspaceTemplatesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetWorkspaceTemplatesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetWorkspaceTemplatesRequest) ProtoMessage() {} + +func (x *GetWorkspaceTemplatesRequest) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetWorkspaceTemplatesRequest.ProtoReflect.Descriptor instead. +func (*GetWorkspaceTemplatesRequest) Descriptor() ([]byte, []int) { + return file_dashboard_v1alpha1_template_service_proto_rawDescGZIP(), []int{2} +} + +func (x *GetWorkspaceTemplatesRequest) GetUseRoleFilter() bool { + if x != nil && x.UseRoleFilter != nil { + return *x.UseRoleFilter + } + return false +} + type GetWorkspaceTemplatesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -92,7 +186,7 @@ type GetWorkspaceTemplatesResponse struct { func (x *GetWorkspaceTemplatesResponse) Reset() { *x = GetWorkspaceTemplatesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[1] + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -105,7 +199,7 @@ func (x *GetWorkspaceTemplatesResponse) String() string { func (*GetWorkspaceTemplatesResponse) ProtoMessage() {} func (x *GetWorkspaceTemplatesResponse) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[1] + mi := &file_dashboard_v1alpha1_template_service_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -118,7 +212,7 @@ func (x *GetWorkspaceTemplatesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetWorkspaceTemplatesResponse.ProtoReflect.Descriptor instead. func (*GetWorkspaceTemplatesResponse) Descriptor() ([]byte, []int) { - return file_dashboard_v1alpha1_template_service_proto_rawDescGZIP(), []int{1} + return file_dashboard_v1alpha1_template_service_proto_rawDescGZIP(), []int{3} } func (x *GetWorkspaceTemplatesResponse) GetMessage() string { @@ -146,49 +240,65 @@ var file_dashboard_v1alpha1_template_service_proto_rawDesc = []byte{ 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x6d, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x6f, 0x6e, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x69, 0x74, - 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x61, 0x73, 0x68, - 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x6d, - 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x69, 0x74, 0x65, - 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x61, 0x73, 0x68, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x32, 0xd9, 0x01, - 0x0a, 0x0f, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x62, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x6f, - 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x1a, 0x31, 0x2e, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, - 0x64, 0x64, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x31, 0x2e, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, - 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x57, - 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xe8, 0x01, 0x0a, 0x16, 0x63, 0x6f, - 0x6d, 0x2e, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x42, 0x14, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4f, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x2d, 0x77, - 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, - 0x72, 0x64, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x64, 0x61, 0x73, 0x68, - 0x62, 0x6f, 0x61, 0x72, 0x64, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, - 0x44, 0x58, 0x58, 0xaa, 0x02, 0x12, 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, - 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x12, 0x44, 0x61, 0x73, 0x68, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, - 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x13, 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x5f, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x6f, 0x6e, 0x54, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x2b, 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0d, 0x75, 0x73, 0x65, 0x52, + 0x6f, 0x6c, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x88, 0x01, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x22, 0x6d, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x6f, 0x6e, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x61, 0x73, + 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, + 0x5f, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x2b, 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0d, 0x75, 0x73, 0x65, 0x52, + 0x6f, 0x6c, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x88, 0x01, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x22, 0x6d, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x61, 0x73, + 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x32, + 0x8d, 0x02, 0x0a, 0x0f, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x7c, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, + 0x64, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x30, 0x2e, 0x64, + 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x6f, 0x6e, 0x54, 0x65, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, + 0x2e, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x6f, 0x6e, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x7c, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x30, 0x2e, 0x64, 0x61, 0x73, + 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x64, + 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0xe8, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, + 0x64, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x14, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x2d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x64, + 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x3b, 0x64, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x44, 0x58, 0x58, 0xaa, 0x02, 0x12, 0x44, 0x61, 0x73, 0x68, + 0x62, 0x6f, 0x61, 0x72, 0x64, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, + 0x12, 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1e, 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, + 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -203,20 +313,21 @@ func file_dashboard_v1alpha1_template_service_proto_rawDescGZIP() []byte { return file_dashboard_v1alpha1_template_service_proto_rawDescData } -var file_dashboard_v1alpha1_template_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_dashboard_v1alpha1_template_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_dashboard_v1alpha1_template_service_proto_goTypes = []interface{}{ - (*GetUserAddonTemplatesResponse)(nil), // 0: dashboard.v1alpha1.GetUserAddonTemplatesResponse - (*GetWorkspaceTemplatesResponse)(nil), // 1: dashboard.v1alpha1.GetWorkspaceTemplatesResponse - (*Template)(nil), // 2: dashboard.v1alpha1.Template - (*emptypb.Empty)(nil), // 3: google.protobuf.Empty + (*GetUserAddonTemplatesRequest)(nil), // 0: dashboard.v1alpha1.GetUserAddonTemplatesRequest + (*GetUserAddonTemplatesResponse)(nil), // 1: dashboard.v1alpha1.GetUserAddonTemplatesResponse + (*GetWorkspaceTemplatesRequest)(nil), // 2: dashboard.v1alpha1.GetWorkspaceTemplatesRequest + (*GetWorkspaceTemplatesResponse)(nil), // 3: dashboard.v1alpha1.GetWorkspaceTemplatesResponse + (*Template)(nil), // 4: dashboard.v1alpha1.Template } var file_dashboard_v1alpha1_template_service_proto_depIdxs = []int32{ - 2, // 0: dashboard.v1alpha1.GetUserAddonTemplatesResponse.items:type_name -> dashboard.v1alpha1.Template - 2, // 1: dashboard.v1alpha1.GetWorkspaceTemplatesResponse.items:type_name -> dashboard.v1alpha1.Template - 3, // 2: dashboard.v1alpha1.TemplateService.GetUserAddonTemplates:input_type -> google.protobuf.Empty - 3, // 3: dashboard.v1alpha1.TemplateService.GetWorkspaceTemplates:input_type -> google.protobuf.Empty - 0, // 4: dashboard.v1alpha1.TemplateService.GetUserAddonTemplates:output_type -> dashboard.v1alpha1.GetUserAddonTemplatesResponse - 1, // 5: dashboard.v1alpha1.TemplateService.GetWorkspaceTemplates:output_type -> dashboard.v1alpha1.GetWorkspaceTemplatesResponse + 4, // 0: dashboard.v1alpha1.GetUserAddonTemplatesResponse.items:type_name -> dashboard.v1alpha1.Template + 4, // 1: dashboard.v1alpha1.GetWorkspaceTemplatesResponse.items:type_name -> dashboard.v1alpha1.Template + 0, // 2: dashboard.v1alpha1.TemplateService.GetUserAddonTemplates:input_type -> dashboard.v1alpha1.GetUserAddonTemplatesRequest + 2, // 3: dashboard.v1alpha1.TemplateService.GetWorkspaceTemplates:input_type -> dashboard.v1alpha1.GetWorkspaceTemplatesRequest + 1, // 4: dashboard.v1alpha1.TemplateService.GetUserAddonTemplates:output_type -> dashboard.v1alpha1.GetUserAddonTemplatesResponse + 3, // 5: dashboard.v1alpha1.TemplateService.GetWorkspaceTemplates:output_type -> dashboard.v1alpha1.GetWorkspaceTemplatesResponse 4, // [4:6] is the sub-list for method output_type 2, // [2:4] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -232,7 +343,7 @@ func file_dashboard_v1alpha1_template_service_proto_init() { file_dashboard_v1alpha1_template_proto_init() if !protoimpl.UnsafeEnabled { file_dashboard_v1alpha1_template_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUserAddonTemplatesResponse); i { + switch v := v.(*GetUserAddonTemplatesRequest); i { case 0: return &v.state case 1: @@ -244,6 +355,30 @@ func file_dashboard_v1alpha1_template_service_proto_init() { } } file_dashboard_v1alpha1_template_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserAddonTemplatesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dashboard_v1alpha1_template_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetWorkspaceTemplatesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dashboard_v1alpha1_template_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetWorkspaceTemplatesResponse); i { case 0: return &v.state @@ -256,13 +391,15 @@ func file_dashboard_v1alpha1_template_service_proto_init() { } } } + file_dashboard_v1alpha1_template_service_proto_msgTypes[0].OneofWrappers = []interface{}{} + file_dashboard_v1alpha1_template_service_proto_msgTypes[2].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_dashboard_v1alpha1_template_service_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/gen/dashboard/v1alpha1/template_service.pb.validate.go b/proto/gen/dashboard/v1alpha1/template_service.pb.validate.go index 68809700..f30c9b86 100644 --- a/proto/gen/dashboard/v1alpha1/template_service.pb.validate.go +++ b/proto/gen/dashboard/v1alpha1/template_service.pb.validate.go @@ -35,6 +35,113 @@ var ( _ = sort.Sort ) +// Validate checks the field values on GetUserAddonTemplatesRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetUserAddonTemplatesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserAddonTemplatesRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetUserAddonTemplatesRequestMultiError, or nil if none found. +func (m *GetUserAddonTemplatesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserAddonTemplatesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.UseRoleFilter != nil { + // no validation rules for UseRoleFilter + } + + if len(errors) > 0 { + return GetUserAddonTemplatesRequestMultiError(errors) + } + + return nil +} + +// GetUserAddonTemplatesRequestMultiError is an error wrapping multiple +// validation errors returned by GetUserAddonTemplatesRequest.ValidateAll() if +// the designated constraints aren't met. +type GetUserAddonTemplatesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserAddonTemplatesRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetUserAddonTemplatesRequestMultiError) AllErrors() []error { return m } + +// GetUserAddonTemplatesRequestValidationError is the validation error returned +// by GetUserAddonTemplatesRequest.Validate if the designated constraints +// aren't met. +type GetUserAddonTemplatesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserAddonTemplatesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserAddonTemplatesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserAddonTemplatesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserAddonTemplatesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserAddonTemplatesRequestValidationError) ErrorName() string { + return "GetUserAddonTemplatesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserAddonTemplatesRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetUserAddonTemplatesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserAddonTemplatesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserAddonTemplatesRequestValidationError{} + // Validate checks the field values on GetUserAddonTemplatesResponse with the // rules defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. @@ -174,6 +281,113 @@ var _ interface { ErrorName() string } = GetUserAddonTemplatesResponseValidationError{} +// Validate checks the field values on GetWorkspaceTemplatesRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetWorkspaceTemplatesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetWorkspaceTemplatesRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetWorkspaceTemplatesRequestMultiError, or nil if none found. +func (m *GetWorkspaceTemplatesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetWorkspaceTemplatesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.UseRoleFilter != nil { + // no validation rules for UseRoleFilter + } + + if len(errors) > 0 { + return GetWorkspaceTemplatesRequestMultiError(errors) + } + + return nil +} + +// GetWorkspaceTemplatesRequestMultiError is an error wrapping multiple +// validation errors returned by GetWorkspaceTemplatesRequest.ValidateAll() if +// the designated constraints aren't met. +type GetWorkspaceTemplatesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetWorkspaceTemplatesRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetWorkspaceTemplatesRequestMultiError) AllErrors() []error { return m } + +// GetWorkspaceTemplatesRequestValidationError is the validation error returned +// by GetWorkspaceTemplatesRequest.Validate if the designated constraints +// aren't met. +type GetWorkspaceTemplatesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetWorkspaceTemplatesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetWorkspaceTemplatesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetWorkspaceTemplatesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetWorkspaceTemplatesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetWorkspaceTemplatesRequestValidationError) ErrorName() string { + return "GetWorkspaceTemplatesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetWorkspaceTemplatesRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetWorkspaceTemplatesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetWorkspaceTemplatesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetWorkspaceTemplatesRequestValidationError{} + // Validate checks the field values on GetWorkspaceTemplatesResponse with the // rules defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. diff --git a/proto/gen/index.md b/proto/gen/index.md index 7a645755..a6a85719 100644 --- a/proto/gen/index.md +++ b/proto/gen/index.md @@ -15,7 +15,9 @@ - [TemplateRequiredVars](#dashboard-v1alpha1-TemplateRequiredVars) - [dashboard/v1alpha1/template_service.proto](#dashboard_v1alpha1_template_service-proto) + - [GetUserAddonTemplatesRequest](#dashboard-v1alpha1-GetUserAddonTemplatesRequest) - [GetUserAddonTemplatesResponse](#dashboard-v1alpha1-GetUserAddonTemplatesResponse) + - [GetWorkspaceTemplatesRequest](#dashboard-v1alpha1-GetWorkspaceTemplatesRequest) - [GetWorkspaceTemplatesResponse](#dashboard-v1alpha1-GetWorkspaceTemplatesResponse) - [TemplateService](#dashboard-v1alpha1-TemplateService) @@ -211,6 +213,21 @@ + + +### GetUserAddonTemplatesRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| use_role_filter | [bool](#bool) | optional | | + + + + + + ### GetUserAddonTemplatesResponse @@ -227,6 +244,21 @@ + + +### GetWorkspaceTemplatesRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| use_role_filter | [bool](#bool) | optional | | + + + + + + ### GetWorkspaceTemplatesResponse @@ -256,8 +288,8 @@ | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| -| GetUserAddonTemplates | [.google.protobuf.Empty](#google-protobuf-Empty) | [GetUserAddonTemplatesResponse](#dashboard-v1alpha1-GetUserAddonTemplatesResponse) | List templates typed useraddon | -| GetWorkspaceTemplates | [.google.protobuf.Empty](#google-protobuf-Empty) | [GetWorkspaceTemplatesResponse](#dashboard-v1alpha1-GetWorkspaceTemplatesResponse) | List templates typed workspace | +| GetUserAddonTemplates | [GetUserAddonTemplatesRequest](#dashboard-v1alpha1-GetUserAddonTemplatesRequest) | [GetUserAddonTemplatesResponse](#dashboard-v1alpha1-GetUserAddonTemplatesResponse) | List templates typed useraddon | +| GetWorkspaceTemplates | [GetWorkspaceTemplatesRequest](#dashboard-v1alpha1-GetWorkspaceTemplatesRequest) | [GetWorkspaceTemplatesResponse](#dashboard-v1alpha1-GetWorkspaceTemplatesResponse) | List templates typed workspace | diff --git a/proto/proto/dashboard-apis/dashboard/v1alpha1/template_service.proto b/proto/proto/dashboard-apis/dashboard/v1alpha1/template_service.proto index 40a10519..a978c1e0 100644 --- a/proto/proto/dashboard-apis/dashboard/v1alpha1/template_service.proto +++ b/proto/proto/dashboard-apis/dashboard/v1alpha1/template_service.proto @@ -12,18 +12,26 @@ import "dashboard/v1alpha1/template.proto"; service TemplateService { // List templates typed useraddon - rpc GetUserAddonTemplates(google.protobuf.Empty) + rpc GetUserAddonTemplates(GetUserAddonTemplatesRequest) returns (GetUserAddonTemplatesResponse); // List templates typed workspace - rpc GetWorkspaceTemplates(google.protobuf.Empty) + rpc GetWorkspaceTemplates(GetWorkspaceTemplatesRequest) returns (GetWorkspaceTemplatesResponse); } +message GetUserAddonTemplatesRequest { + optional bool use_role_filter = 1; +} + message GetUserAddonTemplatesResponse { string message = 1; repeated Template items = 2; } +message GetWorkspaceTemplatesRequest { + optional bool use_role_filter = 1; +} + message GetWorkspaceTemplatesResponse { string message = 1; repeated Template items = 2; diff --git a/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_connectweb.ts b/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_connectweb.ts index 80055852..d7437cb7 100644 --- a/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_connectweb.ts +++ b/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_connectweb.ts @@ -7,8 +7,8 @@ /* eslint-disable */ // @ts-nocheck -import { Empty, MethodKind } from "@bufbuild/protobuf"; -import { GetUserAddonTemplatesResponse, GetWorkspaceTemplatesResponse } from "./template_service_pb.js"; +import { GetUserAddonTemplatesRequest, GetUserAddonTemplatesResponse, GetWorkspaceTemplatesRequest, GetWorkspaceTemplatesResponse } from "./template_service_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; /** * @generated from service dashboard.v1alpha1.TemplateService @@ -23,7 +23,7 @@ export const TemplateService = { */ getUserAddonTemplates: { name: "GetUserAddonTemplates", - I: Empty, + I: GetUserAddonTemplatesRequest, O: GetUserAddonTemplatesResponse, kind: MethodKind.Unary, }, @@ -34,7 +34,7 @@ export const TemplateService = { */ getWorkspaceTemplates: { name: "GetWorkspaceTemplates", - I: Empty, + I: GetWorkspaceTemplatesRequest, O: GetWorkspaceTemplatesResponse, kind: MethodKind.Unary, }, diff --git a/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_pb.ts b/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_pb.ts index 336790ae..bf6b38a9 100644 --- a/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_pb.ts +++ b/web/dashboard-ui/src/proto/gen/dashboard/v1alpha1/template_service_pb.ts @@ -11,6 +11,43 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; import { Template } from "./template_pb.js"; +/** + * @generated from message dashboard.v1alpha1.GetUserAddonTemplatesRequest + */ +export class GetUserAddonTemplatesRequest extends Message { + /** + * @generated from field: optional bool use_role_filter = 1; + */ + useRoleFilter?: boolean; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "dashboard.v1alpha1.GetUserAddonTemplatesRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "use_role_filter", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetUserAddonTemplatesRequest { + return new GetUserAddonTemplatesRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetUserAddonTemplatesRequest { + return new GetUserAddonTemplatesRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetUserAddonTemplatesRequest { + return new GetUserAddonTemplatesRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetUserAddonTemplatesRequest | PlainMessage | undefined, b: GetUserAddonTemplatesRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetUserAddonTemplatesRequest, a, b); + } +} + /** * @generated from message dashboard.v1alpha1.GetUserAddonTemplatesResponse */ @@ -54,6 +91,43 @@ export class GetUserAddonTemplatesResponse extends Message { + /** + * @generated from field: optional bool use_role_filter = 1; + */ + useRoleFilter?: boolean; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "dashboard.v1alpha1.GetWorkspaceTemplatesRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "use_role_filter", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetWorkspaceTemplatesRequest { + return new GetWorkspaceTemplatesRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetWorkspaceTemplatesRequest { + return new GetWorkspaceTemplatesRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetWorkspaceTemplatesRequest { + return new GetWorkspaceTemplatesRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetWorkspaceTemplatesRequest | PlainMessage | undefined, b: GetWorkspaceTemplatesRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetWorkspaceTemplatesRequest, a, b); + } +} + /** * @generated from message dashboard.v1alpha1.GetWorkspaceTemplatesResponse */ diff --git a/web/dashboard-ui/src/views/organisms/UserAddonsChangeDialog.tsx b/web/dashboard-ui/src/views/organisms/UserAddonsChangeDialog.tsx index df9eb891..b8c63dea 100644 --- a/web/dashboard-ui/src/views/organisms/UserAddonsChangeDialog.tsx +++ b/web/dashboard-ui/src/views/organisms/UserAddonsChangeDialog.tsx @@ -45,7 +45,7 @@ export const UserAddonChangeDialog: React.FC<{ onClose: () => void, user: User } }) const templ = useTemplates(); - useEffect(() => { templ.getUserAddonTemplates(); }, []); // eslint-disable-line + useEffect(() => { templ.getAllUserAddonTemplates(); }, []); // eslint-disable-line useEffect(() => { const tt = templ.templates.map(t => ({ template: t, enable: false, vars: [] })); replaceAddons(tt); diff --git a/web/dashboard-ui/src/views/organisms/UserModule.tsx b/web/dashboard-ui/src/views/organisms/UserModule.tsx index 0bdf4771..2bb6ee36 100644 --- a/web/dashboard-ui/src/views/organisms/UserModule.tsx +++ b/web/dashboard-ui/src/views/organisms/UserModule.tsx @@ -222,16 +222,24 @@ export const useTemplates = () => { const templateService = useTemplateService(); const { handleError } = useHandleError(); - const getUserAddonTemplates = () => { + const getAllUserAddonTemplates = () => { console.log('getUserAddonTemplates'); return templateService.getUserAddonTemplates({}) .then(result => { setTemplates(result.items.sort((a, b) => (a.name < b.name) ? -1 : 1)); }) .catch(error => { handleError(error) }); } + const getUserAddonTemplates = () => { + console.log('getUserAddonTemplates'); + return templateService.getUserAddonTemplates({ useRoleFilter: true }) + .then(result => { setTemplates(result.items.sort((a, b) => (a.name < b.name) ? -1 : 1)); }) + .catch(error => { handleError(error) }); + } + return ({ templates, getUserAddonTemplates, + getAllUserAddonTemplates, }); } diff --git a/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx b/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx index 85831414..95c5b7ca 100644 --- a/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx +++ b/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx @@ -198,7 +198,7 @@ export const useTemplates = () => { const getTemplates = async () => { console.log('getTemplates'); try { - const result = await templateService.getWorkspaceTemplates({}); + const result = await templateService.getWorkspaceTemplates({ useRoleFilter: true }); setTemplates(result.items.sort((a, b) => (a.name < b.name) ? -1 : 1)); } catch (error) { handleError(error);