mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Move rights to the API
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a BYOND installation
|
||||
/// </summary>
|
||||
public sealed class Byond
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="ByondStatus"/> for the <see cref="Byond"/> installation
|
||||
/// </summary>
|
||||
public ByondStatus ByondStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Version"/> of the <see cref="Byond"/> installation. Will be <see langword="null"/> if the user does not have permission to view it or there is no BYOND version installed. Only considers the <see cref="Version.Major"/> and <see cref="Version.Minor"/> numbers
|
||||
/// </summary>
|
||||
public Version Version { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Tgstation.Server.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// The status of a BYOND update job
|
||||
/// The status of a <see cref="Byond"/> update job
|
||||
/// </summary>
|
||||
#pragma warning disable CA1717 // Only FlagsAttribute enums should have plural names
|
||||
public enum ByondStatus
|
||||
@@ -31,5 +31,9 @@
|
||||
/// Revision is being applied
|
||||
/// </summary>
|
||||
Updating,
|
||||
/// <summary>
|
||||
/// User does not have permission to view the <see cref="ByondStatus"/>
|
||||
/// </summary>
|
||||
Hidden,
|
||||
}
|
||||
}
|
||||
|
||||
+8
-4
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Client.Rights
|
||||
namespace Tgstation.Server.Api.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights for <see cref="Components.IByondClient"/>
|
||||
/// Rights for <see cref="Models.Byond"/>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ByondRights
|
||||
@@ -33,8 +33,12 @@ namespace Tgstation.Server.Client.Rights
|
||||
/// </summary>
|
||||
Downgrade = 16,
|
||||
/// <summary>
|
||||
/// User may cancel any pending installation job
|
||||
/// User may cancel a pending installation job
|
||||
/// </summary>
|
||||
Cancel = 32
|
||||
Cancel = 32,
|
||||
/// <summary>
|
||||
/// User may read the <see cref="Models.ByondStatus"/> of the installation job
|
||||
/// </summary>
|
||||
ReadStatus = 64,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Api.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights for managing <see cref="Models.Instance"/>s
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum InstanceManagerRights
|
||||
{
|
||||
/// <summary>
|
||||
/// User has no rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// User can view <see cref="Models.Instance"/>s which they have any rights for
|
||||
/// </summary>
|
||||
Read = 1,
|
||||
/// <summary>
|
||||
/// User can create <see cref="Models.Instance"/>s
|
||||
/// </summary>
|
||||
Create = 2,
|
||||
/// <summary>
|
||||
/// User can rename <see cref="Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Rename = 4,
|
||||
/// <summary>
|
||||
/// User can relocate <see cref="Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Relocate = 8,
|
||||
/// <summary>
|
||||
/// User can online <see cref="Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Online = 16,
|
||||
/// <summary>
|
||||
/// User can offline <see cref="Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Offline = 32,
|
||||
/// <summary>
|
||||
/// User can delete <see cref="Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Delete = 64,
|
||||
/// <summary>
|
||||
/// User can view all <see cref="Models.Instance"/>s
|
||||
/// </summary>
|
||||
List = 128
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Client.Rights
|
||||
namespace Tgstation.Server.Api.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights for an <see cref="Components.IInstanceClient"/>
|
||||
/// Rights for an <see cref="Models.Instance"/>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum InstanceRights
|
||||
@@ -13,7 +13,7 @@ namespace Tgstation.Server.Client.Rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Allow access to <see cref="Components.IByondClient"/>
|
||||
/// Allow access to <see cref="Models.Byond"/>
|
||||
/// </summary>
|
||||
Byond = 1,
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Api.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights a user has for an entire server
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ServerRights
|
||||
{
|
||||
/// <summary>
|
||||
/// User has no rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Allow access to the <see cref="Version"/> of the server
|
||||
/// </summary>
|
||||
Version = 1,
|
||||
/// <summary>
|
||||
/// Allow access to <see cref="Models.Token"/>s
|
||||
/// </summary>
|
||||
Tokens = 2,
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Client.Rights
|
||||
namespace Tgstation.Server.Api.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights for <see cref="Components.ITokenClient"/>
|
||||
/// Rights for <see cref="Models.Token"/>s
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum TokenRights
|
||||
@@ -13,15 +13,15 @@ namespace Tgstation.Server.Client.Rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// User can create <see cref="Api.Models.Token"/>s
|
||||
/// User can create <see cref="Models.Token"/>s
|
||||
/// </summary>
|
||||
Create = 1,
|
||||
/// <summary>
|
||||
/// User can delete <see cref="Api.Models.Token"/>s
|
||||
/// User can delete <see cref="Models.Token"/>s
|
||||
/// </summary>
|
||||
Delete = 2,
|
||||
/// <summary>
|
||||
/// User can list all their <see cref="Api.Models.TokenInfo"/>s
|
||||
/// User can list all their <see cref="Models.TokenInfo"/>s
|
||||
/// </summary>
|
||||
List = 4,
|
||||
/// <summary>
|
||||
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="ByondStatus"/> updater</returns>
|
||||
Task<ByondStatus> CurrentStatus(CancellationToken cancellationToken);
|
||||
Task<Byond> Read(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the installed BYOND <see cref="Version"/>
|
||||
/// </summary>
|
||||
/// <param name="version">The <see cref="Version"/> to update to. Only considers the <see cref="Version.Major"/> and <see cref="Version.Minor"/> numbers</param>
|
||||
/// <param name="byond">The <see cref="Byond"/> to update</param>
|
||||
/// <param name="progressCallback">Optional <see cref="Action{T1}"/> taking a <see cref="ByondStatus"/> to run when it changes</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task UpdateToVersion(Version version, CancellationToken cancellationToken);
|
||||
Task Update(Byond byond, Action<ByondStatus> progressCallback, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Get the currently installed BYOND <see cref="Version"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Client.Rights;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Tgstation.Server.Client
|
||||
/// <summary>
|
||||
/// Basic <see cref="Api"/> client
|
||||
/// </summary>
|
||||
/// <typeparam name="TRights">The <see cref="Client.Rights"/> for the <see cref="IClient{TRights}"/></typeparam>
|
||||
/// <typeparam name="TRights">The <see cref="Api.Rights"/> for the <see cref="IClient{TRights}"/></typeparam>
|
||||
public interface IClient<TRights>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Client.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights for <see cref="Components.IInstanceManagerClient"/>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum InstanceManagerRights
|
||||
{
|
||||
/// <summary>
|
||||
/// User has no rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// User can view <see cref="Api.Models.Instance"/>s which they have any rights for
|
||||
/// </summary>
|
||||
Read = 1,
|
||||
/// <summary>
|
||||
/// User can create <see cref="Api.Models.Instance"/>s
|
||||
/// </summary>
|
||||
Create = 2,
|
||||
/// <summary>
|
||||
/// User can rename <see cref="Api.Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Rename = 4,
|
||||
/// <summary>
|
||||
/// User can relocate <see cref="Api.Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Relocate = 8,
|
||||
/// <summary>
|
||||
/// User can online <see cref="Api.Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Online = 16,
|
||||
/// <summary>
|
||||
/// User can offline <see cref="Api.Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Offline = 32,
|
||||
/// <summary>
|
||||
/// User can delete <see cref="Api.Models.Instance"/>s they can view
|
||||
/// </summary>
|
||||
Delete = 64,
|
||||
/// <summary>
|
||||
/// User can view all <see cref="Api.Models.Instance"/>s
|
||||
/// </summary>
|
||||
List = 128
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Client.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights a <see cref="IServerClient"/> has for a server. If a <see cref="IServerClient"/> method isn't listed below
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ServerRights
|
||||
{
|
||||
/// <summary>
|
||||
/// User has no rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Allow access to <see cref="IServerClient.GetServerVersion"/>
|
||||
/// </summary>
|
||||
/// <remarks>This implies access to any <see cref="IServerClient"/> APIs not otherwise listed here</remarks>
|
||||
Version = 1,
|
||||
/// <summary>
|
||||
/// Allow access to <see cref="IServerClient.Token"/>
|
||||
/// </summary>
|
||||
Tokens = 2,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user