tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ServerSwarm.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5using HotChocolate;
6using HotChocolate.Authorization;
7
8using Microsoft.Extensions.Options;
9
15
17{
21 public sealed class ServerSwarm
22 {
27 [Authorize]
29 => throw new ErrorMessageException(ErrorCode.RemoteGatewaysNotImplemented);
30
35 [Authorize]
38
43 [Authorize]
44 public UsersRepository Users() => new();
45
50 [Authorize]
52
60 [Service] IOptionsSnapshot<SwarmConfiguration> swarmConfigurationOptions,
61 [Service] ISwarmService swarmService)
62 {
63 ArgumentNullException.ThrowIfNull(swarmConfigurationOptions);
64 ArgumentNullException.ThrowIfNull(swarmService);
65
66 if (swarmConfigurationOptions.Value.PrivateKey == null)
67 return new StandaloneNode();
68
70 swarmConfigurationOptions.Value.Identifier!,
71 swarmService)) ?? new StandaloneNode();
72 }
73
79 [Authorize]
80 public List<SwarmNode>? Nodes(
81 [Service] ISwarmService swarmService)
82 {
83 ArgumentNullException.ThrowIfNull(swarmService);
84 return swarmService.GetSwarmServers()?.Select(x => new SwarmNode(x)).ToList();
85 }
86
91 [Authorize]
93 }
94}
Exception representing ErrorMessageResponses.
Represents a tgstation-server swarm.
List< SwarmNode >? Nodes([Service] ISwarmService swarmService)
Gets all SwarmNode servers in the swarm.
UpdateInformation UpdateInformation()
Gets the Types.UpdateInformation for the swarm.
UsersRepository Users()
Gets the swarm's UsersRepository.
UserGroupsRepository UserGroups()
Gets the swarm's UserGroupsRepository.
IServerNode CurrentNode([Service] IOptionsSnapshot< SwarmConfiguration > swarmConfigurationOptions, [Service] ISwarmService swarmService)
Gets the connected SwarmNode server.
int ProtocolMajorVersion()
Gets the swarm protocol major version in use.
IQueryable< Instance > Instances()
Access all instances in the ServerSwarm.
A IServerNode not running as part of a larger ServerSwarm.
Represents a node server in a swarm.
Definition SwarmNode.cs:23
static ? SwarmNode GetSwarmNode(string identifier, [Service] ISwarmService swarmService)
Node resolver for SwarmNodes.
Definition SwarmNode.cs:57
Gets information about updates for the ServerSwarm.
Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies ...
string RawSwarmProtocolVersion
The Version string of the TGS swarm protocol.
static MasterVersionsAttribute Instance
Return the Assembly's instance of the MasterVersionsAttribute.
Represents a tgstation-server installation.
Used for swarm operations. Functions may be no-op based on configuration.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
Definition ErrorCode.cs:12