From be8fe6d26e0b968f0c40ef0c6606d1218403c4bd Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 2 Apr 2018 12:11:42 -0400 Subject: [PATCH] Byond client --- .../Models/ByondStatus.cs | 35 ++++++++++++++++ .../Components/IByondClient.cs | 33 +++++++++++++++ .../Components/IInstanceClient.cs | 7 +++- .../Rights/ByondRights.cs | 40 +++++++++++++++++++ .../Rights/InstanceRights.cs | 10 ++++- .../Rights/ServerRights.cs | 2 +- 6 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/Tgstation.Server.Api/Models/ByondStatus.cs create mode 100644 src/Tgstation.Server.Client/Components/IByondClient.cs create mode 100644 src/Tgstation.Server.Client/Rights/ByondRights.cs diff --git a/src/Tgstation.Server.Api/Models/ByondStatus.cs b/src/Tgstation.Server.Api/Models/ByondStatus.cs new file mode 100644 index 0000000000..d722f1c4e7 --- /dev/null +++ b/src/Tgstation.Server.Api/Models/ByondStatus.cs @@ -0,0 +1,35 @@ +namespace Tgstation.Server.Api.Models +{ + /// + /// The status of a BYOND update job + /// +#pragma warning disable CA1717 // Only FlagsAttribute enums should have plural names + public enum ByondStatus +#pragma warning restore CA1717 // Only FlagsAttribute enums should have plural names + { + /// + /// No update in progress + /// + Idle, + /// + /// Preparing to update + /// + Starting, + /// + /// Revision is downloading + /// + Downloading, + /// + /// Revision is deflating + /// + Staging, + /// + /// Revision is ready and waiting for DreamDaemon reboot + /// + Staged, + /// + /// Revision is being applied + /// + Updating, + } +} diff --git a/src/Tgstation.Server.Client/Components/IByondClient.cs b/src/Tgstation.Server.Client/Components/IByondClient.cs new file mode 100644 index 0000000000..76291f4347 --- /dev/null +++ b/src/Tgstation.Server.Client/Components/IByondClient.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading.Tasks; +using Tgstation.Server.Api.Models; +using Tgstation.Server.Client.Rights; + +namespace Tgstation.Server.Client.Components +{ + /// + /// For managing the BYOND installation + /// + public interface IByondClient : IClient + { + /// + /// Gets the current status of any BYOND updates + /// + /// A resulting in the updater + Task CurrentStatus(); + + /// + /// Updates the installed BYOND + /// + /// The to update to. Only considers the and numbers + /// A representing the running operation + Task UpdateToVersion(Version version); + + /// + /// Get the currently installed BYOND + /// + /// Read the staged instead if applicable + /// A resulting in the installed BYOND version or if none is installed + Task GetVersion(bool staged); + } +} diff --git a/src/Tgstation.Server.Client/Components/IInstanceClient.cs b/src/Tgstation.Server.Client/Components/IInstanceClient.cs index 29d6d50a1c..6dd435c045 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceClient.cs @@ -1,7 +1,7 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Client.Rights; -namespace Tgstation.Server.Client +namespace Tgstation.Server.Client.Components { /// /// for server instances @@ -12,5 +12,10 @@ namespace Tgstation.Server.Client /// The of the /// Instance Metadata { get; } + + /// + /// Access the + /// + IByondClient Byond { get; } } } \ No newline at end of file diff --git a/src/Tgstation.Server.Client/Rights/ByondRights.cs b/src/Tgstation.Server.Client/Rights/ByondRights.cs new file mode 100644 index 0000000000..3c17bc4439 --- /dev/null +++ b/src/Tgstation.Server.Client/Rights/ByondRights.cs @@ -0,0 +1,40 @@ +using System; + +namespace Tgstation.Server.Client.Rights +{ + /// + /// Rights for + /// + [Flags] + public enum ByondRights + { + /// + /// User has no rights + /// + None = 0, + /// + /// User may check the installed BYOND version + /// + ReadInstalled = 1, + /// + /// User may check the staged BYOND version + /// + ReadStaged = 2, + /// + /// User may install any BYOND version if none is installed + /// + Install = 4, + /// + /// User may upgrade the installed BYOND version + /// + Upgrade = 8, + /// + /// User may downgrade the installed BYOND version + /// + Downgrade = 16, + /// + /// User may cancel any pending installation job + /// + Cancel = 32 + } +} diff --git a/src/Tgstation.Server.Client/Rights/InstanceRights.cs b/src/Tgstation.Server.Client/Rights/InstanceRights.cs index 20b2998f72..0613badfc2 100644 --- a/src/Tgstation.Server.Client/Rights/InstanceRights.cs +++ b/src/Tgstation.Server.Client/Rights/InstanceRights.cs @@ -3,10 +3,18 @@ namespace Tgstation.Server.Client.Rights { /// - /// Rights for an + /// Rights for an /// [Flags] public enum InstanceRights { + /// + /// User has no rights + /// + None = 0, + /// + /// Allow access to + /// + Byond = 1, } } diff --git a/src/Tgstation.Server.Client/Rights/ServerRights.cs b/src/Tgstation.Server.Client/Rights/ServerRights.cs index d875941010..640f44dc3f 100644 --- a/src/Tgstation.Server.Client/Rights/ServerRights.cs +++ b/src/Tgstation.Server.Client/Rights/ServerRights.cs @@ -9,7 +9,7 @@ namespace Tgstation.Server.Client.Rights public enum ServerRights { /// - /// Client has no rights + /// User has no rights /// None = 0, ///