tgstation-server 6.12.3
The /tg/station 13 server suite
Loading...
Searching...
No Matches
RestServerClient.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4
5using Microsoft.AspNetCore.SignalR.Client;
6using Microsoft.Extensions.Logging;
7
11
13{
16 {
18 public Uri Url => apiClient.Url;
19
22 {
23 get => apiClient.Headers.Token ?? throw new InvalidOperationException("apiClient.Headers.Token was null!");
24 set => apiClient.Headers = new ApiHeaders(apiClient.Headers.UserAgent!, value);
25 }
26
28 public TimeSpan Timeout
29 {
30 get => apiClient.Timeout;
31 set => apiClient.Timeout = value;
32 }
33
36
39
41 public IUsersClient Users { get; }
42
44 public IUserGroupsClient Groups { get; }
45
48
53
59 {
60 this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
61
66 }
67
69 public ValueTask DisposeAsync() => apiClient.DisposeAsync();
70
72 public ValueTask<ServerInformationResponse> ServerInformation(CancellationToken cancellationToken) => apiClient.Read<ServerInformationResponse>(Routes.ApiRoot, cancellationToken);
73
75 public void AddRequestLogger(IRequestLogger requestLogger) => apiClient.AddRequestLogger(requestLogger);
76
78 public ValueTask<IAsyncDisposable> SubscribeToJobUpdates(
79 IJobsHub jobsReceiver,
80 IRetryPolicy? retryPolicy,
81 Action<ILoggingBuilder>? loggingConfigureAction,
82 CancellationToken cancellationToken)
83 => apiClient.CreateHubConnection(jobsReceiver, retryPolicy, loggingConfigureAction, cancellationToken);
84 }
85}
Represents the header that must be present for every server request.
Definition ApiHeaders.cs:25
ProductHeaderValue? UserAgent
The client's user agent as a ProductHeaderValue if valid.
Definition ApiHeaders.cs:89
Represents a JWT returned by the API.
Routes to a server actions.
Definition Routes.cs:9
const string ApiRoot
The root of API methods.
Definition Routes.cs:13
IUsersClient Users
Access the IUsersClient.
Uri Url
The connected server's root Uri.
TimeSpan Timeout
The connection timeout.
IAdministrationClient Administration
Access the IAdministrationClient.
IInstanceManagerClient Instances
Access the IInstanceManagerClient.
readonly IApiClient apiClient
The IApiClient for the RestServerClient.
ValueTask< IAsyncDisposable > SubscribeToJobUpdates(IJobsHub jobsReceiver, IRetryPolicy? retryPolicy, Action< ILoggingBuilder >? loggingConfigureAction, CancellationToken cancellationToken)
Subscribe to all job updates available to the IRestServerClient.An IAsyncDisposable representing the ...
void AddRequestLogger(IRequestLogger requestLogger)
Adds a requestLogger to the request pipeline.
TokenResponse Token
The Token used to access the server.
ValueTask< ServerInformationResponse > ServerInformation(CancellationToken cancellationToken)
The ServerInformationResponse of the IRestServerClient.A Task<TResult> resulting in the ServerInforma...
IUserGroupsClient Groups
Access the IUserGroupsClient.
ITransferClient Transfer
Access the ITransferClient.Most client methods handle transfers in their invocations....
RestServerClient(IApiClient apiClient)
Initializes a new instance of the RestServerClient class.
SignalR client methods for receiving JobResponses.
Definition IJobsHub.cs:12
Web interface for the API.
Definition IApiClient.cs:17
Uri Url
The Uri pointing the tgstation-server.
Definition IApiClient.cs:26
void AddRequestLogger(IRequestLogger requestLogger)
Adds a requestLogger to the request pipeline.
TimeSpan Timeout
The request timeout.
Definition IApiClient.cs:31
ApiHeaders Headers
The ApiHeaders the IApiClient uses.
Definition IApiClient.cs:21
For logging HTTP requests and responses.
Main client for communicating with a server.
For transferring data Streams.
For managing UserGroupResponses.
For managing UserResponses.