Added the tags API into Ombi. Just need to figure out the rest

pull/3895/head
Jamie Rees 6 years ago
parent 93722bb546
commit 9413c7bb48

@ -14,5 +14,6 @@ namespace Ombi.Api.Radarr
Task<MovieResponse> UpdateMovie(MovieResponse movie, string apiKey, string baseUrl);
Task<bool> MovieSearch(int[] movieIds, string apiKey, string baseUrl);
Task<RadarrAddMovieResponse> AddMovie(int tmdbId, string title, int year, int qualityId, string rootPath,string apiKey, string baseUrl, bool searchNow, string minimumAvailability);
Task<List<Tag>> GetTags(string apiKey, string baseUrl);
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Radarr.Models
{
public class Tag
{
public int id { get; set; }
public string label { get; set; }
}
}

@ -123,6 +123,14 @@ namespace Ombi.Api.Radarr
{
var result = await Command(apiKey, baseUrl, new { name = "MoviesSearch", movieIds });
return result != null;
}
public async Task<List<Tag>> GetTags(string apiKey, string baseUrl)
{
var request = new Request("/api/tag", baseUrl, HttpMethod.Get);
AddHeaders(request, apiKey);
return await Api.Request<List<Tag>>(request);
}
private async Task<CommandResult> Command(string apiKey, string baseUrl, object body)

@ -21,5 +21,6 @@ namespace Ombi.Api.Sonarr
Task<bool> SeriesSearch(int seriesId, string apiKey, string baseUrl);
Task<SystemStatus> SystemStatus(string apiKey, string baseUrl);
Task<bool> SeasonPass(string apiKey, string baseUrl, SonarrSeries series);
Task<List<Tag>> GetTags(string apiKey, string baseUrl);
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Sonarr.Models
{
public class Tag
{
public int id { get; set; }
public string label { get; set; }
}
}

@ -225,5 +225,13 @@ namespace Ombi.Api.Sonarr
var content = await Api.RequestContent(request);
return content.Equals("ok", StringComparison.CurrentCultureIgnoreCase);
}
public async Task<List<Tag>> GetTags(string apiKey, string baseUrl)
{
var request = new Request($"{ApiBaseUrl}tag", baseUrl, HttpMethod.Get);
request.AddHeader("X-Api-Key", apiKey);
return await Api.Request<List<Tag>>(request);
}
}
}

@ -93,5 +93,36 @@ namespace Ombi.Controllers.V1.External
}
return null;
}
/// <summary>
/// Gets the Radarr tags
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("tags")]
[PowerUser]
public async Task<IEnumerable<Tag>> GetTags([FromBody] SonarrSettings settings)
{
return await RadarrApi.GetTags(settings.ApiKey, settings.FullUri);
}
/// <summary>
/// Gets the Radarr tags
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("tags")]
[PowerUser]
public async Task<IEnumerable<Tag>> GetTags()
{
var settings = await RadarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
return await RadarrApi.GetTags(settings.ApiKey, settings.FullUri);
}
return null;
}
}
}

@ -101,6 +101,36 @@ namespace Ombi.Controllers.V1.External
return null;
}
/// <summary>
/// Gets the Sonarr tags
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("tags")]
[PowerUser]
public async Task<IEnumerable<Tag>> GetTags([FromBody] SonarrSettings settings)
{
return await SonarrApi.GetTags(settings.ApiKey, settings.FullUri);
}
/// <summary>
/// Gets the Sonarr tags
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("tags")]
[PowerUser]
public async Task<IEnumerable<Tag>> GetTags()
{
var settings = await SonarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
return await SonarrApi.GetTags(settings.ApiKey, settings.FullUri);
}
return null;
}
/// <summary>
/// Gets the Sonarr V3 language profiles

Loading…
Cancel
Save