Documentation
¶
Overview ¶
Package groups contains the domain concept definitions needed to support SuperMQ groups functionality.
Index ¶
- Constants
- Variables
- func NewExternalOperationPerm() svcutil.ExternalOperationPerm
- func NewExternalOperationPermissionMap() map[svcutil.ExternalOperation]svcutil.Permission
- func NewOperationPerm() svcutil.OperationPerm
- func NewOperationPermissionMap() map[svcutil.Operation]svcutil.Permission
- func NewRolesOperationPermissionMap() map[svcutil.Operation]svcutil.Permission
- type Group
- type HierarchyPage
- type HierarchyPageMeta
- type Member
- type MembersPage
- type Metadata
- type Page
- type PageMeta
- type Repository
- type Service
- type Status
Constants ¶
const ( MaxLevel = uint64(20) MaxPathLength = 20 )
MaxLevel represents the maximum group hierarchy level.
const ( OpViewGroup svcutil.Operation = iota OpUpdateGroup OpEnableGroup OpDisableGroup OpRetrieveGroupHierarchy OpAddParentGroup OpRemoveParentGroup OpAddChildrenGroups OpRemoveChildrenGroups OpRemoveAllChildrenGroups OpListChildrenGroups OpDeleteGroup )
const ( DomainOpCreateGroup svcutil.ExternalOperation = iota DomainOpListGroups UserOpListGroups ClientsOpListGroups ChannelsOpListGroups )
External Operations.
const ( Disabled = "disabled" Enabled = "enabled" Deleted = "deleted" All = "all" Unknown = "unknown" )
String representation of the possible status values.
const BuiltInRoleAdmin roles.BuiltInRoleName = "admin"
Variables ¶
var ( // ErrInvalidStatus indicates invalid status. ErrInvalidStatus = errors.New("invalid groups status") // ErrEnableGroup indicates error in enabling group. ErrEnableGroup = errors.New("failed to enable group") // ErrDisableGroup indicates error in disabling group. ErrDisableGroup = errors.New("failed to disable group") )
var ErrGroupIDs = errors.New("invalid group ids")
Functions ¶
func NewExternalOperationPerm ¶
func NewExternalOperationPerm() svcutil.ExternalOperationPerm
func NewExternalOperationPermissionMap ¶
func NewExternalOperationPermissionMap() map[svcutil.ExternalOperation]svcutil.Permission
func NewOperationPerm ¶
func NewOperationPerm() svcutil.OperationPerm
func NewOperationPermissionMap ¶
func NewOperationPermissionMap() map[svcutil.Operation]svcutil.Permission
func NewRolesOperationPermissionMap ¶
func NewRolesOperationPermissionMap() map[svcutil.Operation]svcutil.Permission
Types ¶
type Group ¶
type Group struct { ID string `json:"id"` Domain string `json:"domain_id,omitempty"` Parent string `json:"parent_id,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Metadata Metadata `json:"metadata,omitempty"` Level int `json:"level,omitempty"` Path string `json:"path,omitempty"` Children []*Group `json:"children,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at,omitempty"` UpdatedBy string `json:"updated_by,omitempty"` Status Status `json:"status"` RoleID string `json:"role_id,omitempty"` RoleName string `json:"role_name,omitempty"` Actions []string `json:"actions,omitempty"` AccessType string `json:"access_type,omitempty"` AccessProviderId string `json:"access_provider_id,omitempty"` AccessProviderRoleId string `json:"access_provider_role_id,omitempty"` AccessProviderRoleName string `json:"access_provider_role_name,omitempty"` AccessProviderRoleActions []string `json:"access_provider_role_actions,omitempty"` }
Group represents the group of Clients. Indicates a level in tree hierarchy. Root node is level 1. Path in a tree consisting of group IDs Paths are unique per domain.
type HierarchyPage ¶
type HierarchyPage struct { HierarchyPageMeta Groups []Group }
type HierarchyPageMeta ¶
type MembersPage ¶
type MembersPage struct { Total uint64 `json:"total"` Offset uint64 `json:"offset"` Limit uint64 `json:"limit"` Members []Member `json:"members"` }
Memberships contains page related metadata as well as list of memberships that belong to this page.
type PageMeta ¶
type PageMeta struct { Total uint64 `json:"total"` Offset uint64 `json:"offset"` Limit uint64 `json:"limit"` Name string `json:"name,omitempty"` ID string `json:"id,omitempty"` Path string `json:"path,omitempty"` DomainID string `json:"domain_id,omitempty"` Tag string `json:"tag,omitempty"` Metadata Metadata `json:"metadata,omitempty"` Status Status `json:"status,omitempty"` RoleName string `json:"role_name,omitempty"` RoleID string `json:"role_id,omitempty"` Actions []string `json:"actions,omitempty"` AccessType string `json:"access_type,omitempty"` }
PageMeta contains page metadata that helps navigation.
type Repository ¶
type Repository interface { // Save group. Save(ctx context.Context, g Group) (Group, error) // Update a group. Update(ctx context.Context, g Group) (Group, error) // RetrieveByID retrieves group by its id. RetrieveByID(ctx context.Context, id string) (Group, error) RetrieveByIDAndUser(ctx context.Context, domainID, userID, groupID string) (Group, error) // RetrieveAll retrieves all groups. RetrieveAll(ctx context.Context, pm PageMeta) (Page, error) // RetrieveByIDs retrieves group by ids and query. RetrieveByIDs(ctx context.Context, pm PageMeta, ids ...string) (Page, error) RetrieveHierarchy(ctx context.Context, id string, hm HierarchyPageMeta) (HierarchyPage, error) // ChangeStatus changes groups status to active or inactive ChangeStatus(ctx context.Context, group Group) (Group, error) // AssignParentGroup assigns parent group id to a given group id AssignParentGroup(ctx context.Context, parentGroupID string, groupIDs ...string) error // UnassignParentGroup unassign parent group id fr given group id UnassignParentGroup(ctx context.Context, parentGroupID string, groupIDs ...string) error UnassignAllChildrenGroups(ctx context.Context, id string) error RetrieveUserGroups(ctx context.Context, domainID, userID string, pm PageMeta) (Page, error) // RetrieveChildrenGroups at given level in ltree // Condition: startLevel == 0 and endLevel < 0, Retrieve all children groups from parent group level, Example: If we pass startLevel 0 and endLevel -1, then function will return all children of parent group // Condition: startLevel > 0 and endLevel == 0, Retrieve specific level of children groups from parent group level, Example: If we pass startLevel 1 and endLevel 0, then function will return children of parent group from level 1 // Condition: startLevel > 0 and endLevel < 0, Retrieve all children groups from specific level from parent group level, Example: If we pass startLevel 2 and endLevel -1, then function will return all children of parent group from level 2 // Condition: startLevel > 0 and endLevel > 0, Retrieve children groups between specific level from parent group level, Example: If we pass startLevel 3 and endLevel 5, then function will return all children of parent group between level 3 and 5 RetrieveChildrenGroups(ctx context.Context, domainID, userID, groupID string, startLevel, endLevel int64, pm PageMeta) (Page, error) RetrieveAllParentGroups(ctx context.Context, domainID, userID, groupID string, pm PageMeta) (Page, error) // Delete a group Delete(ctx context.Context, groupID string) error roles.Repository }
Repository specifies a group persistence API.
type Service ¶
type Service interface { // CreateGroup creates new group. CreateGroup(ctx context.Context, session authn.Session, g Group) (Group, error) // UpdateGroup updates the group identified by the provided ID. UpdateGroup(ctx context.Context, session authn.Session, g Group) (Group, error) // ViewGroup retrieves data about the group identified by ID. ViewGroup(ctx context.Context, session authn.Session, id string) (Group, error) // ListGroups retrieves ListGroups(ctx context.Context, session authn.Session, pm PageMeta) (Page, error) ListUserGroups(ctx context.Context, session authn.Session, userID string, pm PageMeta) (Page, error) // EnableGroup logically enables the group identified with the provided ID. EnableGroup(ctx context.Context, session authn.Session, id string) (Group, error) // DisableGroup logically disables the group identified with the provided ID. DisableGroup(ctx context.Context, session authn.Session, id string) (Group, error) // DeleteGroup delete the given group id DeleteGroup(ctx context.Context, session authn.Session, id string) error RetrieveGroupHierarchy(ctx context.Context, session authn.Session, id string, hm HierarchyPageMeta) (HierarchyPage, error) AddParentGroup(ctx context.Context, session authn.Session, id, parentID string) error RemoveParentGroup(ctx context.Context, session authn.Session, id string) error AddChildrenGroups(ctx context.Context, session authn.Session, id string, childrenGroupIDs []string) error RemoveChildrenGroups(ctx context.Context, session authn.Session, id string, childrenGroupIDs []string) error RemoveAllChildrenGroups(ctx context.Context, session authn.Session, id string) error ListChildrenGroups(ctx context.Context, session authn.Session, id string, startLevel, endLevel int64, pm PageMeta) (Page, error) roles.RoleManager }
func NewService ¶
func NewService(repo Repository, policy policies.Service, idp supermq.IDProvider, channels grpcChannelsV1.ChannelsServiceClient, clients grpcClientsV1.ClientsServiceClient, sidProvider supermq.IDProvider, availableActions []roles.Action, builtInRoles map[roles.BuiltInRoleName][]roles.Action) (Service, error)
NewService returns a new groups service implementation.
type Status ¶
type Status uint8
Status represents Group status.
const ( // EnabledStatus represents enabled Group. EnabledStatus Status = iota // DisabledStatus represents disabled Group. DisabledStatus // DeletedStatus represents deleted Group. DeletedStatus // AllStatus is used for querying purposes to list groups irrespective // of their status - both active and inactive. It is never stored in the // database as the actual Group status and should always be the largest // value in this enumeration. AllStatus )
Possible Group status values.
func (Status) MarshalJSON ¶
Custom Marshaller for Status.
func (*Status) UnmarshalJSON ¶
Custom Unmarshaler for Status.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
api
|
|
grpc
Package grpc contains implementation of Auth service gRPC API.
|
Package grpc contains implementation of Auth service gRPC API. |
http
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations. |
Package events contains event source Redis client implementation.
|
Package events contains event source Redis client implementation. |
Package middleware provides middleware for SuperMQ Groups service.
|
Package middleware provides middleware for SuperMQ Groups service. |
Package mocks contains mocks for testing purposes.
|
Package mocks contains mocks for testing purposes. |
Package postgres contains the database implementation of groups repository layer.
|
Package postgres contains the database implementation of groups repository layer. |
Package tracing provides tracing instrumentation for SuperMQ Users Groups service.
|
Package tracing provides tracing instrumentation for SuperMQ Users Groups service. |