From f3f77c7cf93daa7f33889893da147bc9355430f7 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 2 Apr 2018 17:09:54 -0400 Subject: [PATCH] Administration model --- .../Models/Administration.cs | 27 +++++++++ .../Models/DreamDaemon.cs | 26 ++++---- src/Tgstation.Server.Api/Models/User.cs | 38 ++++++++++++ .../Rights/AdministrationRights.cs | 28 +++++++++ .../Rights/DreamDaemonRights.cs | 60 +++++++++++++++++++ .../Components/IDreamDaemonClient.cs | 42 +++++++++++++ .../Components/IInstanceClient.cs | 2 +- .../Components/IInstanceManagerClient.cs | 4 +- 8 files changed, 211 insertions(+), 16 deletions(-) create mode 100644 src/Tgstation.Server.Api/Models/Administration.cs create mode 100644 src/Tgstation.Server.Api/Models/User.cs create mode 100644 src/Tgstation.Server.Api/Rights/AdministrationRights.cs create mode 100644 src/Tgstation.Server.Api/Rights/DreamDaemonRights.cs create mode 100644 src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs diff --git a/src/Tgstation.Server.Api/Models/Administration.cs b/src/Tgstation.Server.Api/Models/Administration.cs new file mode 100644 index 0000000000..668ba0dd0a --- /dev/null +++ b/src/Tgstation.Server.Api/Models/Administration.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tgstation.Server.Api.Models +{ + /// + /// Metadata about an installation + /// + public sealed class Administration + { + /// + /// Use the specified Windows/UNIX authentication to authorize users. Setting this to enables full administrative anonymous access + /// + public string SystemAuthenticationGroup { get; set; } + + /// + /// Automatically send unhandled exception data to a public collection service. This will be limited to system information, path data, and game code compilation information. + /// + public bool EnableTelemetry { get; set; } + + /// + /// Users in the . Not modifiable + /// + public IReadOnlyList Users { get; set; } + } +} diff --git a/src/Tgstation.Server.Api/Models/DreamDaemon.cs b/src/Tgstation.Server.Api/Models/DreamDaemon.cs index 4394923f37..974bf1d83e 100644 --- a/src/Tgstation.Server.Api/Models/DreamDaemon.cs +++ b/src/Tgstation.Server.Api/Models/DreamDaemon.cs @@ -10,61 +10,61 @@ namespace Tgstation.Server.Api.Models /// /// The pull requests merged on the live game version. Not modifiable /// - IReadOnlyDictionary PullRequests { get; set; } + public IReadOnlyDictionary PullRequests { get; set; } /// /// The git sha the live game version was compiled at. Not modifiable /// - string Sha { get; set; } + public string Sha { get; set; } /// /// The git sha of the origin branch the live game version was compiled at. Not modifiable /// - string OriginSha { get; set; } - + public string OriginSha { get; set; } + /// /// If starts when it's starts /// - bool? AutoStart { get; set; } + public bool? AutoStart { get; set; } /// /// The current status of /// - DreamDaemonStatus? Status { get; set; } + public DreamDaemonStatus? Status { get; set; } /// /// If the BYOND web client can be used to connect to the game server /// - bool? AllowWebClient { get; set; } + public bool? AllowWebClient { get; set; } /// /// If the server is undergoing a soft reset. This may be automatically set by changes to other fields /// - bool? SoftRestart { get; set; } + public bool? SoftRestart { get; set; } /// /// If the server is undergoing a soft shutdown /// - bool? SoftShutdown { get; set; } + public bool? SoftShutdown { get; set; } /// /// The level of /// - DreamDaemonSecurity? SecurirtyLevel { get; set; } + public DreamDaemonSecurity? SecurirtyLevel { get; set; } /// /// The first port uses. This should be the publically advertised port /// - ushort? PrimaryPort { get; set; } + public ushort? PrimaryPort { get; set; } /// /// The second port uses /// - ushort? SecondaryPort { get; set; } + public ushort? SecondaryPort { get; set; } /// /// The port the running instance is set to. Not modifiable /// - bool CurrentPort { get; set; } + public bool CurrentPort { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/User.cs b/src/Tgstation.Server.Api/Models/User.cs new file mode 100644 index 0000000000..82699749a9 --- /dev/null +++ b/src/Tgstation.Server.Api/Models/User.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using Tgstation.Server.Api.Rights; + +namespace Tgstation.Server.Api.Models +{ + /// + /// Represents a server + /// + public sealed class User + { + /// + /// The system identifier for the . On Windows, this is the user's SecurityIdentifier. On UNIX, this is their UID + /// + public string SystemIdentifier { get; set; } + + /// + /// The name of the + /// + public string Name { get; set; } + + /// + /// The for the + /// + public AdministrationRights AdministrationRights { get; set; } + + /// + /// The for the + /// + public InstanceManagerRights InstanceManagerRights { get; set; } + + /// + /// of s the can view + /// +#pragma warning disable CA2227 // Collection properties should be read only + public List ViewableInstanceIds { get; set; } +#pragma warning restore CA2227 // Collection properties should be read only + } +} \ No newline at end of file diff --git a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs new file mode 100644 index 0000000000..da7cb3d559 --- /dev/null +++ b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs @@ -0,0 +1,28 @@ +using System; + +namespace Tgstation.Server.Api.Rights +{ + /// + /// Rights for + /// + [Flags] + public enum AdministrationRights + { + /// + /// User has no rights + /// + None = 0, + /// + /// User can change + /// + ChangeAuthenticationGroup = 1, + /// + /// User can change + /// + ChangeTelemetry = 2, + /// + /// User can edit themself and other s + /// + EditUsers = 4, + } +} diff --git a/src/Tgstation.Server.Api/Rights/DreamDaemonRights.cs b/src/Tgstation.Server.Api/Rights/DreamDaemonRights.cs new file mode 100644 index 0000000000..51591eb334 --- /dev/null +++ b/src/Tgstation.Server.Api/Rights/DreamDaemonRights.cs @@ -0,0 +1,60 @@ +using System; + +namespace Tgstation.Server.Api.Rights +{ + /// + /// Rights for + /// + [Flags] + public enum DreamDaemonRights + { + /// + /// User has no rights + /// + None = 0, + /// + /// User can read , , and + /// + ReadRevision = 1, + /// + /// User can change both primary and secondary ports + /// + SetPorts = 2, + /// + /// User can change + /// + SetAutoStart = 4, + /// + /// User set + /// + SetSecurity = 8, + /// + /// User can read all ports, , , , , and + /// + ReadMetadata = 16, + /// + /// User can change + /// + SetWebClient = 32, + /// + /// User can enable + /// + SoftRestart = 64, + /// + /// User can enable + /// + SoftShutdown = 128, + /// + /// User can immediately restart + /// + Restart = 256, + /// + /// User can immediately shutdown + /// + Shutdown = 512, + /// + /// User can start and disable and + /// + Start = 1024 + } +} diff --git a/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs b/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs new file mode 100644 index 0000000000..fb4a0d38d3 --- /dev/null +++ b/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs @@ -0,0 +1,42 @@ +using System.Threading; +using System.Threading.Tasks; +using Tgstation.Server.Api.Models; +using Tgstation.Server.Api.Rights; + +namespace Tgstation.Server.Client.Components +{ + /// + /// For managing + /// + interface IDreamDaemonClient: IRightsClient + { + /// + /// Get the represented by the + /// + /// The for the operation + /// A resulting in the represented by the + Task Read(CancellationToken cancellationToken); + + /// + /// Start + /// + /// The for the operation + /// A representing the running operation + Task Start(CancellationToken cancellationToken); + + /// + /// Stop + /// + /// The for the operation + /// A representing the running operation + Task Stop(CancellationToken cancellationToken); + + /// + /// Update . This may trigger + /// + /// The to update + /// The for the operation + /// A representing the running operation + Task Update(DreamDaemon dreamDaemon, CancellationToken cancellationToken); + } +} diff --git a/src/Tgstation.Server.Client/Components/IInstanceClient.cs b/src/Tgstation.Server.Client/Components/IInstanceClient.cs index 24338095c8..18d1252c65 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceClient.cs @@ -6,7 +6,7 @@ using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client.Components { /// - /// Client for s + /// For managing a single /// public interface IInstanceClient : IRightsClient { diff --git a/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs b/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs index a5fbfc3584..4e87ed6d46 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs @@ -7,9 +7,9 @@ using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client.Components { /// - /// Manager for s + /// For managing s /// - public interface IInstanceManagerClient : IRightsClient + public interface IInstanceManagerClient : IRightsClient { /// /// Get all s for s the user can view