diff --git a/app/cli/cmd/organization.go b/app/cli/cmd/organization.go index c3b076e6b..5ec04e51c 100644 --- a/app/cli/cmd/organization.go +++ b/app/cli/cmd/organization.go @@ -28,6 +28,7 @@ func newOrganizationCmd() *cobra.Command { cmd.AddCommand( newOrganizationList(), + newOrganizationUpdateCmd(), newOrganizationSet(), newOrganizationDescribeCmd(), newOrganizationInvitationCmd(), diff --git a/app/cli/cmd/organization_update.go b/app/cli/cmd/organization_update.go new file mode 100644 index 000000000..b40b7c1c7 --- /dev/null +++ b/app/cli/cmd/organization_update.go @@ -0,0 +1,53 @@ +// +// Copyright 2023 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "context" + + "github.com/chainloop-dev/chainloop/app/cli/internal/action" + "github.com/spf13/cobra" +) + +func newOrganizationUpdateCmd() *cobra.Command { + var orgID, name string + + cmd := &cobra.Command{ + Use: "update", + Short: "Update an existing organization", + RunE: func(cmd *cobra.Command, args []string) error { + opts := &action.NewOrgUpdateOpts{} + if cmd.Flags().Changed("name") { + opts.Name = &name + } + + _, err := action.NewOrgUpdate(actionOpts).Run(context.Background(), orgID, opts) + if err != nil { + return err + } + + logger.Info().Msg("Organization updated!") + return nil + }, + } + + cmd.Flags().StringVar(&orgID, "id", "", "organization ID") + err := cmd.MarkFlagRequired("id") + cobra.CheckErr(err) + + cmd.Flags().StringVar(&name, "name", "", "workflow name") + return cmd +} diff --git a/app/cli/internal/action/membership_list.go b/app/cli/internal/action/membership_list.go index 1beecb302..31570c6e5 100644 --- a/app/cli/internal/action/membership_list.go +++ b/app/cli/internal/action/membership_list.go @@ -58,7 +58,7 @@ func (action *MembershipList) Run() ([]*MembershipItem, error) { return result, nil } -func pbOrgItemToAction(in *pb.Org) *OrgItem { +func pbOrgItemToAction(in *pb.OrgItem) *OrgItem { return &OrgItem{ ID: in.Id, Name: in.Name, diff --git a/app/cli/internal/action/org_update.go b/app/cli/internal/action/org_update.go new file mode 100644 index 000000000..1c764dafc --- /dev/null +++ b/app/cli/internal/action/org_update.go @@ -0,0 +1,47 @@ +// +// Copyright 2023 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package action + +import ( + "context" + + pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1" +) + +type OrgUpdate struct { + cfg *ActionsOpts +} + +func NewOrgUpdate(cfg *ActionsOpts) *OrgUpdate { + return &OrgUpdate{cfg} +} + +type NewOrgUpdateOpts struct { + Name *string +} + +func (action *OrgUpdate) Run(ctx context.Context, id string, opts *NewOrgUpdateOpts) (*OrgItem, error) { + client := pb.NewOrganizationServiceClient(action.cfg.CPConnection) + resp, err := client.Update(ctx, &pb.OrganizationServiceUpdateRequest{ + Id: id, Name: opts.Name, + }) + + if err != nil { + return nil, err + } + + return pbOrgItemToAction(resp.Result), nil +} diff --git a/app/controlplane/api/controlplane/v1/context.pb.go b/app/controlplane/api/controlplane/v1/context.pb.go index d5404c63c..d6df31572 100644 --- a/app/controlplane/api/controlplane/v1/context.pb.go +++ b/app/controlplane/api/controlplane/v1/context.pb.go @@ -126,7 +126,7 @@ type ContextServiceCurrentResponse_Result struct { unknownFields protoimpl.UnknownFields CurrentUser *User `protobuf:"bytes,1,opt,name=current_user,json=currentUser,proto3" json:"current_user,omitempty"` - CurrentOrg *Org `protobuf:"bytes,2,opt,name=current_org,json=currentOrg,proto3" json:"current_org,omitempty"` + CurrentOrg *OrgItem `protobuf:"bytes,2,opt,name=current_org,json=currentOrg,proto3" json:"current_org,omitempty"` CurrentCasBackend *CASBackendItem `protobuf:"bytes,3,opt,name=current_cas_backend,json=currentCasBackend,proto3" json:"current_cas_backend,omitempty"` } @@ -169,7 +169,7 @@ func (x *ContextServiceCurrentResponse_Result) GetCurrentUser() *User { return nil } -func (x *ContextServiceCurrentResponse_Result) GetCurrentOrg() *Org { +func (x *ContextServiceCurrentResponse_Result) GetCurrentOrg() *OrgItem { if x != nil { return x.CurrentOrg } @@ -193,40 +193,40 @@ var file_controlplane_v1_context_proto_rawDesc = []byte{ 0x31, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, 0x1c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xbb, 0x02, 0x0a, 0x1d, 0x43, 0x6f, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xbf, 0x02, 0x0a, 0x1d, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0xca, 0x01, 0x0a, 0x06, 0x52, + 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0xce, 0x01, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x38, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, - 0x35, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6f, 0x72, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x52, 0x0a, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x4f, 0x72, 0x67, 0x12, 0x4f, 0x0a, 0x13, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x5f, 0x63, 0x61, 0x73, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, - 0x49, 0x74, 0x65, 0x6d, 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x61, 0x73, - 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x32, 0x7a, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x07, 0x43, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, - 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, - 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x39, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6f, 0x72, 0x67, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, + 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0a, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4f, 0x72, 0x67, 0x12, 0x4f, 0x0a, 0x13, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x73, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, + 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x43, 0x61, 0x73, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x32, 0x7a, 0x0a, 0x0e, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, + 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, + 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, + 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, + 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -247,13 +247,13 @@ var file_controlplane_v1_context_proto_goTypes = []interface{}{ (*ContextServiceCurrentResponse)(nil), // 1: controlplane.v1.ContextServiceCurrentResponse (*ContextServiceCurrentResponse_Result)(nil), // 2: controlplane.v1.ContextServiceCurrentResponse.Result (*User)(nil), // 3: controlplane.v1.User - (*Org)(nil), // 4: controlplane.v1.Org + (*OrgItem)(nil), // 4: controlplane.v1.OrgItem (*CASBackendItem)(nil), // 5: controlplane.v1.CASBackendItem } var file_controlplane_v1_context_proto_depIdxs = []int32{ 2, // 0: controlplane.v1.ContextServiceCurrentResponse.result:type_name -> controlplane.v1.ContextServiceCurrentResponse.Result 3, // 1: controlplane.v1.ContextServiceCurrentResponse.Result.current_user:type_name -> controlplane.v1.User - 4, // 2: controlplane.v1.ContextServiceCurrentResponse.Result.current_org:type_name -> controlplane.v1.Org + 4, // 2: controlplane.v1.ContextServiceCurrentResponse.Result.current_org:type_name -> controlplane.v1.OrgItem 5, // 3: controlplane.v1.ContextServiceCurrentResponse.Result.current_cas_backend:type_name -> controlplane.v1.CASBackendItem 0, // 4: controlplane.v1.ContextService.Current:input_type -> controlplane.v1.ContextServiceCurrentRequest 1, // 5: controlplane.v1.ContextService.Current:output_type -> controlplane.v1.ContextServiceCurrentResponse diff --git a/app/controlplane/api/controlplane/v1/context.proto b/app/controlplane/api/controlplane/v1/context.proto index 62f56839a..0db394826 100644 --- a/app/controlplane/api/controlplane/v1/context.proto +++ b/app/controlplane/api/controlplane/v1/context.proto @@ -32,7 +32,7 @@ message ContextServiceCurrentResponse { message Result { User current_user = 1; - Org current_org = 2; + OrgItem current_org = 2; CASBackendItem current_cas_backend = 3; } } diff --git a/app/controlplane/api/controlplane/v1/org_invitation.pb.go b/app/controlplane/api/controlplane/v1/org_invitation.pb.go index 6e8a5f97f..02e539a64 100644 --- a/app/controlplane/api/controlplane/v1/org_invitation.pb.go +++ b/app/controlplane/api/controlplane/v1/org_invitation.pb.go @@ -318,7 +318,7 @@ type OrgInvitationItem struct { CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` ReceiverEmail string `protobuf:"bytes,3,opt,name=receiver_email,json=receiverEmail,proto3" json:"receiver_email,omitempty"` Sender *User `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"` - Organization *Org `protobuf:"bytes,5,opt,name=organization,proto3" json:"organization,omitempty"` + Organization *OrgItem `protobuf:"bytes,5,opt,name=organization,proto3" json:"organization,omitempty"` Status string `protobuf:"bytes,6,opt,name=status,proto3" json:"status,omitempty"` } @@ -382,7 +382,7 @@ func (x *OrgInvitationItem) GetSender() *User { return nil } -func (x *OrgInvitationItem) GetOrganization() *Org { +func (x *OrgInvitationItem) GetOrganization() *OrgItem { if x != nil { return x.Organization } @@ -438,7 +438,7 @@ var file_controlplane_v1_org_invitation_proto_rawDesc = []byte{ 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x86, 0x02, 0x0a, 0x11, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x8a, 0x02, 0x0a, 0x11, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, @@ -449,41 +449,41 @@ var file_controlplane_v1_org_invitation_proto_rawDesc = []byte{ 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x2d, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x55, 0x73, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x38, 0x0a, 0x0c, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x3c, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0xf5, - 0x02, 0x0a, 0x14, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0c, 0x6f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x32, 0xf5, 0x02, 0x0a, 0x14, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x06, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x06, 0x52, 0x65, - 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x76, 0x6f, 0x6b, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, - 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, - 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x77, 0x0a, - 0x08, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x34, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, - 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, - 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, - 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, + 0x0a, 0x06, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, + 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, + 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, + 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x77, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x34, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, + 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, + 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, + 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, + 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, + 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -509,14 +509,14 @@ var file_controlplane_v1_org_invitation_proto_goTypes = []interface{}{ (*OrgInvitationItem)(nil), // 6: controlplane.v1.OrgInvitationItem (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp (*User)(nil), // 8: controlplane.v1.User - (*Org)(nil), // 9: controlplane.v1.Org + (*OrgItem)(nil), // 9: controlplane.v1.OrgItem } var file_controlplane_v1_org_invitation_proto_depIdxs = []int32{ 6, // 0: controlplane.v1.OrgInvitationServiceCreateResponse.result:type_name -> controlplane.v1.OrgInvitationItem 6, // 1: controlplane.v1.OrgInvitationServiceListSentResponse.result:type_name -> controlplane.v1.OrgInvitationItem 7, // 2: controlplane.v1.OrgInvitationItem.created_at:type_name -> google.protobuf.Timestamp 8, // 3: controlplane.v1.OrgInvitationItem.sender:type_name -> controlplane.v1.User - 9, // 4: controlplane.v1.OrgInvitationItem.organization:type_name -> controlplane.v1.Org + 9, // 4: controlplane.v1.OrgInvitationItem.organization:type_name -> controlplane.v1.OrgItem 0, // 5: controlplane.v1.OrgInvitationService.Create:input_type -> controlplane.v1.OrgInvitationServiceCreateRequest 2, // 6: controlplane.v1.OrgInvitationService.Revoke:input_type -> controlplane.v1.OrgInvitationServiceRevokeRequest 4, // 7: controlplane.v1.OrgInvitationService.ListSent:input_type -> controlplane.v1.OrgInvitationServiceListSentRequest diff --git a/app/controlplane/api/controlplane/v1/org_invitation.proto b/app/controlplane/api/controlplane/v1/org_invitation.proto index fa7de2b6a..808e802c1 100644 --- a/app/controlplane/api/controlplane/v1/org_invitation.proto +++ b/app/controlplane/api/controlplane/v1/org_invitation.proto @@ -58,6 +58,6 @@ message OrgInvitationItem { google.protobuf.Timestamp created_at = 2; string receiver_email = 3; User sender = 4; - Org organization = 5; + OrgItem organization = 5; string status = 6; } diff --git a/app/controlplane/api/controlplane/v1/organization.pb.go b/app/controlplane/api/controlplane/v1/organization.pb.go index 6f1c8ec04..0aeabd7ad 100644 --- a/app/controlplane/api/controlplane/v1/organization.pb.go +++ b/app/controlplane/api/controlplane/v1/organization.pb.go @@ -121,6 +121,110 @@ func (x *OrganizationServiceListMembershipsResponse) GetResult() []*OrgMembershi return nil } +type OrganizationServiceUpdateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // "optional" allow us to detect if the value is explicitly set + // and not just the default balue + Name *string `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"` +} + +func (x *OrganizationServiceUpdateRequest) Reset() { + *x = OrganizationServiceUpdateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controlplane_v1_organization_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OrganizationServiceUpdateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OrganizationServiceUpdateRequest) ProtoMessage() {} + +func (x *OrganizationServiceUpdateRequest) ProtoReflect() protoreflect.Message { + mi := &file_controlplane_v1_organization_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 OrganizationServiceUpdateRequest.ProtoReflect.Descriptor instead. +func (*OrganizationServiceUpdateRequest) Descriptor() ([]byte, []int) { + return file_controlplane_v1_organization_proto_rawDescGZIP(), []int{2} +} + +func (x *OrganizationServiceUpdateRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *OrganizationServiceUpdateRequest) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +type OrganizationServiceUpdateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Result *OrgItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` +} + +func (x *OrganizationServiceUpdateResponse) Reset() { + *x = OrganizationServiceUpdateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controlplane_v1_organization_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OrganizationServiceUpdateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OrganizationServiceUpdateResponse) ProtoMessage() {} + +func (x *OrganizationServiceUpdateResponse) ProtoReflect() protoreflect.Message { + mi := &file_controlplane_v1_organization_proto_msgTypes[3] + 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 OrganizationServiceUpdateResponse.ProtoReflect.Descriptor instead. +func (*OrganizationServiceUpdateResponse) Descriptor() ([]byte, []int) { + return file_controlplane_v1_organization_proto_rawDescGZIP(), []int{3} +} + +func (x *OrganizationServiceUpdateResponse) GetResult() *OrgItem { + if x != nil { + return x.Result + } + return nil +} + type SetCurrentMembershipRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -132,7 +236,7 @@ type SetCurrentMembershipRequest struct { func (x *SetCurrentMembershipRequest) Reset() { *x = SetCurrentMembershipRequest{} if protoimpl.UnsafeEnabled { - mi := &file_controlplane_v1_organization_proto_msgTypes[2] + mi := &file_controlplane_v1_organization_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -145,7 +249,7 @@ func (x *SetCurrentMembershipRequest) String() string { func (*SetCurrentMembershipRequest) ProtoMessage() {} func (x *SetCurrentMembershipRequest) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_organization_proto_msgTypes[2] + mi := &file_controlplane_v1_organization_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -158,7 +262,7 @@ func (x *SetCurrentMembershipRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SetCurrentMembershipRequest.ProtoReflect.Descriptor instead. func (*SetCurrentMembershipRequest) Descriptor() ([]byte, []int) { - return file_controlplane_v1_organization_proto_rawDescGZIP(), []int{2} + return file_controlplane_v1_organization_proto_rawDescGZIP(), []int{4} } func (x *SetCurrentMembershipRequest) GetMembershipId() string { @@ -179,7 +283,7 @@ type SetCurrentMembershipResponse struct { func (x *SetCurrentMembershipResponse) Reset() { *x = SetCurrentMembershipResponse{} if protoimpl.UnsafeEnabled { - mi := &file_controlplane_v1_organization_proto_msgTypes[3] + mi := &file_controlplane_v1_organization_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -192,7 +296,7 @@ func (x *SetCurrentMembershipResponse) String() string { func (*SetCurrentMembershipResponse) ProtoMessage() {} func (x *SetCurrentMembershipResponse) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_organization_proto_msgTypes[3] + mi := &file_controlplane_v1_organization_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -205,7 +309,7 @@ func (x *SetCurrentMembershipResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SetCurrentMembershipResponse.ProtoReflect.Descriptor instead. func (*SetCurrentMembershipResponse) Descriptor() ([]byte, []int) { - return file_controlplane_v1_organization_proto_rawDescGZIP(), []int{3} + return file_controlplane_v1_organization_proto_rawDescGZIP(), []int{5} } func (x *SetCurrentMembershipResponse) GetResult() *OrgMembershipItem { @@ -234,41 +338,59 @@ var file_controlplane_v1_organization_proto_rawDesc = []byte{ 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, - 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x4c, - 0x0a, 0x1b, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, - 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, - 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x0c, - 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x49, 0x64, 0x22, 0x5a, 0x0a, 0x1c, + 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x5e, + 0x0a, 0x20, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x18, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, + 0xfa, 0x42, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x55, + 0x0a, 0x21, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, + 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x4c, 0x0a, 0x1b, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, + 0x69, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, + 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x0c, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, + 0x70, 0x49, 0x64, 0x22, 0x5a, 0x0a, 0x1c, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, + 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x68, 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, + 0x88, 0x03, 0x0a, 0x13, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8a, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, + 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x73, 0x12, 0x3a, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, + 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6f, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x31, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x14, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x12, 0x2c, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, - 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x06, - 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, - 0x72, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, - 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0x97, 0x02, 0x0a, 0x13, 0x4f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x8a, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, - 0x68, 0x69, 0x70, 0x73, 0x12, 0x3a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x3b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, - 0x73, 0x68, 0x69, 0x70, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, - 0x14, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x73, 0x68, 0x69, 0x70, 0x12, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, - 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, - 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, + 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, + 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, + 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, + 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, + 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, + 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -283,26 +405,32 @@ func file_controlplane_v1_organization_proto_rawDescGZIP() []byte { return file_controlplane_v1_organization_proto_rawDescData } -var file_controlplane_v1_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_controlplane_v1_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_controlplane_v1_organization_proto_goTypes = []interface{}{ (*OrganizationServiceListMembershipsRequest)(nil), // 0: controlplane.v1.OrganizationServiceListMembershipsRequest (*OrganizationServiceListMembershipsResponse)(nil), // 1: controlplane.v1.OrganizationServiceListMembershipsResponse - (*SetCurrentMembershipRequest)(nil), // 2: controlplane.v1.SetCurrentMembershipRequest - (*SetCurrentMembershipResponse)(nil), // 3: controlplane.v1.SetCurrentMembershipResponse - (*OrgMembershipItem)(nil), // 4: controlplane.v1.OrgMembershipItem + (*OrganizationServiceUpdateRequest)(nil), // 2: controlplane.v1.OrganizationServiceUpdateRequest + (*OrganizationServiceUpdateResponse)(nil), // 3: controlplane.v1.OrganizationServiceUpdateResponse + (*SetCurrentMembershipRequest)(nil), // 4: controlplane.v1.SetCurrentMembershipRequest + (*SetCurrentMembershipResponse)(nil), // 5: controlplane.v1.SetCurrentMembershipResponse + (*OrgMembershipItem)(nil), // 6: controlplane.v1.OrgMembershipItem + (*OrgItem)(nil), // 7: controlplane.v1.OrgItem } var file_controlplane_v1_organization_proto_depIdxs = []int32{ - 4, // 0: controlplane.v1.OrganizationServiceListMembershipsResponse.result:type_name -> controlplane.v1.OrgMembershipItem - 4, // 1: controlplane.v1.SetCurrentMembershipResponse.result:type_name -> controlplane.v1.OrgMembershipItem - 0, // 2: controlplane.v1.OrganizationService.ListMemberships:input_type -> controlplane.v1.OrganizationServiceListMembershipsRequest - 2, // 3: controlplane.v1.OrganizationService.SetCurrentMembership:input_type -> controlplane.v1.SetCurrentMembershipRequest - 1, // 4: controlplane.v1.OrganizationService.ListMemberships:output_type -> controlplane.v1.OrganizationServiceListMembershipsResponse - 3, // 5: controlplane.v1.OrganizationService.SetCurrentMembership:output_type -> controlplane.v1.SetCurrentMembershipResponse - 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 - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 6, // 0: controlplane.v1.OrganizationServiceListMembershipsResponse.result:type_name -> controlplane.v1.OrgMembershipItem + 7, // 1: controlplane.v1.OrganizationServiceUpdateResponse.result:type_name -> controlplane.v1.OrgItem + 6, // 2: controlplane.v1.SetCurrentMembershipResponse.result:type_name -> controlplane.v1.OrgMembershipItem + 0, // 3: controlplane.v1.OrganizationService.ListMemberships:input_type -> controlplane.v1.OrganizationServiceListMembershipsRequest + 2, // 4: controlplane.v1.OrganizationService.Update:input_type -> controlplane.v1.OrganizationServiceUpdateRequest + 4, // 5: controlplane.v1.OrganizationService.SetCurrentMembership:input_type -> controlplane.v1.SetCurrentMembershipRequest + 1, // 6: controlplane.v1.OrganizationService.ListMemberships:output_type -> controlplane.v1.OrganizationServiceListMembershipsResponse + 3, // 7: controlplane.v1.OrganizationService.Update:output_type -> controlplane.v1.OrganizationServiceUpdateResponse + 5, // 8: controlplane.v1.OrganizationService.SetCurrentMembership:output_type -> controlplane.v1.SetCurrentMembershipResponse + 6, // [6:9] is the sub-list for method output_type + 3, // [3:6] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_controlplane_v1_organization_proto_init() } @@ -337,7 +465,7 @@ func file_controlplane_v1_organization_proto_init() { } } file_controlplane_v1_organization_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetCurrentMembershipRequest); i { + switch v := v.(*OrganizationServiceUpdateRequest); i { case 0: return &v.state case 1: @@ -349,6 +477,30 @@ func file_controlplane_v1_organization_proto_init() { } } file_controlplane_v1_organization_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OrganizationServiceUpdateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controlplane_v1_organization_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SetCurrentMembershipRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controlplane_v1_organization_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SetCurrentMembershipResponse); i { case 0: return &v.state @@ -361,13 +513,14 @@ func file_controlplane_v1_organization_proto_init() { } } } + file_controlplane_v1_organization_proto_msgTypes[2].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controlplane_v1_organization_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/app/controlplane/api/controlplane/v1/organization.pb.validate.go b/app/controlplane/api/controlplane/v1/organization.pb.validate.go index bdeb7e8d1..c95d38169 100644 --- a/app/controlplane/api/controlplane/v1/organization.pb.validate.go +++ b/app/controlplane/api/controlplane/v1/organization.pb.validate.go @@ -284,6 +284,269 @@ var _ interface { ErrorName() string } = OrganizationServiceListMembershipsResponseValidationError{} +// Validate checks the field values on OrganizationServiceUpdateRequest 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 *OrganizationServiceUpdateRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on OrganizationServiceUpdateRequest 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 +// OrganizationServiceUpdateRequestMultiError, or nil if none found. +func (m *OrganizationServiceUpdateRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *OrganizationServiceUpdateRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if err := m._validateUuid(m.GetId()); err != nil { + err = OrganizationServiceUpdateRequestValidationError{ + field: "Id", + reason: "value must be a valid UUID", + cause: err, + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.Name != nil { + // no validation rules for Name + } + + if len(errors) > 0 { + return OrganizationServiceUpdateRequestMultiError(errors) + } + + return nil +} + +func (m *OrganizationServiceUpdateRequest) _validateUuid(uuid string) error { + if matched := _organization_uuidPattern.MatchString(uuid); !matched { + return errors.New("invalid uuid format") + } + + return nil +} + +// OrganizationServiceUpdateRequestMultiError is an error wrapping multiple +// validation errors returned by +// OrganizationServiceUpdateRequest.ValidateAll() if the designated +// constraints aren't met. +type OrganizationServiceUpdateRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OrganizationServiceUpdateRequestMultiError) 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 OrganizationServiceUpdateRequestMultiError) AllErrors() []error { return m } + +// OrganizationServiceUpdateRequestValidationError is the validation error +// returned by OrganizationServiceUpdateRequest.Validate if the designated +// constraints aren't met. +type OrganizationServiceUpdateRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e OrganizationServiceUpdateRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e OrganizationServiceUpdateRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e OrganizationServiceUpdateRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e OrganizationServiceUpdateRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e OrganizationServiceUpdateRequestValidationError) ErrorName() string { + return "OrganizationServiceUpdateRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e OrganizationServiceUpdateRequestValidationError) 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 %sOrganizationServiceUpdateRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = OrganizationServiceUpdateRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = OrganizationServiceUpdateRequestValidationError{} + +// Validate checks the field values on OrganizationServiceUpdateResponse 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 *OrganizationServiceUpdateResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on OrganizationServiceUpdateResponse +// 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 +// OrganizationServiceUpdateResponseMultiError, or nil if none found. +func (m *OrganizationServiceUpdateResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *OrganizationServiceUpdateResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OrganizationServiceUpdateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OrganizationServiceUpdateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OrganizationServiceUpdateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return OrganizationServiceUpdateResponseMultiError(errors) + } + + return nil +} + +// OrganizationServiceUpdateResponseMultiError is an error wrapping multiple +// validation errors returned by +// OrganizationServiceUpdateResponse.ValidateAll() if the designated +// constraints aren't met. +type OrganizationServiceUpdateResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OrganizationServiceUpdateResponseMultiError) 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 OrganizationServiceUpdateResponseMultiError) AllErrors() []error { return m } + +// OrganizationServiceUpdateResponseValidationError is the validation error +// returned by OrganizationServiceUpdateResponse.Validate if the designated +// constraints aren't met. +type OrganizationServiceUpdateResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e OrganizationServiceUpdateResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e OrganizationServiceUpdateResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e OrganizationServiceUpdateResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e OrganizationServiceUpdateResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e OrganizationServiceUpdateResponseValidationError) ErrorName() string { + return "OrganizationServiceUpdateResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e OrganizationServiceUpdateResponseValidationError) 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 %sOrganizationServiceUpdateResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = OrganizationServiceUpdateResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = OrganizationServiceUpdateResponseValidationError{} + // Validate checks the field values on SetCurrentMembershipRequest 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/app/controlplane/api/controlplane/v1/organization.proto b/app/controlplane/api/controlplane/v1/organization.proto index 376ebd3c5..c9f445682 100644 --- a/app/controlplane/api/controlplane/v1/organization.proto +++ b/app/controlplane/api/controlplane/v1/organization.proto @@ -24,6 +24,7 @@ import "validate/validate.proto"; service OrganizationService { // List the organizations this user has access to rpc ListMemberships (OrganizationServiceListMembershipsRequest) returns (OrganizationServiceListMembershipsResponse); + rpc Update (OrganizationServiceUpdateRequest) returns (OrganizationServiceUpdateResponse); rpc SetCurrentMembership (SetCurrentMembershipRequest) returns (SetCurrentMembershipResponse); } @@ -33,6 +34,17 @@ message OrganizationServiceListMembershipsResponse { repeated OrgMembershipItem result = 1; } +message OrganizationServiceUpdateRequest { + string id = 1 [(validate.rules).string.uuid = true]; + // "optional" allow us to detect if the value is explicitly set + // and not just the default balue + optional string name = 2; +} + +message OrganizationServiceUpdateResponse { + OrgItem result = 1; +} + message SetCurrentMembershipRequest { string membership_id = 1 [(validate.rules).string.uuid = true]; } diff --git a/app/controlplane/api/controlplane/v1/organization_grpc.pb.go b/app/controlplane/api/controlplane/v1/organization_grpc.pb.go index 0a8f69adc..36e3b28b8 100644 --- a/app/controlplane/api/controlplane/v1/organization_grpc.pb.go +++ b/app/controlplane/api/controlplane/v1/organization_grpc.pb.go @@ -35,6 +35,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( OrganizationService_ListMemberships_FullMethodName = "/controlplane.v1.OrganizationService/ListMemberships" + OrganizationService_Update_FullMethodName = "/controlplane.v1.OrganizationService/Update" OrganizationService_SetCurrentMembership_FullMethodName = "/controlplane.v1.OrganizationService/SetCurrentMembership" ) @@ -44,6 +45,7 @@ const ( type OrganizationServiceClient interface { // List the organizations this user has access to ListMemberships(ctx context.Context, in *OrganizationServiceListMembershipsRequest, opts ...grpc.CallOption) (*OrganizationServiceListMembershipsResponse, error) + Update(ctx context.Context, in *OrganizationServiceUpdateRequest, opts ...grpc.CallOption) (*OrganizationServiceUpdateResponse, error) SetCurrentMembership(ctx context.Context, in *SetCurrentMembershipRequest, opts ...grpc.CallOption) (*SetCurrentMembershipResponse, error) } @@ -64,6 +66,15 @@ func (c *organizationServiceClient) ListMemberships(ctx context.Context, in *Org return out, nil } +func (c *organizationServiceClient) Update(ctx context.Context, in *OrganizationServiceUpdateRequest, opts ...grpc.CallOption) (*OrganizationServiceUpdateResponse, error) { + out := new(OrganizationServiceUpdateResponse) + err := c.cc.Invoke(ctx, OrganizationService_Update_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *organizationServiceClient) SetCurrentMembership(ctx context.Context, in *SetCurrentMembershipRequest, opts ...grpc.CallOption) (*SetCurrentMembershipResponse, error) { out := new(SetCurrentMembershipResponse) err := c.cc.Invoke(ctx, OrganizationService_SetCurrentMembership_FullMethodName, in, out, opts...) @@ -79,6 +90,7 @@ func (c *organizationServiceClient) SetCurrentMembership(ctx context.Context, in type OrganizationServiceServer interface { // List the organizations this user has access to ListMemberships(context.Context, *OrganizationServiceListMembershipsRequest) (*OrganizationServiceListMembershipsResponse, error) + Update(context.Context, *OrganizationServiceUpdateRequest) (*OrganizationServiceUpdateResponse, error) SetCurrentMembership(context.Context, *SetCurrentMembershipRequest) (*SetCurrentMembershipResponse, error) mustEmbedUnimplementedOrganizationServiceServer() } @@ -90,6 +102,9 @@ type UnimplementedOrganizationServiceServer struct { func (UnimplementedOrganizationServiceServer) ListMemberships(context.Context, *OrganizationServiceListMembershipsRequest) (*OrganizationServiceListMembershipsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListMemberships not implemented") } +func (UnimplementedOrganizationServiceServer) Update(context.Context, *OrganizationServiceUpdateRequest) (*OrganizationServiceUpdateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") +} func (UnimplementedOrganizationServiceServer) SetCurrentMembership(context.Context, *SetCurrentMembershipRequest) (*SetCurrentMembershipResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetCurrentMembership not implemented") } @@ -124,6 +139,24 @@ func _OrganizationService_ListMemberships_Handler(srv interface{}, ctx context.C return interceptor(ctx, in, info, handler) } +func _OrganizationService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OrganizationServiceUpdateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrganizationServiceServer).Update(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: OrganizationService_Update_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrganizationServiceServer).Update(ctx, req.(*OrganizationServiceUpdateRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _OrganizationService_SetCurrentMembership_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SetCurrentMembershipRequest) if err := dec(in); err != nil { @@ -153,6 +186,10 @@ var OrganizationService_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListMemberships", Handler: _OrganizationService_ListMemberships_Handler, }, + { + MethodName: "Update", + Handler: _OrganizationService_Update_Handler, + }, { MethodName: "SetCurrentMembership", Handler: _OrganizationService_SetCurrentMembership_Handler, diff --git a/app/controlplane/api/controlplane/v1/response_messages.pb.go b/app/controlplane/api/controlplane/v1/response_messages.pb.go index 28ef44d8b..6b5a95631 100644 --- a/app/controlplane/api/controlplane/v1/response_messages.pb.go +++ b/app/controlplane/api/controlplane/v1/response_messages.pb.go @@ -681,7 +681,7 @@ type OrgMembershipItem struct { unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Org *Org `protobuf:"bytes,2,opt,name=org,proto3" json:"org,omitempty"` + Org *OrgItem `protobuf:"bytes,2,opt,name=org,proto3" json:"org,omitempty"` Current bool `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` @@ -726,7 +726,7 @@ func (x *OrgMembershipItem) GetId() string { return "" } -func (x *OrgMembershipItem) GetOrg() *Org { +func (x *OrgMembershipItem) GetOrg() *OrgItem { if x != nil { return x.Org } @@ -754,7 +754,7 @@ func (x *OrgMembershipItem) GetUpdatedAt() *timestamppb.Timestamp { return nil } -type Org struct { +type OrgItem struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -764,8 +764,8 @@ type Org struct { CreatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` } -func (x *Org) Reset() { - *x = Org{} +func (x *OrgItem) Reset() { + *x = OrgItem{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_response_messages_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -773,13 +773,13 @@ func (x *Org) Reset() { } } -func (x *Org) String() string { +func (x *OrgItem) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Org) ProtoMessage() {} +func (*OrgItem) ProtoMessage() {} -func (x *Org) ProtoReflect() protoreflect.Message { +func (x *OrgItem) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_response_messages_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -791,26 +791,26 @@ func (x *Org) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Org.ProtoReflect.Descriptor instead. -func (*Org) Descriptor() ([]byte, []int) { +// Deprecated: Use OrgItem.ProtoReflect.Descriptor instead. +func (*OrgItem) Descriptor() ([]byte, []int) { return file_controlplane_v1_response_messages_proto_rawDescGZIP(), []int{7} } -func (x *Org) GetId() string { +func (x *OrgItem) GetId() string { if x != nil { return x.Id } return "" } -func (x *Org) GetName() string { +func (x *OrgItem) GetName() string { if x != nil { return x.Name } return "" } -func (x *Org) GetCreatedAt() *timestamppb.Timestamp { +func (x *OrgItem) GetCreatedAt() *timestamppb.Timestamp { if x != nil { return x.CreatedAt } @@ -1296,77 +1296,77 @@ var file_controlplane_v1_response_messages_proto_rawDesc = []byte{ 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x22, 0xdb, 0x01, 0x0a, 0x11, 0x4f, 0x72, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x74, 0x22, 0xdf, 0x01, 0x0a, 0x11, 0x4f, 0x72, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x03, 0x6f, 0x72, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x52, 0x03, 0x6f, 0x72, 0x67, 0x12, - 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, - 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, - 0x64, 0x0a, 0x03, 0x4f, 0x72, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xe1, 0x04, 0x0a, 0x0e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, - 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, - 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, - 0x12, 0x5d, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, - 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x10, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x3e, 0x0a, 0x06, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, - 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, - 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x06, 0x6c, - 0x69, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x6c, 0x69, - 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x49, 0x6e, 0x6c, 0x69, - 0x6e, 0x65, 0x1a, 0x25, 0x0a, 0x06, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, - 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x08, 0x6d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x6e, 0x0a, 0x10, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, - 0x1d, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x18, 0x0a, 0x14, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, - 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x56, 0x41, - 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x02, 0x2a, 0x60, 0x0a, 0x0e, 0x41, 0x6c, 0x6c, - 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x20, 0x0a, 0x1c, 0x41, - 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x26, 0x0a, - 0x1c, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, - 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4e, 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x10, 0x01, 0x1a, - 0x04, 0xa8, 0x45, 0x93, 0x03, 0x1a, 0x04, 0xa0, 0x45, 0xf4, 0x03, 0x42, 0x4c, 0x5a, 0x4a, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, - 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, - 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2a, 0x0a, 0x03, 0x6f, 0x72, 0x67, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, + 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x03, + 0x6f, 0x72, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x39, 0x0a, + 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x64, 0x41, 0x74, 0x22, 0x68, 0x0a, 0x07, 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xe1, 0x04, + 0x0a, 0x0e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, + 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x5d, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, + 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, + 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x3e, 0x0a, + 0x06, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x4c, + 0x69, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x06, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, + 0x09, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x08, 0x69, 0x73, 0x49, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x25, 0x0a, 0x06, 0x4c, 0x69, + 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, + 0x73, 0x22, 0x6e, 0x0a, 0x10, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, 0x1d, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x56, 0x41, 0x4c, 0x49, + 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x4b, + 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, + 0x02, 0x2a, 0x60, 0x0a, 0x0e, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x4c, 0x49, 0x53, + 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x26, 0x0a, 0x1c, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x4c, + 0x49, 0x53, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4e, + 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x10, 0x01, 0x1a, 0x04, 0xa8, 0x45, 0x93, 0x03, 0x1a, 0x04, 0xa0, + 0x45, 0xf4, 0x03, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1393,7 +1393,7 @@ var file_controlplane_v1_response_messages_proto_goTypes = []interface{}{ (*WorkflowContractVersionItem)(nil), // 6: controlplane.v1.WorkflowContractVersionItem (*User)(nil), // 7: controlplane.v1.User (*OrgMembershipItem)(nil), // 8: controlplane.v1.OrgMembershipItem - (*Org)(nil), // 9: controlplane.v1.Org + (*OrgItem)(nil), // 9: controlplane.v1.OrgItem (*CASBackendItem)(nil), // 10: controlplane.v1.CASBackendItem nil, // 11: controlplane.v1.AttestationItem.AnnotationsEntry (*AttestationItem_EnvVariable)(nil), // 12: controlplane.v1.AttestationItem.EnvVariable @@ -1419,10 +1419,10 @@ var file_controlplane_v1_response_messages_proto_depIdxs = []int32{ 16, // 11: controlplane.v1.WorkflowContractVersionItem.created_at:type_name -> google.protobuf.Timestamp 18, // 12: controlplane.v1.WorkflowContractVersionItem.v1:type_name -> workflowcontract.v1.CraftingSchema 16, // 13: controlplane.v1.User.created_at:type_name -> google.protobuf.Timestamp - 9, // 14: controlplane.v1.OrgMembershipItem.org:type_name -> controlplane.v1.Org + 9, // 14: controlplane.v1.OrgMembershipItem.org:type_name -> controlplane.v1.OrgItem 16, // 15: controlplane.v1.OrgMembershipItem.created_at:type_name -> google.protobuf.Timestamp 16, // 16: controlplane.v1.OrgMembershipItem.updated_at:type_name -> google.protobuf.Timestamp - 16, // 17: controlplane.v1.Org.created_at:type_name -> google.protobuf.Timestamp + 16, // 17: controlplane.v1.OrgItem.created_at:type_name -> google.protobuf.Timestamp 16, // 18: controlplane.v1.CASBackendItem.created_at:type_name -> google.protobuf.Timestamp 16, // 19: controlplane.v1.CASBackendItem.validated_at:type_name -> google.protobuf.Timestamp 1, // 20: controlplane.v1.CASBackendItem.validation_status:type_name -> controlplane.v1.CASBackendItem.ValidationStatus @@ -1526,7 +1526,7 @@ func file_controlplane_v1_response_messages_proto_init() { } } file_controlplane_v1_response_messages_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Org); i { + switch v := v.(*OrgItem); i { case 0: return &v.state case 1: diff --git a/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go b/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go index 3e3a9b5fa..0d3f546c5 100644 --- a/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go +++ b/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go @@ -1253,21 +1253,21 @@ var _ interface { ErrorName() string } = OrgMembershipItemValidationError{} -// Validate checks the field values on Org 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 *Org) Validate() error { +// Validate checks the field values on OrgItem 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 *OrgItem) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on Org with the rules defined in the +// ValidateAll checks the field values on OrgItem 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 OrgMultiError, or nil if none found. -func (m *Org) ValidateAll() error { +// a list of violation errors wrapped in OrgItemMultiError, or nil if none found. +func (m *OrgItem) ValidateAll() error { return m.validate(true) } -func (m *Org) validate(all bool) error { +func (m *OrgItem) validate(all bool) error { if m == nil { return nil } @@ -1282,7 +1282,7 @@ func (m *Org) validate(all bool) error { switch v := interface{}(m.GetCreatedAt()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, OrgValidationError{ + errors = append(errors, OrgItemValidationError{ field: "CreatedAt", reason: "embedded message failed validation", cause: err, @@ -1290,7 +1290,7 @@ func (m *Org) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, OrgValidationError{ + errors = append(errors, OrgItemValidationError{ field: "CreatedAt", reason: "embedded message failed validation", cause: err, @@ -1299,7 +1299,7 @@ func (m *Org) validate(all bool) error { } } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return OrgValidationError{ + return OrgItemValidationError{ field: "CreatedAt", reason: "embedded message failed validation", cause: err, @@ -1308,18 +1308,18 @@ func (m *Org) validate(all bool) error { } if len(errors) > 0 { - return OrgMultiError(errors) + return OrgItemMultiError(errors) } return nil } -// OrgMultiError is an error wrapping multiple validation errors returned by -// Org.ValidateAll() if the designated constraints aren't met. -type OrgMultiError []error +// OrgItemMultiError is an error wrapping multiple validation errors returned +// by OrgItem.ValidateAll() if the designated constraints aren't met. +type OrgItemMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m OrgMultiError) Error() string { +func (m OrgItemMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -1328,11 +1328,11 @@ func (m OrgMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m OrgMultiError) AllErrors() []error { return m } +func (m OrgItemMultiError) AllErrors() []error { return m } -// OrgValidationError is the validation error returned by Org.Validate if the -// designated constraints aren't met. -type OrgValidationError struct { +// OrgItemValidationError is the validation error returned by OrgItem.Validate +// if the designated constraints aren't met. +type OrgItemValidationError struct { field string reason string cause error @@ -1340,22 +1340,22 @@ type OrgValidationError struct { } // Field function returns field value. -func (e OrgValidationError) Field() string { return e.field } +func (e OrgItemValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e OrgValidationError) Reason() string { return e.reason } +func (e OrgItemValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e OrgValidationError) Cause() error { return e.cause } +func (e OrgItemValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e OrgValidationError) Key() bool { return e.key } +func (e OrgItemValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e OrgValidationError) ErrorName() string { return "OrgValidationError" } +func (e OrgItemValidationError) ErrorName() string { return "OrgItemValidationError" } // Error satisfies the builtin error interface -func (e OrgValidationError) Error() string { +func (e OrgItemValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1367,14 +1367,14 @@ func (e OrgValidationError) Error() string { } return fmt.Sprintf( - "invalid %sOrg.%s: %s%s", + "invalid %sOrgItem.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = OrgValidationError{} +var _ error = OrgItemValidationError{} var _ interface { Field() string @@ -1382,7 +1382,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = OrgValidationError{} +} = OrgItemValidationError{} // Validate checks the field values on CASBackendItem with the rules defined in // the proto definition for this message. If any rules are violated, the first diff --git a/app/controlplane/api/controlplane/v1/response_messages.proto b/app/controlplane/api/controlplane/v1/response_messages.proto index 8d45e2edb..63610ada2 100644 --- a/app/controlplane/api/controlplane/v1/response_messages.proto +++ b/app/controlplane/api/controlplane/v1/response_messages.proto @@ -111,13 +111,13 @@ message User { message OrgMembershipItem { string id = 1; - Org org = 2; + OrgItem org = 2; bool current = 3; google.protobuf.Timestamp created_at = 4; google.protobuf.Timestamp updated_at = 5; } -message Org { +message OrgItem { string id = 1; string name = 2; google.protobuf.Timestamp created_at = 3; diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/context.ts b/app/controlplane/api/gen/frontend/controlplane/v1/context.ts index c9054d98c..a8439a938 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/context.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/context.ts @@ -2,7 +2,7 @@ import { grpc } from "@improbable-eng/grpc-web"; import { BrowserHeaders } from "browser-headers"; import _m0 from "protobufjs/minimal"; -import { CASBackendItem, Org, User } from "./response_messages"; +import { CASBackendItem, OrgItem, User } from "./response_messages"; export const protobufPackage = "controlplane.v1"; @@ -15,7 +15,7 @@ export interface ContextServiceCurrentResponse { export interface ContextServiceCurrentResponse_Result { currentUser?: User; - currentOrg?: Org; + currentOrg?: OrgItem; currentCasBackend?: CASBackendItem; } @@ -134,7 +134,7 @@ export const ContextServiceCurrentResponse_Result = { User.encode(message.currentUser, writer.uint32(10).fork()).ldelim(); } if (message.currentOrg !== undefined) { - Org.encode(message.currentOrg, writer.uint32(18).fork()).ldelim(); + OrgItem.encode(message.currentOrg, writer.uint32(18).fork()).ldelim(); } if (message.currentCasBackend !== undefined) { CASBackendItem.encode(message.currentCasBackend, writer.uint32(26).fork()).ldelim(); @@ -161,7 +161,7 @@ export const ContextServiceCurrentResponse_Result = { break; } - message.currentOrg = Org.decode(reader, reader.uint32()); + message.currentOrg = OrgItem.decode(reader, reader.uint32()); continue; case 3: if (tag !== 26) { @@ -182,7 +182,7 @@ export const ContextServiceCurrentResponse_Result = { fromJSON(object: any): ContextServiceCurrentResponse_Result { return { currentUser: isSet(object.currentUser) ? User.fromJSON(object.currentUser) : undefined, - currentOrg: isSet(object.currentOrg) ? Org.fromJSON(object.currentOrg) : undefined, + currentOrg: isSet(object.currentOrg) ? OrgItem.fromJSON(object.currentOrg) : undefined, currentCasBackend: isSet(object.currentCasBackend) ? CASBackendItem.fromJSON(object.currentCasBackend) : undefined, @@ -194,7 +194,7 @@ export const ContextServiceCurrentResponse_Result = { message.currentUser !== undefined && (obj.currentUser = message.currentUser ? User.toJSON(message.currentUser) : undefined); message.currentOrg !== undefined && - (obj.currentOrg = message.currentOrg ? Org.toJSON(message.currentOrg) : undefined); + (obj.currentOrg = message.currentOrg ? OrgItem.toJSON(message.currentOrg) : undefined); message.currentCasBackend !== undefined && (obj.currentCasBackend = message.currentCasBackend ? CASBackendItem.toJSON(message.currentCasBackend) @@ -216,7 +216,7 @@ export const ContextServiceCurrentResponse_Result = { ? User.fromPartial(object.currentUser) : undefined; message.currentOrg = (object.currentOrg !== undefined && object.currentOrg !== null) - ? Org.fromPartial(object.currentOrg) + ? OrgItem.fromPartial(object.currentOrg) : undefined; message.currentCasBackend = (object.currentCasBackend !== undefined && object.currentCasBackend !== null) ? CASBackendItem.fromPartial(object.currentCasBackend) diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/org_invitation.ts b/app/controlplane/api/gen/frontend/controlplane/v1/org_invitation.ts index d1b117eb9..85c4536cf 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/org_invitation.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/org_invitation.ts @@ -3,7 +3,7 @@ import { grpc } from "@improbable-eng/grpc-web"; import { BrowserHeaders } from "browser-headers"; import _m0 from "protobufjs/minimal"; import { Timestamp } from "../../google/protobuf/timestamp"; -import { Org, User } from "./response_messages"; +import { OrgItem, User } from "./response_messages"; export const protobufPackage = "controlplane.v1"; @@ -35,7 +35,7 @@ export interface OrgInvitationItem { createdAt?: Date; receiverEmail: string; sender?: User; - organization?: Org; + organization?: OrgItem; status: string; } @@ -418,7 +418,7 @@ export const OrgInvitationItem = { User.encode(message.sender, writer.uint32(34).fork()).ldelim(); } if (message.organization !== undefined) { - Org.encode(message.organization, writer.uint32(42).fork()).ldelim(); + OrgItem.encode(message.organization, writer.uint32(42).fork()).ldelim(); } if (message.status !== "") { writer.uint32(50).string(message.status); @@ -466,7 +466,7 @@ export const OrgInvitationItem = { break; } - message.organization = Org.decode(reader, reader.uint32()); + message.organization = OrgItem.decode(reader, reader.uint32()); continue; case 6: if (tag !== 50) { @@ -490,7 +490,7 @@ export const OrgInvitationItem = { createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, receiverEmail: isSet(object.receiverEmail) ? String(object.receiverEmail) : "", sender: isSet(object.sender) ? User.fromJSON(object.sender) : undefined, - organization: isSet(object.organization) ? Org.fromJSON(object.organization) : undefined, + organization: isSet(object.organization) ? OrgItem.fromJSON(object.organization) : undefined, status: isSet(object.status) ? String(object.status) : "", }; }, @@ -502,7 +502,7 @@ export const OrgInvitationItem = { message.receiverEmail !== undefined && (obj.receiverEmail = message.receiverEmail); message.sender !== undefined && (obj.sender = message.sender ? User.toJSON(message.sender) : undefined); message.organization !== undefined && - (obj.organization = message.organization ? Org.toJSON(message.organization) : undefined); + (obj.organization = message.organization ? OrgItem.toJSON(message.organization) : undefined); message.status !== undefined && (obj.status = message.status); return obj; }, @@ -520,7 +520,7 @@ export const OrgInvitationItem = { ? User.fromPartial(object.sender) : undefined; message.organization = (object.organization !== undefined && object.organization !== null) - ? Org.fromPartial(object.organization) + ? OrgItem.fromPartial(object.organization) : undefined; message.status = object.status ?? ""; return message; diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts b/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts index ec44d600f..3dc5991d4 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts @@ -2,7 +2,7 @@ import { grpc } from "@improbable-eng/grpc-web"; import { BrowserHeaders } from "browser-headers"; import _m0 from "protobufjs/minimal"; -import { OrgMembershipItem } from "./response_messages"; +import { OrgItem, OrgMembershipItem } from "./response_messages"; export const protobufPackage = "controlplane.v1"; @@ -13,6 +13,19 @@ export interface OrganizationServiceListMembershipsResponse { result: OrgMembershipItem[]; } +export interface OrganizationServiceUpdateRequest { + id: string; + /** + * "optional" allow us to detect if the value is explicitly set + * and not just the default balue + */ + name?: string | undefined; +} + +export interface OrganizationServiceUpdateResponse { + result?: OrgItem; +} + export interface SetCurrentMembershipRequest { membershipId: string; } @@ -135,6 +148,143 @@ export const OrganizationServiceListMembershipsResponse = { }, }; +function createBaseOrganizationServiceUpdateRequest(): OrganizationServiceUpdateRequest { + return { id: "", name: undefined }; +} + +export const OrganizationServiceUpdateRequest = { + encode(message: OrganizationServiceUpdateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.name !== undefined) { + writer.uint32(18).string(message.name); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OrganizationServiceUpdateRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOrganizationServiceUpdateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.id = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.name = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OrganizationServiceUpdateRequest { + return { + id: isSet(object.id) ? String(object.id) : "", + name: isSet(object.name) ? String(object.name) : undefined, + }; + }, + + toJSON(message: OrganizationServiceUpdateRequest): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.name !== undefined && (obj.name = message.name); + return obj; + }, + + create, I>>( + base?: I, + ): OrganizationServiceUpdateRequest { + return OrganizationServiceUpdateRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>( + object: I, + ): OrganizationServiceUpdateRequest { + const message = createBaseOrganizationServiceUpdateRequest(); + message.id = object.id ?? ""; + message.name = object.name ?? undefined; + return message; + }, +}; + +function createBaseOrganizationServiceUpdateResponse(): OrganizationServiceUpdateResponse { + return { result: undefined }; +} + +export const OrganizationServiceUpdateResponse = { + encode(message: OrganizationServiceUpdateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.result !== undefined) { + OrgItem.encode(message.result, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OrganizationServiceUpdateResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOrganizationServiceUpdateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.result = OrgItem.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OrganizationServiceUpdateResponse { + return { result: isSet(object.result) ? OrgItem.fromJSON(object.result) : undefined }; + }, + + toJSON(message: OrganizationServiceUpdateResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = message.result ? OrgItem.toJSON(message.result) : undefined); + return obj; + }, + + create, I>>( + base?: I, + ): OrganizationServiceUpdateResponse { + return OrganizationServiceUpdateResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>( + object: I, + ): OrganizationServiceUpdateResponse { + const message = createBaseOrganizationServiceUpdateResponse(); + message.result = (object.result !== undefined && object.result !== null) + ? OrgItem.fromPartial(object.result) + : undefined; + return message; + }, +}; + function createBaseSetCurrentMembershipRequest(): SetCurrentMembershipRequest { return { membershipId: "" }; } @@ -256,6 +406,10 @@ export interface OrganizationService { request: DeepPartial, metadata?: grpc.Metadata, ): Promise; + Update( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise; SetCurrentMembership( request: DeepPartial, metadata?: grpc.Metadata, @@ -268,6 +422,7 @@ export class OrganizationServiceClientImpl implements OrganizationService { constructor(rpc: Rpc) { this.rpc = rpc; this.ListMemberships = this.ListMemberships.bind(this); + this.Update = this.Update.bind(this); this.SetCurrentMembership = this.SetCurrentMembership.bind(this); } @@ -282,6 +437,17 @@ export class OrganizationServiceClientImpl implements OrganizationService { ); } + Update( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise { + return this.rpc.unary( + OrganizationServiceUpdateDesc, + OrganizationServiceUpdateRequest.fromPartial(request), + metadata, + ); + } + SetCurrentMembership( request: DeepPartial, metadata?: grpc.Metadata, @@ -319,6 +485,29 @@ export const OrganizationServiceListMembershipsDesc: UnaryMethodDefinitionish = } as any, }; +export const OrganizationServiceUpdateDesc: UnaryMethodDefinitionish = { + methodName: "Update", + service: OrganizationServiceDesc, + requestStream: false, + responseStream: false, + requestType: { + serializeBinary() { + return OrganizationServiceUpdateRequest.encode(this).finish(); + }, + } as any, + responseType: { + deserializeBinary(data: Uint8Array) { + const value = OrganizationServiceUpdateResponse.decode(data); + return { + ...value, + toObject() { + return value; + }, + }; + }, + } as any, +}; + export const OrganizationServiceSetCurrentMembershipDesc: UnaryMethodDefinitionish = { methodName: "SetCurrentMembership", service: OrganizationServiceDesc, diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts b/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts index 6b0a412d1..07c497f1e 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts @@ -140,13 +140,13 @@ export interface User { export interface OrgMembershipItem { id: string; - org?: Org; + org?: OrgItem; current: boolean; createdAt?: Date; updatedAt?: Date; } -export interface Org { +export interface OrgItem { id: string; name: string; createdAt?: Date; @@ -1416,7 +1416,7 @@ export const OrgMembershipItem = { writer.uint32(10).string(message.id); } if (message.org !== undefined) { - Org.encode(message.org, writer.uint32(18).fork()).ldelim(); + OrgItem.encode(message.org, writer.uint32(18).fork()).ldelim(); } if (message.current === true) { writer.uint32(24).bool(message.current); @@ -1449,7 +1449,7 @@ export const OrgMembershipItem = { break; } - message.org = Org.decode(reader, reader.uint32()); + message.org = OrgItem.decode(reader, reader.uint32()); continue; case 3: if (tag !== 24) { @@ -1484,7 +1484,7 @@ export const OrgMembershipItem = { fromJSON(object: any): OrgMembershipItem { return { id: isSet(object.id) ? String(object.id) : "", - org: isSet(object.org) ? Org.fromJSON(object.org) : undefined, + org: isSet(object.org) ? OrgItem.fromJSON(object.org) : undefined, current: isSet(object.current) ? Boolean(object.current) : false, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, updatedAt: isSet(object.updatedAt) ? fromJsonTimestamp(object.updatedAt) : undefined, @@ -1494,7 +1494,7 @@ export const OrgMembershipItem = { toJSON(message: OrgMembershipItem): unknown { const obj: any = {}; message.id !== undefined && (obj.id = message.id); - message.org !== undefined && (obj.org = message.org ? Org.toJSON(message.org) : undefined); + message.org !== undefined && (obj.org = message.org ? OrgItem.toJSON(message.org) : undefined); message.current !== undefined && (obj.current = message.current); message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString()); @@ -1508,7 +1508,7 @@ export const OrgMembershipItem = { fromPartial, I>>(object: I): OrgMembershipItem { const message = createBaseOrgMembershipItem(); message.id = object.id ?? ""; - message.org = (object.org !== undefined && object.org !== null) ? Org.fromPartial(object.org) : undefined; + message.org = (object.org !== undefined && object.org !== null) ? OrgItem.fromPartial(object.org) : undefined; message.current = object.current ?? false; message.createdAt = object.createdAt ?? undefined; message.updatedAt = object.updatedAt ?? undefined; @@ -1516,12 +1516,12 @@ export const OrgMembershipItem = { }, }; -function createBaseOrg(): Org { +function createBaseOrgItem(): OrgItem { return { id: "", name: "", createdAt: undefined }; } -export const Org = { - encode(message: Org, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { +export const OrgItem = { + encode(message: OrgItem, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.id !== "") { writer.uint32(10).string(message.id); } @@ -1534,10 +1534,10 @@ export const Org = { return writer; }, - decode(input: _m0.Reader | Uint8Array, length?: number): Org { + decode(input: _m0.Reader | Uint8Array, length?: number): OrgItem { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseOrg(); + const message = createBaseOrgItem(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -1571,7 +1571,7 @@ export const Org = { return message; }, - fromJSON(object: any): Org { + fromJSON(object: any): OrgItem { return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "", @@ -1579,7 +1579,7 @@ export const Org = { }; }, - toJSON(message: Org): unknown { + toJSON(message: OrgItem): unknown { const obj: any = {}; message.id !== undefined && (obj.id = message.id); message.name !== undefined && (obj.name = message.name); @@ -1587,12 +1587,12 @@ export const Org = { return obj; }, - create, I>>(base?: I): Org { - return Org.fromPartial(base ?? {}); + create, I>>(base?: I): OrgItem { + return OrgItem.fromPartial(base ?? {}); }, - fromPartial, I>>(object: I): Org { - const message = createBaseOrg(); + fromPartial, I>>(object: I): OrgItem { + const message = createBaseOrgItem(); message.id = object.id ?? ""; message.name = object.name ?? ""; message.createdAt = object.createdAt ?? undefined; diff --git a/app/controlplane/cmd/wire_gen.go b/app/controlplane/cmd/wire_gen.go index 6dd1c7053..382b00ecd 100644 --- a/app/controlplane/cmd/wire_gen.go +++ b/app/controlplane/cmd/wire_gen.go @@ -45,7 +45,7 @@ func wireApp(bootstrap *conf.Bootstrap, readerWriter credentials.ReaderWriter, l Logger: logger, } integrationUseCase := biz.NewIntegrationUseCase(newIntegrationUseCaseOpts) - organizationUseCase := biz.NewOrganizationUseCase(organizationRepo, casBackendUseCase, integrationUseCase, logger) + organizationUseCase := biz.NewOrganizationUseCase(organizationRepo, casBackendUseCase, integrationUseCase, membershipRepo, logger) newUserUseCaseParams := &biz.NewUserUseCaseParams{ UserRepo: userRepo, MembershipUseCase: membershipUseCase, @@ -133,7 +133,7 @@ func wireApp(bootstrap *conf.Bootstrap, readerWriter credentials.ReaderWriter, l } orgMetricsService := service.NewOrgMetricsService(orgMetricsUseCase, v2...) integrationsService := service.NewIntegrationsService(integrationUseCase, workflowUseCase, availablePlugins, v2...) - organizationService := service.NewOrganizationService(membershipUseCase, v2...) + organizationService := service.NewOrganizationService(membershipUseCase, organizationUseCase, v2...) casBackendService := service.NewCASBackendService(casBackendUseCase, providers, v2...) casRedirectService, err := service.NewCASRedirectService(casMappingUseCase, casCredentialsUseCase, bootstrap_CASServer, v2...) if err != nil { diff --git a/app/controlplane/internal/biz/casbackend_integration_test.go b/app/controlplane/internal/biz/casbackend_integration_test.go index 3d142a900..912c0b59d 100644 --- a/app/controlplane/internal/biz/casbackend_integration_test.go +++ b/app/controlplane/internal/biz/casbackend_integration_test.go @@ -320,11 +320,11 @@ func (s *CASBackendIntegrationTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(s.T(), testhelpers.WithCredsReaderWriter(s.credsWriter)) - s.orgOne, err = s.Organization.Create(ctx, "testing org 1 with one backend") + s.orgOne, err = s.Organization.Create(ctx, "testing-org-1-with-one-backend") assert.NoError(err) - s.orgTwo, err = s.Organization.Create(ctx, "testing org 2 with 2 backends") + s.orgTwo, err = s.Organization.Create(ctx, "testing-org-2-with-2-backends") assert.NoError(err) - s.orgNoBackend, err = s.Organization.Create(ctx, "testing org 3, no backends") + s.orgNoBackend, err = s.Organization.Create(ctx, "testing-org-3-no-backends") assert.NoError(err) s.casBackend1, err = s.CASBackend.Create(ctx, s.orgOne.ID, "my-location", "backend 1 description", backendType, nil, true) diff --git a/app/controlplane/internal/biz/casmapping_integration_test.go b/app/controlplane/internal/biz/casmapping_integration_test.go index 1059c6e34..73f84b8ff 100644 --- a/app/controlplane/internal/biz/casmapping_integration_test.go +++ b/app/controlplane/internal/biz/casmapping_integration_test.go @@ -307,16 +307,16 @@ func (s *casMappingIntegrationSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(s.T(), testhelpers.WithCredsReaderWriter(credsWriter)) // Create casBackend in the database - s.org1, err = s.Organization.Create(ctx, "testing org 1 with one backend") + s.org1, err = s.Organization.Create(ctx, "testing-org-1-with-one0backend") assert.NoError(err) s.casBackend1, err = s.CASBackend.Create(ctx, s.org1.ID, "my-location", "backend 1 description", backendType, nil, true) assert.NoError(err) - s.org2, err = s.Organization.Create(ctx, "testing org 2") + s.org2, err = s.Organization.Create(ctx, "testing-org-2") assert.NoError(err) s.casBackend2, err = s.CASBackend.Create(ctx, s.org2.ID, "my-location", "backend 1 description", backendType, nil, true) assert.NoError(err) // Create casBackend associated with an org which users are not member of - s.orgNoUsers, err = s.Organization.Create(ctx, "org without users") + s.orgNoUsers, err = s.Organization.Create(ctx, "org-without-users") assert.NoError(err) s.casBackend3, err = s.CASBackend.Create(ctx, s.orgNoUsers.ID, "my-location", "backend 1 description", backendType, nil, true) assert.NoError(err) diff --git a/app/controlplane/internal/biz/integration_test.go b/app/controlplane/internal/biz/integration_test.go index f72874185..d6660b7ad 100644 --- a/app/controlplane/internal/biz/integration_test.go +++ b/app/controlplane/internal/biz/integration_test.go @@ -187,9 +187,9 @@ func (s *testSuite) SetupTest() { var err error // Create org, integration and oci repository - s.org, err = s.Organization.Create(ctx, "testing org") + s.org, err = s.Organization.Create(ctx, "testing-org") assert.NoError(err) - s.emptyOrg, err = s.Organization.Create(ctx, "empty org") + s.emptyOrg, err = s.Organization.Create(ctx, "empty-org") assert.NoError(err) // Workflow diff --git a/app/controlplane/internal/biz/mocks/OrganizationRepo.go b/app/controlplane/internal/biz/mocks/OrganizationRepo.go index 10769922f..a69274160 100644 --- a/app/controlplane/internal/biz/mocks/OrganizationRepo.go +++ b/app/controlplane/internal/biz/mocks/OrganizationRepo.go @@ -1,19 +1,4 @@ -// -// Copyright 2023 The Chainloop Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by mockery v2.16.0. DO NOT EDIT. +// Code generated by mockery v2.20.0. DO NOT EDIT. package mocks @@ -37,6 +22,10 @@ func (_m *OrganizationRepo) Create(ctx context.Context, name string) (*biz.Organ ret := _m.Called(ctx, name) var r0 *biz.Organization + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*biz.Organization, error)); ok { + return rf(ctx, name) + } if rf, ok := ret.Get(0).(func(context.Context, string) *biz.Organization); ok { r0 = rf(ctx, name) } else { @@ -45,7 +34,6 @@ func (_m *OrganizationRepo) Create(ctx context.Context, name string) (*biz.Organ } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(ctx, name) } else { @@ -74,6 +62,10 @@ func (_m *OrganizationRepo) FindByID(ctx context.Context, orgID uuid.UUID) (*biz ret := _m.Called(ctx, orgID) var r0 *biz.Organization + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*biz.Organization, error)); ok { + return rf(ctx, orgID) + } if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *biz.Organization); ok { r0 = rf(ctx, orgID) } else { @@ -82,7 +74,6 @@ func (_m *OrganizationRepo) FindByID(ctx context.Context, orgID uuid.UUID) (*biz } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { r1 = rf(ctx, orgID) } else { @@ -92,6 +83,32 @@ func (_m *OrganizationRepo) FindByID(ctx context.Context, orgID uuid.UUID) (*biz return r0, r1 } +// Update provides a mock function with given fields: ctx, id, name +func (_m *OrganizationRepo) Update(ctx context.Context, id uuid.UUID, name *string) (*biz.Organization, error) { + ret := _m.Called(ctx, id, name) + + var r0 *biz.Organization + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, *string) (*biz.Organization, error)); ok { + return rf(ctx, id, name) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, *string) *biz.Organization); ok { + r0 = rf(ctx, id, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*biz.Organization) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, *string) error); ok { + r1 = rf(ctx, id, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + type mockConstructorTestingTNewOrganizationRepo interface { mock.TestingT Cleanup(func()) diff --git a/app/controlplane/internal/biz/organization.go b/app/controlplane/internal/biz/organization.go index f9f293604..cb1d3b86d 100644 --- a/app/controlplane/internal/biz/organization.go +++ b/app/controlplane/internal/biz/organization.go @@ -17,12 +17,15 @@ package biz import ( "context" + "errors" "fmt" + "strings" "time" "github.com/go-kratos/kratos/v2/log" "github.com/google/uuid" "github.com/moby/moby/pkg/namesgenerator" + "k8s.io/apimachinery/pkg/util/validation" ) type Organization struct { @@ -33,6 +36,7 @@ type Organization struct { type OrganizationRepo interface { FindByID(ctx context.Context, orgID uuid.UUID) (*Organization, error) Create(ctx context.Context, name string) (*Organization, error) + Update(ctx context.Context, id uuid.UUID, name *string) (*Organization, error) Delete(ctx context.Context, ID uuid.UUID) error } @@ -41,13 +45,15 @@ type OrganizationUseCase struct { logger *log.Helper casBackendUseCase *CASBackendUseCase integrationUC *IntegrationUseCase + membershipRepo MembershipRepo } -func NewOrganizationUseCase(repo OrganizationRepo, repoUC *CASBackendUseCase, iUC *IntegrationUseCase, logger log.Logger) *OrganizationUseCase { +func NewOrganizationUseCase(repo OrganizationRepo, repoUC *CASBackendUseCase, iUC *IntegrationUseCase, mRepo MembershipRepo, logger log.Logger) *OrganizationUseCase { return &OrganizationUseCase{orgRepo: repo, logger: log.NewHelper(logger), casBackendUseCase: repoUC, integrationUC: iUC, + membershipRepo: mRepo, } } @@ -55,11 +61,80 @@ func (uc *OrganizationUseCase) Create(ctx context.Context, name string) (*Organi // Create a random name if none is provided if name == "" { name = namesgenerator.GetRandomName(0) + // Replace underscores with dashes to make it compatible with DNS1123 + name = strings.ReplaceAll(name, "_", "-") + } + + if err := validateOrgName(name); err != nil { + return nil, NewErrValidation(fmt.Errorf("invalid organization name: %w", err)) } return uc.orgRepo.Create(ctx, name) } +func validateOrgName(name string) error { + // The same validation done by Kubernetes for their namespace name + // https://github.com/kubernetes/apimachinery/blob/fa98d6eaedb4caccd69fc07d90bbb6a1e551f00f/pkg/api/validation/generic.go#L63 + err := validation.IsDNS1123Label(name) + if len(err) > 0 { + errMsg := "" + for _, e := range err { + errMsg += e + "\n" + } + + return errors.New(errMsg) + } + + return nil +} + +func (uc *OrganizationUseCase) Update(ctx context.Context, userID, orgID string, name *string) (*Organization, error) { + userUUID, err := uuid.Parse(userID) + if err != nil { + return nil, NewErrInvalidUUID(err) + } + + orgUUID, err := uuid.Parse(orgID) + if err != nil { + return nil, NewErrInvalidUUID(err) + } + + // We validate the name to get ready for the name to become identifiers + if name != nil { + if err := validateOrgName(*name); err != nil { + return nil, NewErrValidation(fmt.Errorf("invalid organization name: %w", err)) + } + } + + // Make sure that the organization exists and that the user is a member of it + memberships, err := uc.membershipRepo.FindByUser(ctx, userUUID) + if err != nil { + return nil, fmt.Errorf("failed to find memberships: %w", err) + } + + var found bool + for _, m := range memberships { + if m.OrganizationID == orgUUID { + found = true + break + } + } + + if !found { + return nil, NewErrNotFound("organization") + } + + // Perform the update + org, err := uc.orgRepo.Update(ctx, orgUUID, name) + if err != nil { + return nil, fmt.Errorf("failed to update organization: %w", err) + } else if org == nil { + return nil, NewErrNotFound("organization") + } + + return org, nil +} + func (uc *OrganizationUseCase) FindByID(ctx context.Context, id string) (*Organization, error) { orgUUID, err := uuid.Parse(id) if err != nil { diff --git a/app/controlplane/internal/biz/organization_integration_test.go b/app/controlplane/internal/biz/organization_integration_test.go index c2e129ad2..d5de2772e 100644 --- a/app/controlplane/internal/biz/organization_integration_test.go +++ b/app/controlplane/internal/biz/organization_integration_test.go @@ -31,9 +31,91 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) +// and delete cascades that we want to validate that they work too +func (s *OrgIntegrationTestSuite) TestCreate() { + ctx := context.Background() + + testCases := []struct { + name string + expectedError bool + }{ + // autogenerated name + {"", false}, + {"a", false}, + {"aa-aa", false}, + {"-aaa", true}, + // no under-scores + {"aaa_aaa", true}, + {"1-aaaa", false}, + {"Aaaaa", true}, + {"12-foo-bar-waz", false}, + // 63 max + {"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk", false}, + // over the max size + {"aabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk", true}, + } + + for _, tc := range testCases { + s.T().Run(tc.name, func(t *testing.T) { + org, err := s.Organization.Create(ctx, tc.name) + if tc.expectedError { + s.Error(err) + return + } + + require.NoError(s.T(), err) + if tc.name == "" { + // It was autogenerated + s.NotEmpty(org.Name) + } else { + s.Equal(tc.name, org.Name) + } + }) + } +} + +func (s *OrgIntegrationTestSuite) TestUpdate() { + ctx := context.Background() + + s.T().Run("invalid org ID", func(t *testing.T) { + // Invalid org ID + _, err := s.Organization.Update(ctx, s.user.ID, "invalid", nil) + s.Error(err) + s.True(biz.IsErrInvalidUUID(err)) + }) + + s.T().Run("org non existent", func(t *testing.T) { + // org not found + _, err := s.Organization.Update(ctx, s.user.ID, uuid.NewString(), nil) + s.Error(err) + s.True(biz.IsNotFound(err)) + }) + + s.T().Run("org not accessible to user", func(t *testing.T) { + org2, err := s.Organization.Create(ctx, "testing-org") + require.NoError(s.T(), err) + _, err = s.Organization.Update(ctx, s.user.ID, org2.ID, nil) + s.Error(err) + s.True(biz.IsNotFound(err)) + }) + + s.T().Run("valid name update", func(t *testing.T) { + got, err := s.Organization.Update(ctx, s.user.ID, s.org.ID, toPtrS("new-name")) + s.NoError(err) + s.Equal("new-name", got.Name) + }) + + s.T().Run("invalid name update", func(t *testing.T) { + _, err := s.Organization.Update(ctx, s.user.ID, s.org.ID, toPtrS("invalid_new-name")) + s.Error(err) + s.True(biz.IsErrValidation(err)) + }) +} + // We are doing an integration test here because there are some database constraints // and delete cascades that we want to validate that they work too func (s *OrgIntegrationTestSuite) TestDeleteOrg() { @@ -89,6 +171,7 @@ func TestOrgUseCase(t *testing.T) { type OrgIntegrationTestSuite struct { testhelpers.UseCasesEachTestSuite org *biz.Organization + user *biz.User mockedCredsReaderWriter *creds.ReaderWriter } @@ -110,7 +193,12 @@ func (s *OrgIntegrationTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(t, testhelpers.WithCredsReaderWriter(s.mockedCredsReaderWriter)) // Create org, integration and oci repository - s.org, err = s.Organization.Create(ctx, "testing org") + s.org, err = s.Organization.Create(ctx, "testing-org") + assert.NoError(err) + + s.user, err = s.User.FindOrCreateByEmail(ctx, "foo@test.com") + assert.NoError(err) + _, err = s.Membership.Create(ctx, s.org.ID, s.user.ID, true) assert.NoError(err) // Integration diff --git a/app/controlplane/internal/biz/organization_test.go b/app/controlplane/internal/biz/organization_test.go index 773b81e9f..6312579b6 100644 --- a/app/controlplane/internal/biz/organization_test.go +++ b/app/controlplane/internal/biz/organization_test.go @@ -13,54 +13,47 @@ // See the License for the specific language governing permissions and // limitations under the License. -package biz_test +package biz import ( - "context" "testing" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" - repoM "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz/mocks" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" ) type organizationTestSuite struct { suite.Suite - repo *repoM.OrganizationRepo - useCase *biz.OrganizationUseCase } -func (s *organizationTestSuite) SetupTest() { - s.repo = repoM.NewOrganizationRepo(s.T()) - s.useCase = biz.NewOrganizationUseCase(s.repo, nil, nil, nil) -} - -func (s *organizationTestSuite) TestCreate() { - assert := assert.New(s.T()) - ctx := context.Background() - tests := []struct { - name string - }{{"defined"}, {""}} - - newOrg := &biz.Organization{} - s.repo.On("Create", ctx, mock.AnythingOfType("string")).Return( - func(ctx context.Context, s string) *biz.Organization { - newOrg.Name = s - return newOrg - }, nil, - ) +func (s *organizationTestSuite) TestValidateOrgName() { + testCases := []struct { + name string + expectedError bool + }{ + {"", true}, + {"a", false}, + {"aa-aa", false}, + {"-aaa", true}, + // no under-scores + {"aaa_aaa", true}, + {"1-aaaa", false}, + {"Aaaaa", true}, + {"12-foo-bar-waz", false}, + // 63 max + {"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk", false}, + // over the max size + {"aabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk", true}, + } - for _, tc := range tests { - gotOrg, err := s.useCase.Create(ctx, tc.name) - assert.NoError(err) - // The name was provided - if tc.name != "" { - assert.Equal(gotOrg.Name, tc.name) - } - // The name is always set, even if it was not provided - assert.NotEmpty(gotOrg.Name) + for _, tc := range testCases { + s.T().Run(tc.name, func(t *testing.T) { + err := validateOrgName(tc.name) + if tc.expectedError { + s.Error(err) + } else { + s.NoError(err) + } + }) } } diff --git a/app/controlplane/internal/biz/referrer_integration_test.go b/app/controlplane/internal/biz/referrer_integration_test.go index 2bb6ee262..9ba258067 100644 --- a/app/controlplane/internal/biz/referrer_integration_test.go +++ b/app/controlplane/internal/biz/referrer_integration_test.go @@ -357,9 +357,9 @@ func (s *referrerIntegrationTestSuite) SetupTest() { ctx := context.Background() var err error - s.org1, err = s.Organization.Create(ctx, "testing org") + s.org1, err = s.Organization.Create(ctx, "testing-org") require.NoError(s.T(), err) - s.org2, err = s.Organization.Create(ctx, "testing org 2") + s.org2, err = s.Organization.Create(ctx, "testing-org-2") require.NoError(s.T(), err) s.org1UUID, err = uuid.Parse(s.org1.ID) diff --git a/app/controlplane/internal/biz/testhelpers/wire_gen.go b/app/controlplane/internal/biz/testhelpers/wire_gen.go index afcb5f161..ac9e9bc5d 100644 --- a/app/controlplane/internal/biz/testhelpers/wire_gen.go +++ b/app/controlplane/internal/biz/testhelpers/wire_gen.go @@ -47,7 +47,7 @@ func WireTestData(testDatabase *TestDatabase, t *testing.T, logger log.Logger, r } integrationUseCase := biz.NewIntegrationUseCase(newIntegrationUseCaseOpts) organizationRepo := data.NewOrganizationRepo(dataData, logger) - organizationUseCase := biz.NewOrganizationUseCase(organizationRepo, casBackendUseCase, integrationUseCase, logger) + organizationUseCase := biz.NewOrganizationUseCase(organizationRepo, casBackendUseCase, integrationUseCase, membershipRepo, logger) workflowContractRepo := data.NewWorkflowContractRepo(dataData, logger) workflowContractUseCase := biz.NewWorkflowContractUseCase(workflowContractRepo, logger) workflowUseCase := biz.NewWorkflowUsecase(workflowRepo, workflowContractUseCase, logger) diff --git a/app/controlplane/internal/biz/user_integration_test.go b/app/controlplane/internal/biz/user_integration_test.go index 687b1d9af..b9f3232b3 100644 --- a/app/controlplane/internal/biz/user_integration_test.go +++ b/app/controlplane/internal/biz/user_integration_test.go @@ -78,9 +78,9 @@ func (s *userIntegrationTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(t) - s.userOneOrg, err = s.Organization.Create(ctx, "user 1 org") + s.userOneOrg, err = s.Organization.Create(ctx, "user-1-org") assert.NoError(err) - s.sharedOrg, err = s.Organization.Create(ctx, "shared org") + s.sharedOrg, err = s.Organization.Create(ctx, "shared-org") assert.NoError(err) // Create User 1 diff --git a/app/controlplane/internal/biz/workflow_integration_test.go b/app/controlplane/internal/biz/workflow_integration_test.go index 063633b7a..fcf8f76e6 100644 --- a/app/controlplane/internal/biz/workflow_integration_test.go +++ b/app/controlplane/internal/biz/workflow_integration_test.go @@ -37,7 +37,7 @@ func (s *workflowIntegrationTestSuite) TestUpdate() { project = "test project" ) - org2, err := s.Organization.Create(context.Background(), "testing org") + org2, err := s.Organization.Create(context.Background(), "testing-org") require.NoError(s.T(), err) workflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: name, OrgID: s.org.ID}) require.NoError(s.T(), err) @@ -147,7 +147,7 @@ func (s *workflowIntegrationTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(s.T()) ctx := context.Background() - s.org, err = s.Organization.Create(ctx, "testing org") + s.org, err = s.Organization.Create(ctx, "testing-org") assert.NoError(err) } diff --git a/app/controlplane/internal/biz/workflowrun_integration_test.go b/app/controlplane/internal/biz/workflowrun_integration_test.go index 76add728b..9eec8a0a7 100644 --- a/app/controlplane/internal/biz/workflowrun_integration_test.go +++ b/app/controlplane/internal/biz/workflowrun_integration_test.go @@ -226,9 +226,9 @@ func (s *workflowRunIntegrationTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(s.T(), testhelpers.WithCredsReaderWriter(credsWriter)) - s.org, err = s.Organization.Create(ctx, "testing org") + s.org, err = s.Organization.Create(ctx, "testing-org") assert.NoError(err) - s.org2, err = s.Organization.Create(ctx, "second org") + s.org2, err = s.Organization.Create(ctx, "second-org") assert.NoError(err) // Workflow diff --git a/app/controlplane/internal/data/organization.go b/app/controlplane/internal/data/organization.go index 48f18afe7..f941d63bd 100644 --- a/app/controlplane/internal/data/organization.go +++ b/app/controlplane/internal/data/organization.go @@ -17,6 +17,7 @@ package data import ( "context" + "fmt" "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent" @@ -60,6 +61,21 @@ func (r *OrganizationRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Org return entOrgToBizOrg(org), nil } +func (r *OrganizationRepo) Update(ctx context.Context, id uuid.UUID, name *string) (*biz.Organization, error) { + req := r.data.db.Organization.UpdateOneID(id) + if name != nil && *name != "" { + req = req.SetName(*name) + } + + org, err := req.Save(ctx) + if err != nil { + return nil, fmt.Errorf("failed to update organization: %w", err) + } + + // Reload the object to include the relations + return r.FindByID(ctx, org.ID) +} + // Delete deletes an organization by ID. func (r *OrganizationRepo) Delete(ctx context.Context, id uuid.UUID) error { return r.data.db.Organization.DeleteOneID(id).Exec(ctx) diff --git a/app/controlplane/internal/dispatcher/dispatcher_test.go b/app/controlplane/internal/dispatcher/dispatcher_test.go index bddc81d46..292a8b7f0 100644 --- a/app/controlplane/internal/dispatcher/dispatcher_test.go +++ b/app/controlplane/internal/dispatcher/dispatcher_test.go @@ -213,11 +213,11 @@ func (s *dispatcherTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(s.T()) // Create org, integration and oci repository - s.org, err = s.Organization.Create(ctx, "testing org") + s.org, err = s.Organization.Create(ctx, "testing-org") assert.NoError(s.T(), err) // Create org, integration and oci repository - s.emptyOrg, err = s.Organization.Create(ctx, "empty org") + s.emptyOrg, err = s.Organization.Create(ctx, "empty-org") assert.NoError(s.T(), err) // Workflow diff --git a/app/controlplane/internal/service/context.go b/app/controlplane/internal/service/context.go index a4afe3c18..bcda039de 100644 --- a/app/controlplane/internal/service/context.go +++ b/app/controlplane/internal/service/context.go @@ -65,8 +65,8 @@ func (s *ContextService) Current(ctx context.Context, _ *pb.ContextServiceCurren }, nil } -func bizOrgToPb(m *biz.Organization) *pb.Org { - return &pb.Org{Id: m.ID, Name: m.Name, CreatedAt: timestamppb.New(*m.CreatedAt)} +func bizOrgToPb(m *biz.Organization) *pb.OrgItem { + return &pb.OrgItem{Id: m.ID, Name: m.Name, CreatedAt: timestamppb.New(*m.CreatedAt)} } func bizUserToPb(u *biz.User) *pb.User { diff --git a/app/controlplane/internal/service/organization.go b/app/controlplane/internal/service/organization.go index 9c56a726c..473cbc1ff 100644 --- a/app/controlplane/internal/service/organization.go +++ b/app/controlplane/internal/service/organization.go @@ -30,13 +30,15 @@ type OrganizationService struct { pb.UnimplementedOrganizationServiceServer *service - useCase *biz.MembershipUseCase + membershipUC *biz.MembershipUseCase + orgUC *biz.OrganizationUseCase } -func NewOrganizationService(uc *biz.MembershipUseCase, opts ...NewOpt) *OrganizationService { +func NewOrganizationService(muc *biz.MembershipUseCase, ouc *biz.OrganizationUseCase, opts ...NewOpt) *OrganizationService { return &OrganizationService{ - service: newService(opts...), - useCase: uc, + service: newService(opts...), + membershipUC: muc, + orgUC: ouc, } } @@ -46,7 +48,7 @@ func (s *OrganizationService) ListMemberships(ctx context.Context, _ *pb.Organiz return nil, err } - memberships, err := s.useCase.ByUser(ctx, currentUser.ID) + memberships, err := s.membershipUC.ByUser(ctx, currentUser.ID) if err != nil && biz.IsNotFound(err) { return nil, errors.NotFound("not found", err.Error()) } else if err != nil { @@ -61,13 +63,27 @@ func (s *OrganizationService) ListMemberships(ctx context.Context, _ *pb.Organiz return &pb.OrganizationServiceListMembershipsResponse{Result: result}, nil } +func (s *OrganizationService) Update(ctx context.Context, req *pb.OrganizationServiceUpdateRequest) (*pb.OrganizationServiceUpdateResponse, error) { + currentUser, _, err := loadCurrentUserAndOrg(ctx) + if err != nil { + return nil, err + } + + org, err := s.orgUC.Update(ctx, currentUser.ID, req.Id, req.Name) + if err != nil { + return nil, handleUseCaseErr("organization", err, s.log) + } + + return &pb.OrganizationServiceUpdateResponse{Result: bizOrgToPb(org)}, nil +} + func (s *OrganizationService) SetCurrentMembership(ctx context.Context, req *pb.SetCurrentMembershipRequest) (*pb.SetCurrentMembershipResponse, error) { currentUser, _, err := loadCurrentUserAndOrg(ctx) if err != nil { return nil, err } - m, err := s.useCase.SetCurrent(ctx, currentUser.ID, req.MembershipId) + m, err := s.membershipUC.SetCurrent(ctx, currentUser.ID, req.MembershipId) if err != nil && biz.IsNotFound(err) { return nil, errors.NotFound("not found", err.Error()) } else if err != nil { diff --git a/go.mod b/go.mod index 4840751b4..fd94512cf 100644 --- a/go.mod +++ b/go.mod @@ -298,7 +298,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.28.3 // indirect - k8s.io/apimachinery v0.28.3 // indirect + k8s.io/apimachinery v0.28.3 k8s.io/client-go v0.28.3 // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect