From 7dd3cdb3a3330d833e59d414a92e83d190fcbafe Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 2 Apr 2018 12:31:07 -0400 Subject: [PATCH] Move rights to the API --- src/Tgstation.Server.Api/Models/Byond.cs | 20 ++++++++ .../Models/ByondStatus.cs | 6 ++- .../Rights/ByondRights.cs | 12 +++-- .../Rights/InstanceManagerRights.cs | 48 +++++++++++++++++++ .../Rights/InstanceRights.cs | 6 +-- .../Rights/ServerRights.cs | 24 ++++++++++ .../Rights/TokenRights.cs | 10 ++-- .../Components/IByondClient.cs | 9 ++-- .../Components/IInstanceClient.cs | 2 +- .../Components/IInstanceManagerClient.cs | 2 +- .../Components/ITokenClient.cs | 2 +- src/Tgstation.Server.Client/IClient.cs | 2 +- src/Tgstation.Server.Client/IServerClient.cs | 3 +- .../Rights/InstanceManagerRights.cs | 48 ------------------- .../Rights/ServerRights.cs | 25 ---------- 15 files changed, 123 insertions(+), 96 deletions(-) create mode 100644 src/Tgstation.Server.Api/Models/Byond.cs rename src/{Tgstation.Server.Client => Tgstation.Server.Api}/Rights/ByondRights.cs (71%) create mode 100644 src/Tgstation.Server.Api/Rights/InstanceManagerRights.cs rename src/{Tgstation.Server.Client => Tgstation.Server.Api}/Rights/InstanceRights.cs (56%) create mode 100644 src/Tgstation.Server.Api/Rights/ServerRights.cs rename src/{Tgstation.Server.Client => Tgstation.Server.Api}/Rights/TokenRights.cs (63%) delete mode 100644 src/Tgstation.Server.Client/Rights/InstanceManagerRights.cs delete mode 100644 src/Tgstation.Server.Client/Rights/ServerRights.cs diff --git a/src/Tgstation.Server.Api/Models/Byond.cs b/src/Tgstation.Server.Api/Models/Byond.cs new file mode 100644 index 0000000000..d0de46ce47 --- /dev/null +++ b/src/Tgstation.Server.Api/Models/Byond.cs @@ -0,0 +1,20 @@ +using System; + +namespace Tgstation.Server.Api.Models +{ + /// + /// Represents a BYOND installation + /// + public sealed class Byond + { + /// + /// The for the installation + /// + public ByondStatus ByondStatus { get; set; } + + /// + /// The of the installation. Will be if the user does not have permission to view it or there is no BYOND version installed. Only considers the and numbers + /// + public Version Version { get; set; } + } +} diff --git a/src/Tgstation.Server.Api/Models/ByondStatus.cs b/src/Tgstation.Server.Api/Models/ByondStatus.cs index d722f1c4e7..638a91e475 100644 --- a/src/Tgstation.Server.Api/Models/ByondStatus.cs +++ b/src/Tgstation.Server.Api/Models/ByondStatus.cs @@ -1,7 +1,7 @@ namespace Tgstation.Server.Api.Models { /// - /// The status of a BYOND update job + /// The status of a update job /// #pragma warning disable CA1717 // Only FlagsAttribute enums should have plural names public enum ByondStatus @@ -31,5 +31,9 @@ /// Revision is being applied /// Updating, + /// + /// User does not have permission to view the + /// + Hidden, } } diff --git a/src/Tgstation.Server.Client/Rights/ByondRights.cs b/src/Tgstation.Server.Api/Rights/ByondRights.cs similarity index 71% rename from src/Tgstation.Server.Client/Rights/ByondRights.cs rename to src/Tgstation.Server.Api/Rights/ByondRights.cs index 3c17bc4439..0b96b9783a 100644 --- a/src/Tgstation.Server.Client/Rights/ByondRights.cs +++ b/src/Tgstation.Server.Api/Rights/ByondRights.cs @@ -1,9 +1,9 @@ using System; -namespace Tgstation.Server.Client.Rights +namespace Tgstation.Server.Api.Rights { /// - /// Rights for + /// Rights for /// [Flags] public enum ByondRights @@ -33,8 +33,12 @@ namespace Tgstation.Server.Client.Rights /// Downgrade = 16, /// - /// User may cancel any pending installation job + /// User may cancel a pending installation job /// - Cancel = 32 + Cancel = 32, + /// + /// User may read the of the installation job + /// + ReadStatus = 64, } } diff --git a/src/Tgstation.Server.Api/Rights/InstanceManagerRights.cs b/src/Tgstation.Server.Api/Rights/InstanceManagerRights.cs new file mode 100644 index 0000000000..31a7eea0d3 --- /dev/null +++ b/src/Tgstation.Server.Api/Rights/InstanceManagerRights.cs @@ -0,0 +1,48 @@ +using System; + +namespace Tgstation.Server.Api.Rights +{ + /// + /// Rights for managing s + /// + [Flags] + public enum InstanceManagerRights + { + /// + /// User has no rights + /// + None = 0, + /// + /// User can view s which they have any rights for + /// + Read = 1, + /// + /// User can create s + /// + Create = 2, + /// + /// User can rename s they can view + /// + Rename = 4, + /// + /// User can relocate s they can view + /// + Relocate = 8, + /// + /// User can online s they can view + /// + Online = 16, + /// + /// User can offline s they can view + /// + Offline = 32, + /// + /// User can delete s they can view + /// + Delete = 64, + /// + /// User can view all s + /// + List = 128 + } +} diff --git a/src/Tgstation.Server.Client/Rights/InstanceRights.cs b/src/Tgstation.Server.Api/Rights/InstanceRights.cs similarity index 56% rename from src/Tgstation.Server.Client/Rights/InstanceRights.cs rename to src/Tgstation.Server.Api/Rights/InstanceRights.cs index 0613badfc2..31dfa21825 100644 --- a/src/Tgstation.Server.Client/Rights/InstanceRights.cs +++ b/src/Tgstation.Server.Api/Rights/InstanceRights.cs @@ -1,9 +1,9 @@ using System; -namespace Tgstation.Server.Client.Rights +namespace Tgstation.Server.Api.Rights { /// - /// Rights for an + /// Rights for an /// [Flags] public enum InstanceRights @@ -13,7 +13,7 @@ namespace Tgstation.Server.Client.Rights /// None = 0, /// - /// Allow access to + /// Allow access to /// Byond = 1, } diff --git a/src/Tgstation.Server.Api/Rights/ServerRights.cs b/src/Tgstation.Server.Api/Rights/ServerRights.cs new file mode 100644 index 0000000000..60f6e98172 --- /dev/null +++ b/src/Tgstation.Server.Api/Rights/ServerRights.cs @@ -0,0 +1,24 @@ +using System; + +namespace Tgstation.Server.Api.Rights +{ + /// + /// Rights a user has for an entire server + /// + [Flags] + public enum ServerRights + { + /// + /// User has no rights + /// + None = 0, + /// + /// Allow access to the of the server + /// + Version = 1, + /// + /// Allow access to s + /// + Tokens = 2, + } +} \ No newline at end of file diff --git a/src/Tgstation.Server.Client/Rights/TokenRights.cs b/src/Tgstation.Server.Api/Rights/TokenRights.cs similarity index 63% rename from src/Tgstation.Server.Client/Rights/TokenRights.cs rename to src/Tgstation.Server.Api/Rights/TokenRights.cs index 70bddf5441..ba958fd380 100644 --- a/src/Tgstation.Server.Client/Rights/TokenRights.cs +++ b/src/Tgstation.Server.Api/Rights/TokenRights.cs @@ -1,9 +1,9 @@ using System; -namespace Tgstation.Server.Client.Rights +namespace Tgstation.Server.Api.Rights { /// - /// Rights for + /// Rights for s /// [Flags] public enum TokenRights @@ -13,15 +13,15 @@ namespace Tgstation.Server.Client.Rights /// None = 0, /// - /// User can create s + /// User can create s /// Create = 1, /// - /// User can delete s + /// User can delete s /// Delete = 2, /// - /// User can list all their s + /// User can list all their s /// List = 4, /// diff --git a/src/Tgstation.Server.Client/Components/IByondClient.cs b/src/Tgstation.Server.Client/Components/IByondClient.cs index 2c9ca74652..942fcf1fc7 100644 --- a/src/Tgstation.Server.Client/Components/IByondClient.cs +++ b/src/Tgstation.Server.Client/Components/IByondClient.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; -using Tgstation.Server.Client.Rights; +using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client.Components { @@ -16,15 +16,16 @@ namespace Tgstation.Server.Client.Components /// /// The for the operation /// A resulting in the updater - Task CurrentStatus(CancellationToken cancellationToken); + Task Read(CancellationToken cancellationToken); /// /// Updates the installed BYOND /// - /// The to update to. Only considers the and numbers + /// The to update + /// Optional taking a to run when it changes /// The for the operation /// A representing the running operation - Task UpdateToVersion(Version version, CancellationToken cancellationToken); + Task Update(Byond byond, Action progressCallback, CancellationToken cancellationToken); /// /// Get the currently installed BYOND diff --git a/src/Tgstation.Server.Client/Components/IInstanceClient.cs b/src/Tgstation.Server.Client/Components/IInstanceClient.cs index 6dd435c045..03b2a06e70 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceClient.cs @@ -1,5 +1,5 @@ using Tgstation.Server.Api.Models; -using Tgstation.Server.Client.Rights; +using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client.Components { diff --git a/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs b/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs index f615eaa389..d8eb5493c6 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; -using Tgstation.Server.Client.Rights; +using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client.Components { diff --git a/src/Tgstation.Server.Client/Components/ITokenClient.cs b/src/Tgstation.Server.Client/Components/ITokenClient.cs index 7365fedf11..155975f528 100644 --- a/src/Tgstation.Server.Client/Components/ITokenClient.cs +++ b/src/Tgstation.Server.Client/Components/ITokenClient.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; -using Tgstation.Server.Client.Rights; +using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client.Components { diff --git a/src/Tgstation.Server.Client/IClient.cs b/src/Tgstation.Server.Client/IClient.cs index 2091805d10..b83a7248d6 100644 --- a/src/Tgstation.Server.Client/IClient.cs +++ b/src/Tgstation.Server.Client/IClient.cs @@ -6,7 +6,7 @@ namespace Tgstation.Server.Client /// /// Basic client /// - /// The for the + /// The for the public interface IClient { /// diff --git a/src/Tgstation.Server.Client/IServerClient.cs b/src/Tgstation.Server.Client/IServerClient.cs index 6e1baa11d4..72f602066d 100644 --- a/src/Tgstation.Server.Client/IServerClient.cs +++ b/src/Tgstation.Server.Client/IServerClient.cs @@ -1,9 +1,8 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Client.Components; -using Tgstation.Server.Client.Rights; +using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Client { diff --git a/src/Tgstation.Server.Client/Rights/InstanceManagerRights.cs b/src/Tgstation.Server.Client/Rights/InstanceManagerRights.cs deleted file mode 100644 index 7414d61db8..0000000000 --- a/src/Tgstation.Server.Client/Rights/InstanceManagerRights.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace Tgstation.Server.Client.Rights -{ - /// - /// Rights for - /// - [Flags] - public enum InstanceManagerRights - { - /// - /// User has no rights - /// - None = 0, - /// - /// User can view s which they have any rights for - /// - Read = 1, - /// - /// User can create s - /// - Create = 2, - /// - /// User can rename s they can view - /// - Rename = 4, - /// - /// User can relocate s they can view - /// - Relocate = 8, - /// - /// User can online s they can view - /// - Online = 16, - /// - /// User can offline s they can view - /// - Offline = 32, - /// - /// User can delete s they can view - /// - Delete = 64, - /// - /// User can view all s - /// - List = 128 - } -} diff --git a/src/Tgstation.Server.Client/Rights/ServerRights.cs b/src/Tgstation.Server.Client/Rights/ServerRights.cs deleted file mode 100644 index 640f44dc3f..0000000000 --- a/src/Tgstation.Server.Client/Rights/ServerRights.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Tgstation.Server.Client.Rights -{ - /// - /// Rights a has for a server. If a method isn't listed below - /// - [Flags] - public enum ServerRights - { - /// - /// User has no rights - /// - None = 0, - /// - /// Allow access to - /// - /// This implies access to any APIs not otherwise listed here - Version = 1, - /// - /// Allow access to - /// - Tokens = 2, - } -} \ No newline at end of file