1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-31 20:03:06 +00:00
Radarr/NzbDrone.Api/Indexers/IndexerSchemaModule.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2013-05-28 00:19:07 +00:00
using System.Collections.Generic;
2013-09-23 00:27:00 +00:00
using System.Linq;
2013-05-28 00:19:07 +00:00
using NzbDrone.Api.ClientSchema;
using NzbDrone.Core.Indexers;
using Omu.ValueInjecter;
namespace NzbDrone.Api.Indexers
{
public class IndexerSchemaModule : NzbDroneRestModule<IndexerResource>
{
2013-09-24 23:42:55 +00:00
private readonly IIndexerFactory _indexerFactory;
2013-05-28 00:19:07 +00:00
2013-09-24 23:42:55 +00:00
public IndexerSchemaModule(IIndexerFactory indexerFactory)
2013-05-28 00:19:07 +00:00
: base("indexer/schema")
{
2013-09-24 23:42:55 +00:00
_indexerFactory = indexerFactory;
2013-05-28 00:19:07 +00:00
GetResourceAll = GetSchema;
}
private List<IndexerResource> GetSchema()
{
2013-09-22 23:40:36 +00:00
2013-09-24 23:42:55 +00:00
var indexers = _indexerFactory.Templates().Where(c => c.Implementation =="Newznab");
2013-09-22 23:40:36 +00:00
2013-05-28 00:19:07 +00:00
2013-09-23 00:27:00 +00:00
var result = new List<IndexerResource>(indexers.Count());
2013-05-28 00:19:07 +00:00
2013-09-23 00:27:00 +00:00
foreach (var indexer in indexers)
{
var indexerResource = new IndexerResource();
indexerResource.InjectFrom(indexer);
indexerResource.Fields = SchemaBuilder.ToSchema(indexer.Settings);
2013-05-28 00:19:07 +00:00
2013-09-23 00:27:00 +00:00
result.Add(indexerResource);
}
2013-05-28 00:19:07 +00:00
2013-09-23 00:27:00 +00:00
return result;
2013-05-28 00:19:07 +00:00
}
}
}