static async Task CheckSuccessStatusCode(HttpClient client, RemoteInstanceSetting remoteSettings, TimeSpan queryTimeout, CancellationToken token) { try { var response = await client.GetAsync(remoteSettings.ApiUri, token).ConfigureAwait(false); response.EnsureSuccessStatusCode(); } catch (HttpRequestException e) { throw new TimeoutException($"Remote at '{remoteSettings.ApiUri}' doesn't seem to be available. Reason: {e.Message}", e); } catch (OperationCanceledException e) { throw new TimeoutException($"Remote at '{remoteSettings.ApiUri}' did not respond within the allotted timespan of '{queryTimeout}'.", e); } }
public static PsServiceControlRemote FromRemote(RemoteInstanceSetting remoteInstance) => new PsServiceControlRemote { ApiUrl = remoteInstance.ApiUri };