tgstation-server
The /tg/station 13 server suite
ByondClient.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Threading;
4 using System.Threading.Tasks;
5 using Tgstation.Server.Api;
7 
9 {
11  sealed class ByondClient : IByondClient
12  {
17 
21  readonly Instance instance;
22 
29  {
30  this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
31  this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
32  }
33 
35  public Task<Byond> ActiveVersion(CancellationToken cancellationToken) => apiClient.Read<Byond>(Routes.Byond, instance.Id, cancellationToken);
36 
38  public Task<IReadOnlyList<Byond>> InstalledVersions(CancellationToken cancellationToken) => apiClient.Read<IReadOnlyList<Byond>>(Routes.ListRoute(Routes.Byond), instance.Id, cancellationToken);
39 
41  public Task<Byond> SetActiveVersion(Byond byond, CancellationToken cancellationToken) => apiClient.Update<Byond, Byond>(Routes.Byond, byond ?? throw new ArgumentNullException(nameof(byond)), instance.Id, cancellationToken);
42  }
43 }
const string Byond
The Models.Byond controller
Definition: Routes.cs:34
Task< Byond > Byond(Routes.Byond, byond ?? throw new ArgumentNullException(nameof(byond)), instance.Id, cancellationToken)
Task< Byond > SetActiveVersion(Byond byond, CancellationToken cancellationToken)
Updates the Byond information
For managing the Byond installation
Definition: IByondClient.cs:11
ByondClient(IApiClient apiClient, Instance instance)
Construct a ByondClient
Definition: ByondClient.cs:28
static string ListRoute(string route)
Get the /List postfix for a route
readonly IApiClient apiClient
The IApiClient for the ByondClient
Definition: ByondClient.cs:16
Routes to a server actions
Definition: Routes.cs:9
readonly Instance instance
The Instance for the ByondClient
Definition: ByondClient.cs:21
long Id
The id of the Instance. Not modifiable
Definition: Instance.cs:14
Task< IReadOnlyList< Byond > > InstalledVersions(CancellationToken cancellationToken)
Get all installed Byond System.Versions
Metadata about a server instance
Definition: Instance.cs:9
Represents a BYOND installation
Definition: Byond.cs:8
Web interface for the API
Definition: IApiClient.cs:11
Task< Byond > ActiveVersion(CancellationToken cancellationToken)
Get the Byond active System.Version information