mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-22 07:24:26 +00:00
# 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]>
41 lines
764 B
Go
41 lines
764 B
Go
package domain
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
const (
|
|
maxGroupNameLen = 200
|
|
)
|
|
|
|
// Group represents a user group in an organization
|
|
type Group struct {
|
|
models.ObjectRoot
|
|
|
|
Name string
|
|
Description string
|
|
}
|
|
|
|
func (g *Group) IsValid() error {
|
|
groupName := strings.TrimSpace(g.Name)
|
|
if groupName == "" || len(groupName) > maxGroupNameLen {
|
|
return zerrors.ThrowInvalidArgument(nil, "GROUP-m177lN", "Errors.Group.InvalidName")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type GroupState int32
|
|
|
|
const (
|
|
GroupStateUnspecified GroupState = iota
|
|
GroupStateActive
|
|
GroupStateRemoved
|
|
)
|
|
|
|
func (g GroupState) Exists() bool {
|
|
return g != GroupStateRemoved && g != GroupStateUnspecified
|
|
}
|