2using System.Collections.Generic;
4using System.Net.Http.Headers;
6using System.Threading.Tasks;
49 IEnumerable<IRequestLogger>? requestLoggers =
null,
50 TimeSpan? timeout =
null,
51 bool attemptLoginRefresh =
true,
52 CancellationToken cancellationToken =
default)
55 throw new ArgumentNullException(nameof(host));
57 throw new ArgumentNullException(nameof(username));
59 throw new ArgumentNullException(nameof(password));
76 IEnumerable<IRequestLogger>? requestLoggers =
null,
77 TimeSpan? timeout =
null,
78 CancellationToken cancellationToken =
default)
81 throw new ArgumentNullException(nameof(host));
82 if (oAuthCode ==
null)
83 throw new ArgumentNullException(nameof(oAuthCode));
99 throw new ArgumentNullException(nameof(host));
101 throw new ArgumentNullException(nameof(token));
103 throw new InvalidOperationException(
"token.Bearer should not be null!");
119 IEnumerable<IRequestLogger>? requestLoggers =
null,
120 TimeSpan? timeout =
null,
121 CancellationToken cancellationToken =
default)
134 if (requestLoggers !=
null)
135 foreach (var requestLogger
in requestLoggers)
138 if (timeout.HasValue)
139 api.Timeout = timeout.Value;
157 IEnumerable<IRequestLogger>? requestLoggers,
159 bool attemptLoginRefresh,
160 CancellationToken cancellationToken)
167 foreach (var requestLogger
in requestLoggers)
168 api.AddRequestLogger(requestLogger);
170 if (timeout.HasValue)
171 api.Timeout = timeout.Value;
180 attemptLoginRefresh ? loginHeaders :
null,
182 if (timeout.HasValue)
183 client.Timeout = timeout.Value;
185 foreach (var requestLogger
in requestLoggers)
186 client.AddRequestLogger(requestLogger);
Represents a JWT returned by the API.
string? Bearer
The value of the JWT.
Routes to a server actions.
const string ApiRoot
The root of API methods.
IApiClient CreateApiClient(Uri url, ApiHeaders apiHeaders, ApiHeaders? tokenRefreshHeaders, bool authless)
Create an IApiClient.A new IApiClient.
static RestServerClientFactory()
Initializes static members of the RestServerClientFactory class.
RestServerClientFactory(ProductHeaderValue productHeaderValue)
Initializes a new instance of the RestServerClientFactory class.
readonly ProductHeaderValue productHeaderValue
The ProductHeaderValue for the RestServerClientFactory.
async ValueTask< ServerInformationResponse > GetServerInformation(Uri host, IEnumerable< IRequestLogger >? requestLoggers=null, TimeSpan? timeout=null, CancellationToken cancellationToken=default)
Gets the ServerInformationResponse for a given host .A ValueTask<TResult> resulting in the ServerInfo...
IRestServerClient CreateFromToken(Uri host, TokenResponse token)
Create a IRestServerClient.A new IRestServerClient.
async ValueTask< IRestServerClient > CreateWithNewToken(Uri host, ApiHeaders loginHeaders, IEnumerable< IRequestLogger >? requestLoggers, TimeSpan? timeout, bool attemptLoginRefresh, CancellationToken cancellationToken)
Creates a IRestServerClient from a login operation.
ValueTask< IRestServerClient > CreateFromLogin(Uri host, string username, string password, IEnumerable< IRequestLogger >? requestLoggers=null, TimeSpan? timeout=null, bool attemptLoginRefresh=true, CancellationToken cancellationToken=default)
Create a IRestServerClient using a password login.A ValueTask<TResult> resulting in a new IRestServer...
ValueTask< IRestServerClient > CreateFromOAuth(Uri host, string oAuthCode, OAuthProvider oAuthProvider, IEnumerable< IRequestLogger >? requestLoggers=null, TimeSpan? timeout=null, CancellationToken cancellationToken=default)
Create a IRestServerClient using an OAuth login.A ValueTask<TResult> resulting in a new IRestServerCl...
For creating IApiClients.
void AddRequestLogger(IRequestLogger requestLogger)
Adds a requestLogger to the request pipeline.
For logging HTTP requests and responses.
Factory for creating IRestServerClients.
Main client for communicating with a server.
OAuthProvider
List of OAuth providers supported by TGS.