mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-25 22:37:27 -04:00
New: v4 API (DROP v3 AFTER TESTING PERIOD)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using NzbDrone.Core.Download;
|
||||
using Radarr.Http;
|
||||
|
||||
namespace Radarr.Api.V4.DownloadClient
|
||||
{
|
||||
[V4ApiController]
|
||||
public class DownloadClientController : ProviderControllerBase<DownloadClientResource, IDownloadClient, DownloadClientDefinition>
|
||||
{
|
||||
public static readonly DownloadClientResourceMapper ResourceMapper = new DownloadClientResourceMapper();
|
||||
|
||||
public DownloadClientController(IDownloadClientFactory downloadClientFactory)
|
||||
: base(downloadClientFactory, "downloadclient", ResourceMapper)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
|
||||
namespace Radarr.Api.V4.DownloadClient
|
||||
{
|
||||
public class DownloadClientResource : ProviderResource<DownloadClientResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
public DownloadProtocol Protocol { get; set; }
|
||||
public int Priority { get; set; }
|
||||
public bool RemoveCompletedDownloads { get; set; }
|
||||
public bool RemoveFailedDownloads { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadClientResourceMapper : ProviderResourceMapper<DownloadClientResource, DownloadClientDefinition>
|
||||
{
|
||||
public override DownloadClientResource ToResource(DownloadClientDefinition definition)
|
||||
{
|
||||
if (definition == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var resource = base.ToResource(definition);
|
||||
|
||||
resource.Enable = definition.Enable;
|
||||
resource.Protocol = definition.Protocol;
|
||||
resource.Priority = definition.Priority;
|
||||
resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads;
|
||||
resource.RemoveFailedDownloads = definition.RemoveFailedDownloads;
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
public override DownloadClientDefinition ToModel(DownloadClientResource resource)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var definition = base.ToModel(resource);
|
||||
|
||||
definition.Enable = resource.Enable;
|
||||
definition.Protocol = resource.Protocol;
|
||||
definition.Priority = resource.Priority;
|
||||
definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads;
|
||||
definition.RemoveFailedDownloads = resource.RemoveFailedDownloads;
|
||||
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user