mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
ConfigurationClient
This commit is contained in:
@@ -43,6 +43,11 @@ namespace Tgstation.Server.Api
|
||||
/// </summary>
|
||||
public const string DreamDaemon = Root + nameof(Models.DreamDaemon);
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Models.ConfigurationFile"/> controller
|
||||
/// </summary>
|
||||
public const string Configuration = Root + "Config";
|
||||
|
||||
/// <summary>
|
||||
/// Apply an <paramref name="id"/> postfix to a <paramref name="route"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
@@ -21,11 +22,11 @@ namespace Tgstation.Server.Client.Components
|
||||
/// Construct a <see cref="ByondClient"/>
|
||||
/// </summary>
|
||||
/// <param name="apiClient">The value of <see cref="apiClient"/></param>
|
||||
/// <param name="instance"></param>
|
||||
/// <param name="instance">The value of <see cref="Instance"/></param>
|
||||
public ByondClient(IApiClient apiClient, Instance instance)
|
||||
{
|
||||
this.apiClient = apiClient;
|
||||
this.instance = instance;
|
||||
this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class ConfigurationClient : IConfigurationClient
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IApiClient"/> for the <see cref="ConfigurationClient"/>
|
||||
/// </summary>
|
||||
readonly IApiClient apiClient;
|
||||
/// <summary>
|
||||
/// The <see cref="Instance"/> for the <see cref="ConfigurationClient"/>
|
||||
/// </summary>
|
||||
readonly Instance instance;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="ConfigurationClient"/>
|
||||
/// </summary>
|
||||
/// <param name="apiClient">The value of <see cref="apiClient"/></param>
|
||||
/// <param name="instance">The value of <see cref="instance"/></param>
|
||||
public ConfigurationClient(IApiClient apiClient, Instance instance)
|
||||
{
|
||||
this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<IReadOnlyList<ConfigurationFile>> List(string directory, CancellationToken cancellationToken)
|
||||
{
|
||||
if (directory == null)
|
||||
directory = String.Empty;
|
||||
return apiClient.Read<IReadOnlyList<ConfigurationFile>>(Routes.List(Routes.Configuration) + directory, instance.Id, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<ConfigurationFile> Read(ConfigurationFile file, CancellationToken cancellationToken)
|
||||
{
|
||||
if (file == null)
|
||||
throw new ArgumentNullException(nameof(file));
|
||||
return apiClient.Read<ConfigurationFile>(Routes.Configuration + file.Path, instance.Id, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<ConfigurationFile> Write(ConfigurationFile file, CancellationToken cancellationToken) => apiClient.Update<ConfigurationFile, ConfigurationFile>(Routes.Configuration, file, instance.Id, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
@@ -21,11 +22,11 @@ namespace Tgstation.Server.Client.Components
|
||||
/// Construct a <see cref="DreamDaemonClient"/>
|
||||
/// </summary>
|
||||
/// <param name="apiClient">The value of <see cref="apiClient"/></param>
|
||||
/// <param name="instance"></param>
|
||||
/// <param name="instance">The value of <see cref="instance"/></param>
|
||||
public DreamDaemonClient(IApiClient apiClient, Instance instance)
|
||||
{
|
||||
this.apiClient = apiClient;
|
||||
this.instance = instance;
|
||||
this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Tgstation.Server.Client.Components
|
||||
public IDreamDaemonClient DreamDaemon { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IConfigurationClient Configuration => throw new NotImplementedException();
|
||||
public IConfigurationClient Configuration { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IInstanceUserClient Users => throw new NotImplementedException();
|
||||
@@ -51,6 +51,7 @@ namespace Tgstation.Server.Client.Components
|
||||
Byond = new ByondClient(apiClient, instance);
|
||||
Repository = new RepositoryClient(apiClient, instance);
|
||||
DreamDaemon = new DreamDaemonClient(apiClient, instance);
|
||||
Configuration = new ConfigurationClient(apiClient, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
using Tgstation.Server.Host.Components;
|
||||
@@ -15,7 +16,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// <summary>
|
||||
/// The <see cref="ModelController{TModel}"/> for <see cref="ConfigurationFile"/>s
|
||||
/// </summary>
|
||||
[Route("/" + nameof(Configuration))]
|
||||
[Route(Routes.Configuration)]
|
||||
public sealed class ConfigurationController : ModelController<ConfigurationFile>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user