mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
IConfigurationClient
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Api.Models
|
||||
#pragma warning restore CA1819 // Properties should not return arrays
|
||||
|
||||
/// <summary>
|
||||
/// The MD5 hash of the file when last read by the user. Will be <see langword="null"/> if <see cref="ReadDenied"/> is <see langword="true"/>. If this doesn't match during update actions, the write will be denied
|
||||
/// The MD5 hash of the file when last read by the user. Will be <see langword="null"/> if <see cref="ReadDenied"/> is <see langword="true"/>. If this doesn't match during update actions, the write will be denied with error code 409
|
||||
/// </summary>
|
||||
public string LastReadHash { get; set; }
|
||||
}
|
||||
|
||||
@@ -121,6 +121,19 @@ namespace Tgstation.Server.Api
|
||||
/// <returns>A <see cref="Route"/> to the read action</returns>
|
||||
public static Route ReadFile(Instance instance, string path) => new Route { Path = String.Concat("/Configuration/", instance?.Id ?? throw new ArgumentNullException(nameof(instance)), '/', path?.TrimStart('/') ?? throw new ArgumentNullException(nameof(path))), Method = HttpMethod.Get };
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="Route"/> to list <see cref="Configuration"/> files for a <paramref name="directory"/>
|
||||
/// </summary>
|
||||
/// <param name="instance">The <see cref="Instance"/> the <see cref="Configuration"/> file resides in</param>
|
||||
/// <param name="directory">The <see cref="Configuration"/> directory to list</param>
|
||||
/// <returns>A <see cref="Route"/> to the read action</returns>
|
||||
public static Route ListFiles(Instance instance, string directory)
|
||||
{
|
||||
var result = ReadFile(instance, directory);
|
||||
result.Path = String.Concat("/ConfigurationList", result.Path.Substring(result.Path.IndexOf('/', 1)));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="Route"/> to create a <see cref="Configuration"/> file
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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 <see cref="Configuration"/> files
|
||||
/// </summary>
|
||||
public interface IConfigurationClient : IRightsClient<ConfigurationRights>
|
||||
{
|
||||
/// <summary>
|
||||
/// List configuration files
|
||||
/// </summary>
|
||||
/// <param name="directory">The path to the directory to list files in</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="IReadOnlyList{T}"/> of <see cref="Configuration"/>s in the <paramref name="directory"/></returns>
|
||||
Task<IReadOnlyList<Configuration>> List(string directory, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Read a <see cref="Configuration"/> file
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="Configuration"/> file to read</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Read(Configuration file, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Overwrite a <see cref="Configuration"/> file with integrity checks
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="Configuration"/> file to write</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Write(Configuration file, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Create/overwrite a <see cref="Configuration"/> file
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="Configuration"/> file to write</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Create(Configuration file, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a <see cref="Configuration"/> file
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="Configuration"/> file 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 Delete(Configuration file, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,11 @@ namespace Tgstation.Server.Client.Components
|
||||
/// </summary>
|
||||
IDreamDaemonClient DreamDaemon { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="IConfigurationClient"/>
|
||||
/// </summary>
|
||||
IConfigurationClient Configuration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="IInstanceUserClient"/>
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user