mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
Questionable behaviour refactor
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,8 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <summary>
|
||||
/// For managing the BYOND installation
|
||||
/// </summary>
|
||||
public interface IByondClient : IClient<ByondRights>
|
||||
public interface IByondClient : IClient<ByondRights, Byond>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current status of any BYOND updates
|
||||
/// </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<Byond> Read(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the installed BYOND <see cref="Version"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -4,15 +4,10 @@ using Tgstation.Server.Api.Rights;
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="IClient{TRights}"/> for server instances
|
||||
/// <see cref="IClient{TRights, TModel}"/> for server instances
|
||||
/// </summary>
|
||||
public interface IInstanceClient : IClient<InstanceRights>
|
||||
public interface IInstanceClient : IClient<InstanceRights, Instance>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Instance"/> of the <see cref="IInstanceClient"/>
|
||||
/// </summary>
|
||||
Instance Metadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="IByondClient"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -9,22 +9,15 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <summary>
|
||||
/// Manager for <see cref="Instance"/>s
|
||||
/// </summary>
|
||||
public interface IInstanceManagerClient : IClient<InstanceRights>
|
||||
public interface IInstanceManagerClient : IClient<InstanceRights, IReadOnlyList<IInstanceClient>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all <see cref="IInstanceClient"/>s for <see cref="Instance"/>s that the <see cref="IClient{TRights}"/> can view
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="IReadOnlyList{T}"/> of <see cref="IInstanceClient"/>s</returns>
|
||||
Task<IReadOnlyList<IInstanceClient>> GetInstanceClients(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Create an <paramref name="instance"/>
|
||||
/// </summary>
|
||||
/// <param name="instance">The <see cref="Instance"/> to create. <see cref="Instance.Id"/> will be ignored</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in <see cref="IInstanceClient"/> for the created <see cref="Instance"/></returns>
|
||||
Task<IInstanceClient> CreateInstance(Instance instance, CancellationToken cancellationToken);
|
||||
Task<IInstanceClient> Create(Instance instance, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Relocates, renamed, and/or on/offlines an <paramref name="instance"/>
|
||||
@@ -32,7 +25,7 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <param name="instance">The <see cref="Instance"/> to update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task UpdateInstance(Instance instance, CancellationToken cancellationToken);
|
||||
Task Update(Instance instance, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an <paramref name="instance"/>
|
||||
@@ -40,6 +33,6 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <param name="instance">The <see cref="Instance"/> to delete</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task DeleteInstance(Instance instance, CancellationToken cancellationToken);
|
||||
Task Delete(Instance instance, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,27 +9,20 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <summary>
|
||||
/// <see cref="IServerClient"/> for managing <see cref="Token"/>s
|
||||
/// </summary>
|
||||
public interface ITokenClient: IClient<TokenRights>
|
||||
public interface ITokenClient: IClient<TokenRights, Token>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a new token for the <see cref="IServerClient"/>'s <see cref="System.Net.IPAddress"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> resulting in a new <see cref="Token"/> for the <see cref="IServerClient"/></returns>
|
||||
Task<Token> Generate(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all active <see cref="TokenInfo"/>s for the <see cref="IServerClient"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> resulting a <see cref="IReadOnlyList{T}"/> of active <see cref="TokenInfo"/>s for the <see cref="IServerClient"/></returns>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting a <see cref="IReadOnlyList{T}"/> of active <see cref="TokenInfo"/>s for the <see cref="IServerClient"/></returns>
|
||||
Task<IReadOnlyList<TokenInfo>> GetClientInfos(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all active <see cref="TokenInfo"/>s for all users
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> resulting a <see cref="IReadOnlyDictionary{TKey, TValue}"/> of active <see cref="TokenInfo"/>s for the <see cref="IServerClient"/> keyed by username</returns>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting a <see cref="IReadOnlyDictionary{TKey, TValue}"/> of active <see cref="TokenInfo"/>s for the <see cref="IServerClient"/> keyed by username</returns>
|
||||
Task<IReadOnlyDictionary<string, TokenInfo>> GetAllInfos(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,24 +6,22 @@ namespace Tgstation.Server.Client
|
||||
/// <summary>
|
||||
/// Basic <see cref="Api"/> client
|
||||
/// </summary>
|
||||
/// <typeparam name="TRights">The <see cref="Api.Rights"/> for the <see cref="IClient{TRights}"/></typeparam>
|
||||
public interface IClient<TRights>
|
||||
/// <typeparam name="TRights">The <see cref="Api.Rights"/> for the <see cref="IClient{TRights, TModel}"/></typeparam>
|
||||
/// <typeparam name="TModel">Which of the <see cref="Api.Models"/> the <see cref="IClient{TRights, TModel}"/> represents</typeparam>
|
||||
public interface IClient<TRights, TModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// The connection timeout in milliseconds
|
||||
/// </summary>
|
||||
int Timeout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The requery rate for job updates in milliseconds
|
||||
/// </summary>
|
||||
int RequeryRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the <typeparamref name="TRights"/> for the <see cref="IClient{TRights}"/>
|
||||
/// Get the <typeparamref name="TRights"/> for the <see cref="IClient{TRights, TModel}"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <typeparamref name="TRights"/> for the <see cref="IClient{TRights}"/></returns>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <typeparamref name="TRights"/> for the <see cref="IClient{TRights, TModel}"/></returns>
|
||||
Task<TRights> Rights(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Read the <typeparamref name="TModel"/> of the <see cref="IClient{TRights, TModel}"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>The <typeparamref name="TModel"/> of the <see cref="IClient{TRights, TModel}"/></returns>
|
||||
Task<TModel> Read(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,38 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Client.Components;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
|
||||
namespace Tgstation.Server.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="IClient{TRights}"/> for communicating with a server
|
||||
/// Main client for communicating with a server
|
||||
/// </summary>
|
||||
public interface IServerClient : IDisposable, IClient<ServerRights>
|
||||
public interface IServerClient : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="System.Version"/> of the <see cref="IServerClient"/>
|
||||
/// </summary>
|
||||
Version Version { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The connection timeout in milliseconds
|
||||
/// </summary>
|
||||
int Timeout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The requery rate for job updates in milliseconds
|
||||
/// </summary>
|
||||
int RequeryRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="ITokenClient"/>
|
||||
/// </summary>
|
||||
ITokenClient Token { get; }
|
||||
ITokenClient Tokens { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="IInstanceManagerClient"/>
|
||||
/// </summary>
|
||||
IInstanceManagerClient Instance { get; }
|
||||
IInstanceManagerClient Instances { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Version"/> of the connected server
|
||||
|
||||
Reference in New Issue
Block a user