tgstation-server 6.12.3
The /tg/station 13 server suite
Loading...
Searching...
No Matches
EngineClient.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 {
30 this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
31 }
32
34 public ValueTask<EngineResponse> ActiveVersion(CancellationToken cancellationToken) => ApiClient.Read<EngineResponse>(Routes.Engine, instance.Id!.Value, cancellationToken);
35
37 public ValueTask<JobResponse> DeleteVersion(EngineVersionDeleteRequest deleteRequest, CancellationToken cancellationToken)
38 => ApiClient.Delete<EngineVersionDeleteRequest, JobResponse>(Routes.Engine, deleteRequest, instance.Id!.Value, cancellationToken);
39
41 public ValueTask<List<EngineResponse>> InstalledVersions(PaginationSettings? paginationSettings, CancellationToken cancellationToken)
42 => ReadPaged<EngineResponse>(paginationSettings, Routes.ListRoute(Routes.Engine), instance.Id, cancellationToken);
43
45 public async ValueTask<EngineInstallResponse> SetActiveVersion(EngineVersionRequest installRequest, Stream? zipFileStream, CancellationToken cancellationToken)
46 {
47 if (installRequest == null)
48 throw new ArgumentNullException(nameof(installRequest));
49 if (installRequest.UploadCustomZip == true && zipFileStream == null)
50 throw new ArgumentNullException(nameof(zipFileStream));
51
52 var result = await ApiClient.Update<EngineVersionRequest, EngineInstallResponse>(
54 installRequest,
55 instance.Id!.Value,
56 cancellationToken)
57 .ConfigureAwait(false);
58
59 if (installRequest.UploadCustomZip == true)
60 await ApiClient.Upload(result, zipFileStream, cancellationToken).ConfigureAwait(false);
61
62 return result;
63 }
64 }
65}
virtual ? long Id
The ID of the entity.
Definition EntityId.cs:13
Metadata about a server instance.
Definition Instance.cs:9
A request to switch to a given EngineVersion.
bool? UploadCustomZip
If a custom BYOND version is to be uploaded.
Represents an engine installation job. FileTicketResponse.FileTicket is used to upload custom version...
Represents an installed Models.EngineVersion.
Represents a long running job on the server. Model is read-only, updates attempt to cancel the job.
Definition JobResponse.cs:7
Routes to a server actions.
Definition Routes.cs:9
static string ListRoute(string route)
Get the /List postfix for a route .
const string Engine
The engine controller.
Definition Routes.cs:53
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.
readonly Instance instance
The Instance for the EngineClient.
async ValueTask< EngineInstallResponse > SetActiveVersion(EngineVersionRequest installRequest, Stream? zipFileStream, CancellationToken cancellationToken)
Updates the active engine version.A ValueTask<TResult> resulting in the EngineInstallResponse.
ValueTask< EngineResponse > ActiveVersion(CancellationToken cancellationToken)
Get the EngineInstallResponse active Api.Models.EngineVersion.A ValueTask<TResult> resulting in the E...
EngineClient(IApiClient apiClient, Instance instance)
Initializes a new instance of the EngineClient class.
ValueTask< List< EngineResponse > > InstalledVersions(PaginationSettings? paginationSettings, CancellationToken cancellationToken)
Get all installed EngineInstallResponse System.Versions.A ValueTask<TResult> resulting in an List<T> ...
ValueTask< JobResponse > DeleteVersion(EngineVersionDeleteRequest deleteRequest, CancellationToken cancellationToken)
Starts a job to delete a specific engine version.A ValueTask<TResult> resulting in the JobResponse fo...
Client that deals with getting paginated results.
Settings for a paginated request.
For managing the engine installations.
Web interface for the API.
Definition IApiClient.cs:17