howdy/auth/groups
Group management. Every operation here is privileged: authorize the
caller first, as with auth.suspend. None is exposed over HTTP. Choose
how users relate to groups with auth.with_groups.
Values
pub fn create(
identity: auth.Auth,
name name: String,
by actor: user.Actor,
) -> Result(group.Group, service.Error)
Create a group with a generated id.
pub fn create_with(
identity: auth.Auth,
id id: String,
name name: String,
fields changes: List(field.Change),
by actor: user.Actor,
) -> Result(group.Group, service.Error)
As create_with_id, setting fields on the new group in the same
transaction; see howdy/auth/field. Pass token.new-style ids of your
own, or use create and update when the id should be generated.
pub fn create_with_id(
identity: auth.Auth,
id id: String,
name name: String,
by actor: user.Actor,
) -> Result(group.Group, service.Error)
Create a group under an id of your choosing, such as a tenant’s slug: 1 to 64 of letters, digits, hyphen and underscore. Conflict if it is taken.
pub fn delete(
identity: auth.Auth,
id: String,
by actor: user.Actor,
) -> Result(Nil, service.Error)
Delete an empty group. Conflict while it has users: move them first. The default group cannot be deleted.
pub fn fields(
identity: auth.Auth,
id: String,
) -> Result(field.Fields, service.Error)
The fields the group holds; read them with field.get.
pub fn find(
identity: auth.Auth,
where field: field.Field(a),
is value: a,
) -> Result(List(group.Group), service.Error)
The groups holding value in a field, by name: at most one when the
field is unique.
pub fn get(
identity: auth.Auth,
id: String,
) -> Result(group.Group, service.Error)
pub fn list(
identity: auth.Auth,
) -> Result(List(group.Group), service.Error)
Every group, by name.
pub fn members(
identity: auth.Auth,
id: String,
) -> Result(List(user.User), service.Error)
The group’s users, by email address.
pub fn move(
identity: auth.Auth,
user_id: String,
to id: String,
by actor: user.Actor,
) -> Result(user.User, service.Error)
Put a user in another group; they leave the one they were in. Their
sessions and credentials go with them. Invalid under Single, and
Conflict under AccountPerGroup when the destination already has an
account for their address. Role assignments are untouched: revoke any
scoped to the old group yourself.
pub fn rename(
identity: auth.Auth,
id: String,
to name: String,
by actor: user.Actor,
) -> Result(group.Group, service.Error)
pub fn update(
identity: auth.Auth,
id: String,
changes: List(field.Change),
by actor: user.Actor,
) -> Result(group.Group, service.Error)
Set and clear fields on a group, all or nothing. Conflict when a unique value is held by another group.