Documentation
¶
Overview ¶
Package groups is the group scenario: CRUD, the member relationship indexes and the owners join resource.
Index ¶
- Variables
- type Attrs
- type OptionalInt
- type Page
- type Scenario
- func (s Scenario) AttachOwners(ctx context.Context, account domain.Account, principal access.Principal, ...) ([]domain.GroupOwner, error)
- func (s Scenario) Create(ctx context.Context, account domain.Account, principal access.Principal, ...) (domain.Group, error)
- func (s Scenario) Delete(ctx context.Context, account domain.Account, principal access.Principal, ...) error
- func (s Scenario) DetachOwners(ctx context.Context, account domain.Account, principal access.Principal, ...) error
- func (s Scenario) LicenseGroup(ctx context.Context, account domain.Account, principal access.Principal, ...) (domain.Group, error)
- func (s Scenario) LicenseIDs(ctx context.Context, account domain.Account, principal access.Principal, ...) ([]uuid.UUID, error)
- func (s Scenario) List(ctx context.Context, account domain.Account, principal access.Principal, ...) (Page, error)
- func (s Scenario) MachineIDs(ctx context.Context, account domain.Account, principal access.Principal, ...) ([]uuid.UUID, error)
- func (s Scenario) Owner(ctx context.Context, account domain.Account, principal access.Principal, ...) (domain.GroupOwner, error)
- func (s Scenario) Owners(ctx context.Context, account domain.Account, principal access.Principal, ...) ([]domain.GroupOwner, error)
- func (s Scenario) Search(ctx context.Context, account domain.Account, principal access.Principal, ...) (Page, error)
- func (s Scenario) Show(ctx context.Context, account domain.Account, principal access.Principal, ...) (domain.Group, error)
- func (s Scenario) Update(ctx context.Context, account domain.Account, principal access.Principal, ...) (domain.Group, error)
- func (s Scenario) Users(ctx context.Context, account domain.Account, principal access.Principal, ...) ([]domain.User, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = domain.ErrNotFound
ErrNotFound is the storage port's not-found sentinel.
Functions ¶
This section is empty.
Types ¶
type Attrs ¶
type Attrs struct {
Name *string
MaxUsers OptionalInt
MaxLicenses OptionalInt
MaxMachines OptionalInt
Metadata map[string]any
}
Attrs is the decoded write payload of POST/PATCH /groups.
type OptionalInt ¶
OptionalInt is a tri-state integer attribute: absent, JSON null (clears the limit) or a value.
type Scenario ¶
type Scenario struct {
// contains filtered or unexported fields
}
Scenario runs the group scenarios.
func (Scenario) AttachOwners ¶
func (s Scenario) AttachOwners( ctx context.Context, account domain.Account, principal access.Principal, groupID uuid.UUID, userIDs []uuid.UUID, ) ([]domain.GroupOwner, error)
AttachOwners attaches users as the group's owners, answering the created join rows.
func (Scenario) Create ¶
func (s Scenario) Create( ctx context.Context, account domain.Account, principal access.Principal, attrs Attrs, ) (domain.Group, error)
Create validates and writes a new group.
func (Scenario) Delete ¶
func (s Scenario) Delete( ctx context.Context, account domain.Account, principal access.Principal, id uuid.UUID, ) error
Delete removes the group.
func (Scenario) DetachOwners ¶
func (s Scenario) DetachOwners( ctx context.Context, account domain.Account, principal access.Principal, groupID uuid.UUID, userIDs []uuid.UUID, ) error
DetachOwners detaches the given owner users; an unknown one is a 422 pointing at its body slot.
func (Scenario) LicenseGroup ¶
func (s Scenario) LicenseGroup( ctx context.Context, account domain.Account, principal access.Principal, id uuid.UUID, ) (domain.Group, error)
LicenseGroup resolves and authorizes the group of the license relationship routes.
func (Scenario) LicenseIDs ¶
func (s Scenario) LicenseIDs( ctx context.Context, account domain.Account, principal access.Principal, id uuid.UUID, limit int, ) ([]uuid.UUID, error)
LicenseIDs answers the group's license ids.
func (Scenario) List ¶
func (s Scenario) List( ctx context.Context, account domain.Account, principal access.Principal, p paging.Params, ) (Page, error)
List answers the principal-scoped page.
func (Scenario) MachineIDs ¶
func (s Scenario) MachineIDs( ctx context.Context, account domain.Account, principal access.Principal, id uuid.UUID, limit int, ) ([]uuid.UUID, error)
MachineIDs answers the group's machine ids.
func (Scenario) Owner ¶
func (s Scenario) Owner( ctx context.Context, account domain.Account, principal access.Principal, groupID, ownerID uuid.UUID, ) (domain.GroupOwner, error)
Owner loads one group-owner row.
func (Scenario) Owners ¶
func (s Scenario) Owners( ctx context.Context, account domain.Account, principal access.Principal, id uuid.UUID, limit int, ) ([]domain.GroupOwner, error)
Owners answers the group's owners (the join resource).
func (Scenario) Search ¶
func (s Scenario) Search( ctx context.Context, account domain.Account, principal access.Principal, matches []uuid.UUID, p paging.Params, ) (Page, error)
Search pages the account's groups among a search's matches.
func (Scenario) Show ¶
func (s Scenario) Show( ctx context.Context, account domain.Account, principal access.Principal, id uuid.UUID, ) (domain.Group, error)
Show loads one group under the GroupPolicy.
type Store ¶
type Store interface {
// Do runs fn in one transaction; the writes and the webhook
// events of one action commit together.
Do(ctx context.Context, fn func(ctx context.Context) error) error
// GroupByID loads a group; ErrNotFound.
GroupByID(ctx context.Context, accountID, id uuid.UUID) (domain.Group, error)
// ListGroups answers the principal-scoped page.
ListGroups(ctx context.Context, accountID uuid.UUID, memberUser uuid.NullUUID, ids []uuid.UUID, p paging.Params) ([]domain.Group, error) //nolint:lll // the scope's arguments
// CountGroups answers the scope's total.
CountGroups(ctx context.Context, accountID uuid.UUID, memberUser uuid.NullUUID, ids []uuid.UUID) (int, error)
// InsertGroup writes a new group row.
InsertGroup(ctx context.Context, group domain.Group) error
// UpdateGroup writes every mutable column.
UpdateGroup(ctx context.Context, group domain.Group) error
// DeleteGroup removes the group (members' group_id nulled).
DeleteGroup(ctx context.Context, accountID, id uuid.UUID) error
// ListGroupUsers answers the group's member users.
ListGroupUsers(ctx context.Context, accountID, groupID uuid.UUID, limit int) ([]domain.User, error)
// ListGroupLicenseIDs answers the group's license ids.
ListGroupLicenseIDs(ctx context.Context, accountID, groupID uuid.UUID, limit int) ([]uuid.UUID, error)
// ListGroupMachineIDs answers the group's machine ids.
ListGroupMachineIDs(ctx context.Context, accountID, groupID uuid.UUID, limit int) ([]uuid.UUID, error)
// InsertGroupOwner attaches a user as owner.
InsertGroupOwner(ctx context.Context, owner domain.GroupOwner) error
// GetGroupOwner loads a group-owner row.
GetGroupOwner(ctx context.Context, accountID, groupID, ownerID uuid.UUID) (domain.GroupOwner, error)
// GetGroupOwnerByUser loads the group-owner row of a user.
GetGroupOwnerByUser(ctx context.Context, accountID, groupID, userID uuid.UUID) (domain.GroupOwner, error)
// ListGroupOwners answers the group's owners.
ListGroupOwners(ctx context.Context, accountID, groupID uuid.UUID, limit int) ([]domain.GroupOwner, error)
// DeleteGroupOwnersByUsers detaches the given users; it answers the
// number of rows removed.
DeleteGroupOwnersByUsers(ctx context.Context, accountID, groupID uuid.UUID, userIDs []uuid.UUID) (int64, error)
// UserByID loads a user (owner attach validates them).
UserByID(ctx context.Context, accountID, id uuid.UUID) (domain.User, error)
// GroupIDsOfUser answers the group ids the user belongs to or owns.
GroupIDsOfUser(ctx context.Context, accountID, userID uuid.UUID) ([]uuid.UUID, error)
// OwnedGroupIDsOfUser excludes membership-only groups.
OwnedGroupIDsOfUser(ctx context.Context, accountID, userID uuid.UUID) ([]uuid.UUID, error)
// UserLicenseIDs answers the user's license ids.
UserLicenseIDs(ctx context.Context, accountID, userID uuid.UUID) ([]uuid.UUID, error)
// UserProductIDs answers the product ids behind the user's licenses.
UserProductIDs(ctx context.Context, accountID, userID uuid.UUID) ([]uuid.UUID, error)
}
Store is the scenario's consumer-side storage port.