tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ConfigurationClient.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Threading;
5using System.Threading.Tasks;
6
11
13{
16 {
21
28 : base(apiClient)
29 {
31 }
32
35
38
42 string directory,
43 CancellationToken cancellationToken)
47 instance.Id!.Value,
49
52 {
53 if (file == null)
56 Routes.ConfigurationFile + Routes.SanitizeGetPath(file.Path ?? throw new InvalidOperationException("file.Path should not be null!")),
57 instance.Id!.Value,
59 .ConfigureAwait(false);
61 try
62 {
63 return Tuple.Create(configFile, downloadStream);
64 }
65 catch
66 {
67 downloadStream.Dispose();
68 throw;
69 }
70 }
71
74 {
75 long initialStreamPosition = 0;
77 if (uploadStream?.CanSeek == false)
79 else if (uploadStream != null)
81
82 using (memoryStream)
83 {
87 instance.Id!.Value,
89
90 if (memoryStream != null)
91 await uploadStream!.CopyToAsync(memoryStream).ConfigureAwait(false);
92
93 var configFile = await configFileTask.ConfigureAwait(false);
94
98
99 return configFile;
100 }
101 }
102 }
103}
virtual ? long Id
The ID of the entity.
Definition EntityId.cs:13
Metadata about a server instance.
Definition Instance.cs:9
Represents a request to update a configuration file.
Routes to a server actions.
Definition Routes.cs:9
static string ListRoute(string route)
Get the /List postfix for a route .
static string SanitizeGetPath(string path)
Sanitize a Models.Response.FileTicketResponse path for use in a GET Uri.
Definition Routes.cs:140
const string Configuration
The configuration controller.
Definition Routes.cs:73
ValueTask< Stream > Download(FileTicketResponse ticket, CancellationToken cancellationToken)
Downloads a file Stream for a given ticket .A ValueTask<TResult> resulting in the downloaded Stream.
Definition ApiClient.cs:285
async ValueTask Upload(FileTicketResponse ticket, Stream? uploadStream, CancellationToken cancellationToken)
Uploads a given uploadStream for a given ticket .A ValueTask representing the running operation.
Definition ApiClient.cs:300
ValueTask Delete(string route, CancellationToken cancellationToken)
Run an HTTP DELETE request.A ValueTask representing the running operation.
ValueTask DeleteEmptyDirectory(IConfigurationFile directory, CancellationToken cancellationToken)
Delete an empty directory .A ValueTask representing the running operation.
async ValueTask< Tuple< ConfigurationFileResponse, Stream > > Read(IConfigurationFile file, CancellationToken cancellationToken)
Read a file .A ValueTask resulting in a Tuple<T1, T2> containing the ConfigurationFileResponse and do...
ValueTask< ConfigurationFileResponse > CreateDirectory(IConfigurationFile directory, CancellationToken cancellationToken)
Creates an empty directory .A ValueTask<TResult> resulting in the new ConfigurationFileResponse.
readonly Instance instance
The Instance for the ConfigurationClient.
async ValueTask< ConfigurationFileResponse > Write(ConfigurationFileRequest file, Stream uploadStream, CancellationToken cancellationToken)
Overwrite a file .A ValueTask<TResult> resulting in the new ConfigurationFileResponse.
ValueTask< List< ConfigurationFileResponse > > List(PaginationSettings? paginationSettings, string directory, CancellationToken cancellationToken)
List configuration files.A List<T> of ConfigurationFileResponses in the directory .
ConfigurationClient(IApiClient apiClient, Instance instance)
Initializes a new instance of the ConfigurationClient class.
Client that deals with getting paginated results.
Settings for a paginated request.
Represents a game configuration file. Create and delete actions uncerimonuously overwrite/delete file...
Web interface for the API.
Definition IApiClient.cs:17