tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
UserGroup.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel.DataAnnotations;
4using System.Linq;
5
9
11{
15 public sealed class UserGroup : NamedEntity, ILegacyApiTransformable<UserGroupResponse>, IApiTransformable<UserGroup, GraphQL.Types.UserGroup, UserGroupGraphQLTransformer>
16 {
20 [Required]
21 public PermissionSet? PermissionSet { get; set; }
22
26 public ICollection<User>? Users { get; set; }
27
33 public UserGroupResponse ToApi(bool showUsers) => new()
34 {
35 Id = Id,
36 Name = Name,
37 PermissionSet = (PermissionSet ?? throw new InvalidOperationException("PermissionSet must be set!")).ToApi(),
38 Users = showUsers
39 ? Users
40 ?.Select(x => x.CreateUserName())
41 .ToList()
42 ?? new List<UserName>()
43 : null,
44 };
45
47 public UserGroupResponse ToApi() => ToApi(true);
48 }
49}
virtual ? long Id
The ID of the entity.
Definition EntityId.cs:13
Base class for named entities.
Definition NamedEntity.cs:9
virtual ? string Name
The name of the entity represented by the NamedEntity.
Represents a group of Users.
Definition UserGroup.cs:16
ICollection< User >? Users
The Users the UserGroup has.
Definition UserGroup.cs:26
UserGroupResponse ToApi(bool showUsers)
Convert the UserGroup to it's API form.
Represents a host-side model that may be transformed into a TApiModel .
Represents a host-side model that may be transformed into a TApiModel .
@ Required
DMAPI validation must suceed for the deployment to succeed.