Dreammaker and jobs client

This commit is contained in:
Cyberboss
2018-04-04 17:18:49 -04:00
parent 5c7ff60829
commit 9ff800cdfe
7 changed files with 102 additions and 14 deletions
+6 -1
View File
@@ -3,7 +3,7 @@
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Represents a long running job on the server
/// Represents a long running job on the server. Model is read-only, updates attempt to cancel the job
/// </summary>
[Model]
public sealed class Job
@@ -37,5 +37,10 @@ namespace Tgstation.Server.Api.Models
/// If the <see cref="Job"/> has incremental progress, this will range from 1 - 100. 0 otherwise
/// </summary>
public int Progress { get; set; }
/// <summary>
/// If the current user has permission to cancel the job. Will be <see langword="null"/> if <see cref="StoppedAt"/> isn't
/// </summary>
public bool? UserCanCancel { get; set; }
}
}
@@ -6,7 +6,7 @@ using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Client.Components
{
/// <summary>
/// For managing server administration
/// For managing the chat bots
/// </summary>
public interface IChatClient : IRightsClient<ChatRights>
{
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Client.Components
/// Get the <see cref="Chat"/> represented by the <see cref="IChatClient"/>
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="Administration"/> represented by the <see cref="IChatClient"/></returns>
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="Chat"/> represented by the <see cref="IChatClient"/></returns>
Task<Chat> Read(CancellationToken cancellationToken);
/// <summary>
@@ -0,0 +1,35 @@
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Client.Components
{
/// <summary>
/// For managing the compiler
/// </summary>
public interface IDreamMakerClient : IRightsClient<DreamMakerRights>
{
/// <summary>
/// Get the <see cref="DreamMaker"/> represented by the <see cref="IDreamMakerClient"/>
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="DreamMaker"/> represented by the <see cref="IDreamMakerClient"/></returns>
Task<Chat> Read(CancellationToken cancellationToken);
/// <summary>
/// Updates the <see cref="DreamMaker"/> setttings
/// </summary>
/// <param name="dreamMaker">The <see cref="DreamMaker"/> 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 Update(DreamMaker dreamMaker, CancellationToken cancellationToken);
/// <summary>
/// Compile the current repository revision
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task"/> representing the running operation</returns>
Task Compile(CancellationToken cancellationToken);
}
}
@@ -29,16 +29,26 @@ namespace Tgstation.Server.Client.Components
/// </summary>
IConfigurationClient Configuration { get; }
/// <summary>
/// Access the <see cref="IInstanceUserClient"/>
/// </summary>
IInstanceUserClient Users { get; }
/// <summary>
/// Access the <see cref="IInstanceUserClient"/>
/// </summary>
IInstanceUserClient Users { get; }
/// <summary>
/// Get the <see cref="Instance"/> represented by the <see cref="IInstanceClient"/>
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="Instance"/> represented by the <see cref="IInstanceClient"/></returns>
Task<Instance> Read(CancellationToken cancellationToken);
/// <summary>
/// Access the <see cref="IChatClient"/>
/// </summary>
IChatClient Chat { get; }
/// <summary>
/// Access the <see cref="IDreamMakerClient"/>
/// </summary>
IDreamMakerClient DreamMaker { get; }
/// <summary>
/// Get the <see cref="Instance"/> represented by the <see cref="IInstanceClient"/>
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="Instance"/> represented by the <see cref="IInstanceClient"/></returns>
Task<Instance> Read(CancellationToken cancellationToken);
}
}
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
namespace Tgstation.Server.Client.Components
{
/// <summary>
/// Access to running jobs
/// </summary>
public interface IJobsClient
{
/// <summary>
/// List the active jobs the user 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 active <see cref="Job"/>s the user can view</returns>
Task<IReadOnlyList<Job>> List(CancellationToken cancellationToken);
/// <summary>
/// Cancels a <paramref name="job"/>
/// </summary>
/// <param name="job">The <see cref="Job"/> to cancel</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task"/> representing the running operation</returns>
Task Cancel(Job job, CancellationToken cancellationToken);
}
}
@@ -12,7 +12,7 @@ namespace Tgstation.Server.Client.Components
public interface ITokenClient: IRightsClient<TokenRights>
{
/// <summary>
/// Generate a new <see cref="Token"/> for the connected user, expiring the current one if applicable
/// Generate a new <see cref="Token"/> for the connected user/ipaddress, deleting the current one if applicable
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the new <see cref="Token"/></returns>
@@ -40,6 +40,16 @@ namespace Tgstation.Server.Client
/// </summary>
IInstanceManagerClient Instances { get; }
/// <summary>
/// Access the <see cref="IAdministrationClient"/>
/// </summary>
IAdministrationClient Administration { get; }
/// <summary>
/// These generally shouldn't be used in favor of the <see cref="Task"/> based polling and <see cref="CancellationToken"/>s other clients use. However, this is the only way to access jobs the client didn't start in it's current session
/// </summary>
IJobsClient Jobs { get; }
/// <summary>
/// The <see cref="System.Version"/> of the connected server
/// </summary>