mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Started the Radarr Settings #865
This commit is contained in:
parent
521f7c3ea0
commit
7595ccf6c4
34 changed files with 637 additions and 33 deletions
63
src/Ombi.Api.Radarr/RadarrApi.cs
Normal file
63
src/Ombi.Api.Radarr/RadarrApi.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Radarr.Models;
|
||||
|
||||
namespace Ombi.Api.Radarr
|
||||
{
|
||||
public class RadarrApi : IRadarrApi
|
||||
{
|
||||
public RadarrApi(ILogger<RadarrApi> logger)
|
||||
{
|
||||
Api = new Api();
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
private Api Api { get; }
|
||||
private ILogger<RadarrApi> Logger { get; }
|
||||
|
||||
public async Task<List<RadarrProfile>> GetProfiles(string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new Request(baseUrl.ToString(), "/api/profile", HttpMethod.Get);
|
||||
|
||||
AddHeaders(request, apiKey);
|
||||
return await Api.Request<List<RadarrProfile>>(request);
|
||||
}
|
||||
|
||||
public async Task<List<RadarrRootFolder>> GetRootFolders(string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new Request(baseUrl.ToString(), "/api/rootfolder", HttpMethod.Get);
|
||||
|
||||
AddHeaders(request, apiKey);
|
||||
return await Api.Request<List<RadarrRootFolder>>(request);
|
||||
}
|
||||
|
||||
public async Task<SystemStatus> SystemStatus(string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new Request(baseUrl.ToString(), "/api/system/status", HttpMethod.Get);
|
||||
AddHeaders(request, apiKey);
|
||||
|
||||
return await Api.Request<SystemStatus>(request);
|
||||
}
|
||||
|
||||
public async Task<List<MovieResponse>> GetMovies(string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new Request(baseUrl.ToString(), "/api/movie", HttpMethod.Get);
|
||||
AddHeaders(request, apiKey);
|
||||
|
||||
return await Api.Request<List<MovieResponse>>(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the required headers and also the authorization header
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="key"></param>
|
||||
private void AddHeaders(Request request, string key)
|
||||
{
|
||||
request.AddHeader("X-Api-Key", key);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue