mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 09:03:49 -07:00
New: Add Test all functionality to API (Clients/Indexers/Lists)
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
1d1aca8fb7
commit
4347e92bef
3 changed files with 41 additions and 0 deletions
|
@ -28,6 +28,7 @@ namespace Lidarr.Api.V1
|
|||
|
||||
Get["schema"] = x => GetTemplates();
|
||||
Post["test"] = x => Test(ReadResourceFromRequest(true));
|
||||
Post["testall"] = x => TestAll();
|
||||
Post["action/{action}"] = x => RequestAction(x.action, ReadResourceFromRequest(true));
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
|
@ -144,6 +145,27 @@ namespace Lidarr.Api.V1
|
|||
return "{}";
|
||||
}
|
||||
|
||||
private Response TestAll()
|
||||
{
|
||||
var providerDefinitions = _providerFactory.All()
|
||||
.Where(c => c.Settings.Validate().IsValid && c.Enable)
|
||||
.ToList();
|
||||
var result = new List<ProviderTestAllResult>();
|
||||
|
||||
foreach (var definition in providerDefinitions)
|
||||
{
|
||||
var validationResult = _providerFactory.Test(definition);
|
||||
|
||||
result.Add(new ProviderTestAllResult
|
||||
{
|
||||
Id = definition.Id,
|
||||
ValidationFailures = validationResult.Errors.ToList()
|
||||
});
|
||||
}
|
||||
|
||||
return result.AsResponse(result.Any(c => !c.IsValid) ? HttpStatusCode.BadRequest : HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
private Response RequestAction(string action, TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue