public async Task <IActionResult> TestSonarrSettings([FromBody] TestSonarrSettingsModel model) { try { await Sonarr.TestConnectionAsync(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model)); return(Ok(new { ok = true })); } catch (System.Exception) { return(BadRequest($"The specified settings are invalid")); } }
public async Task <IActionResult> GetSonarrTags([FromBody] TestSonarrSettingsModel model) { try { var tags = await Sonarr.GetTags(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model)); return(Ok(tags.Select(x => new SonarrTag { Id = x.id, Name = x.label }))); } catch (System.Exception) { return(BadRequest($"Could not load the tags from Sonarr, check your settings.")); } }
public async Task <IActionResult> GetSonarrRootPaths([FromBody] TestSonarrSettingsModel model) { try { var paths = await Sonarr.GetRootPaths(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model)); return(Ok(paths.Select(x => new SonarrPath { Id = x.id, Path = x.path }))); } catch (System.Exception) { return(BadRequest($"Could not load the paths from Sonarr, check your settings.")); } }
private static Requestrr.DownloadClients.Sonarr.SonarrSettings ConvertToSonarrSettings(TestSonarrSettingsModel model) { return(new Requestrr.DownloadClients.Sonarr.SonarrSettings { ApiKey = model.ApiKey.Trim(), Hostname = model.Hostname.Trim(), Port = model.Port, UseSSL = model.UseSSL, Version = model.Version }); }