mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-24 22:35:49 -04:00
New: Bulk manage custom formats
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Radarr.Api.V3.CustomFormats
|
||||
{
|
||||
public class CustomFormatBulkResource
|
||||
{
|
||||
public HashSet<int> Ids { get; set; } = new ();
|
||||
public bool? IncludeCustomFormatWhenRenaming { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,13 @@ namespace Radarr.Api.V3.CustomFormats
|
||||
return _formatService.GetById(id).ToResource(true);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Produces("application/json")]
|
||||
public List<CustomFormatResource> GetAll()
|
||||
{
|
||||
return _formatService.All().ToResource(true);
|
||||
}
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFormatResource> Create([FromBody] CustomFormatResource customFormatResource)
|
||||
@@ -70,11 +77,26 @@ namespace Radarr.Api.V3.CustomFormats
|
||||
return Accepted(model.Id);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HttpPut("bulk")]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
public List<CustomFormatResource> GetAll()
|
||||
public virtual ActionResult<CustomFormatResource> Update([FromBody] CustomFormatBulkResource resource)
|
||||
{
|
||||
return _formatService.All().ToResource(true);
|
||||
if (!resource.Ids.Any())
|
||||
{
|
||||
throw new BadRequestException("ids must be provided");
|
||||
}
|
||||
|
||||
var customFormats = resource.Ids.Select(id => _formatService.GetById(id)).ToList();
|
||||
|
||||
customFormats.ForEach(existing =>
|
||||
{
|
||||
existing.IncludeCustomFormatWhenRenaming = resource.IncludeCustomFormatWhenRenaming ?? existing.IncludeCustomFormatWhenRenaming;
|
||||
});
|
||||
|
||||
_formatService.Update(customFormats);
|
||||
|
||||
return Accepted(customFormats.ConvertAll(cf => cf.ToResource(true)));
|
||||
}
|
||||
|
||||
[RestDeleteById]
|
||||
@@ -83,12 +105,21 @@ namespace Radarr.Api.V3.CustomFormats
|
||||
_formatService.Delete(id);
|
||||
}
|
||||
|
||||
[HttpDelete("bulk")]
|
||||
[Consumes("application/json")]
|
||||
public virtual object DeleteFormats([FromBody] CustomFormatBulkResource resource)
|
||||
{
|
||||
_formatService.Delete(resource.Ids.ToList());
|
||||
|
||||
return new { };
|
||||
}
|
||||
|
||||
[HttpGet("schema")]
|
||||
public object GetTemplates()
|
||||
{
|
||||
var schema = _specifications.OrderBy(x => x.Order).Select(x => x.ToSchema()).ToList();
|
||||
|
||||
var presets = GetPresets();
|
||||
var presets = GetPresets().ToList();
|
||||
|
||||
foreach (var item in schema)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user