mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-14 09:55:12 +00:00
feat(group): group service to create, update, and delete groups (#10455)
# Which Problems Are Solved This PR adds API definition and backend implementation for GroupService to manage user groups. # How the Problems Are Solved * API definition to create, update, retrieve, and delete groups is added * Command-side implementation to create, update, and delete user groups as part of the GroupV2 API is added # Additional Changes N/A # Additional Context - Related to #10089, #9702 (parent ticket) - User contribution: https://github.com/zitadel/zitadel/pull/9428/files - Additional functionalities to list/search user groups, add permissions, manage users in groups, group scopes will be added in subsequent PRs. - Also needs documentation, which will be added once the entire feature is available --------- Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
parent
ee3654fe6f
commit
b81dedcaea
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"connectrpc.com/connect"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
group "github.com/zitadel/zitadel/pkg/grpc/group/v2"
|
||||
)
|
||||
|
||||
// GetGroup returns a group that matches the group ID in the request
|
||||
func (s *Server) GetGroup(ctx context.Context, req *connect.Request[group.GetGroupRequest]) (*connect.Response[group.GetGroupResponse], error) {
|
||||
return nil, zerrors.ThrowUnimplemented(nil, "GRP-1234", "Errors.Internal.Unimplemented")
|
||||
}
|
||||
|
||||
// ListGroups returns a list of groups that match the search criteria
|
||||
func (s *Server) ListGroups(ctx context.Context, req *connect.Request[group.ListGroupsRequest]) (*connect.Response[group.ListGroupsResponse], error) {
|
||||
resp, err := s.query.SearchGroups(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return connect.NewResponse(&group.ListGroupsResponse{
|
||||
Groups: groupsToPb(resp.Groups),
|
||||
}), nil
|
||||
}
|
||||
|
||||
func groupsToPb(groups []*query.Group) []*group.Group {
|
||||
pbGroups := make([]*group.Group, len(groups))
|
||||
for i, g := range groups {
|
||||
pbGroups[i] = groupToPb(g)
|
||||
}
|
||||
return pbGroups
|
||||
}
|
||||
|
||||
func groupToPb(g *query.Group) *group.Group {
|
||||
return &group.Group{
|
||||
Id: g.ID,
|
||||
Name: g.Name,
|
||||
CreationDate: timestamppb.New(g.CreationDate),
|
||||
ChangeDate: timestamppb.New(g.ChangeDate),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user