2using System.Collections.Generic;
5using System.Threading.Tasks;
30 this.instance =
instance ??
throw new ArgumentNullException(nameof(
instance));
40 public ValueTask<List<ConfigurationFileResponse>>
List(
43 CancellationToken cancellationToken)
44 => ReadPaged<ConfigurationFileResponse>(
51 public async ValueTask<Tuple<ConfigurationFileResponse, Stream>>
Read(
IConfigurationFile file, CancellationToken cancellationToken)
54 throw new ArgumentNullException(nameof(file));
56 Routes.ConfigurationFile +
Routes.
SanitizeGetPath(file.
Path ??
throw new InvalidOperationException(
"file.Path should not be null!")),
59 .ConfigureAwait(
false);
60 var downloadStream = await
ApiClient.
Download(configFile, cancellationToken).ConfigureAwait(
false);
63 return Tuple.Create(configFile, downloadStream);
67 downloadStream.Dispose();
75 long initialStreamPosition = 0;
76 MemoryStream? memoryStream =
null;
77 if (uploadStream?.CanSeek ==
false)
78 memoryStream =
new MemoryStream();
79 else if (uploadStream !=
null)
80 initialStreamPosition = uploadStream.Position;
86 file ??
throw new ArgumentNullException(nameof(file)),
90 if (memoryStream !=
null)
91 await uploadStream!.CopyToAsync(memoryStream).ConfigureAwait(
false);
93 var configFile = await configFileTask.ConfigureAwait(
false);
95 var streamUsed = memoryStream ?? uploadStream;
96 streamUsed?.Seek(initialStreamPosition, SeekOrigin.Begin);
97 await
ApiClient.
Upload(configFile, streamUsed, cancellationToken).ConfigureAwait(
false);
virtual ? long Id
The ID of the entity.
Metadata about a server instance.
Represents a request to update a configuration file.
Response when reading configuration files.
Routes to a server actions.
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.
const string Configuration
The configuration controller.
ValueTask< Stream > Download(FileTicketResponse ticket, CancellationToken cancellationToken)
Downloads a file Stream for a given ticket . A ValueTask<TResult> resulting in the downloaded Stream.
async ValueTask Upload(FileTicketResponse ticket, Stream? uploadStream, CancellationToken cancellationToken)
Uploads a given uploadStream for a given ticket . A ValueTask representing the running operation.
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 d...
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.
Represents a game configuration file. Create and delete actions uncerimonuously overwrite/delete file...
string? Path
The path to the IConfigurationFile file.
For managing IConfigurationFiles.
Web interface for the API.