Example #1
0
        private static string GetBaseURL(OmbiSettings settings)
        {
            var protocol = settings.UseSSL ? "https" : "http";

            return($"{protocol}://{settings.Hostname}:{settings.Port}");
        }
Example #2
0
        private static async Task <HttpResponseMessage> HttpGetAsync(HttpClient client, OmbiSettings settings, string url)
        {
            var request = new HttpRequestMessage(HttpMethod.Get, url);

            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("ApiKey", settings.ApiKey);

            return(await client.SendAsync(request));
        }
Example #3
0
        public static async Task TestConnectionAsync(HttpClient httpClient, ILogger <Ombi> logger, OmbiSettings settings)
        {
            var testSuccessful = false;

            try
            {
                var response = await HttpGetAsync(httpClient, settings, $"{GetBaseURL(settings)}/api/v1/LandingPage");

                testSuccessful = response.IsSuccessStatusCode;
            }
            catch (System.Exception ex)
            {
                logger.LogWarning("Error while testing ombi connection: " + ex.Message);
                throw new Exception("Could not connect to Radarr");
            }

            if (!testSuccessful)
            {
                throw new Exception("Could not connect to Radarr");
            }
        }