2013-04-28 02:25:28 +02:00
|
|
|
|
using System.Collections.Generic;
|
2013-05-01 08:43:14 +02:00
|
|
|
|
using NzbDrone.Api.ClientSchema;
|
2013-04-28 02:25:28 +02:00
|
|
|
|
using NzbDrone.Core.Indexers;
|
2013-05-01 08:43:14 +02:00
|
|
|
|
using Omu.ValueInjecter;
|
2013-04-28 02:25:28 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Indexers
|
|
|
|
|
{
|
|
|
|
|
public class IndexerModule : NzbDroneRestModule<IndexerResource>
|
|
|
|
|
{
|
|
|
|
|
private readonly IIndexerService _indexerService;
|
|
|
|
|
|
|
|
|
|
public IndexerModule(IIndexerService indexerService)
|
|
|
|
|
{
|
|
|
|
|
_indexerService = indexerService;
|
|
|
|
|
GetResourceAll = GetAll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<IndexerResource> GetAll()
|
|
|
|
|
{
|
2013-05-01 08:43:14 +02:00
|
|
|
|
var indexers = _indexerService.All();
|
|
|
|
|
|
|
|
|
|
var result = new List<IndexerResource>(indexers.Count);
|
|
|
|
|
|
|
|
|
|
foreach (var indexerDefinition in indexers)
|
|
|
|
|
{
|
|
|
|
|
var resource = new IndexerResource();
|
|
|
|
|
resource.InjectFrom(indexerDefinition);
|
|
|
|
|
resource.Fields = SchemaBuilder.GenerateSchema(indexerDefinition.Settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2013-04-28 02:25:28 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|