Add some API attributes

This commit is contained in:
Qstick 2023-05-29 21:52:20 -05:00
parent 1d034d8099
commit d400685cd1
24 changed files with 46 additions and 1 deletions

View File

@ -22,6 +22,7 @@ namespace Lidarr.Api.V1.Blocklist
}
[HttpGet]
[Produces("application/json")]
public PagingResource<BlocklistResource> GetBlocklist()
{
var pagingResource = Request.ReadPagingResourceFromRequest<BlocklistResource>();
@ -37,6 +38,7 @@ namespace Lidarr.Api.V1.Blocklist
}
[HttpDelete("bulk")]
[Produces("application/json")]
public object Remove([FromBody] BlocklistBulkResource resource)
{
_blocklistService.Delete(resource.Ids);

View File

@ -48,6 +48,8 @@ namespace Lidarr.Api.V1.Commands
}
[RestPostById]
[Consumes("application/json")]
[Produces("application/json")]
public ActionResult<CommandResource> StartCommand(CommandResource commandResource)
{
var commandType =
@ -73,6 +75,7 @@ namespace Lidarr.Api.V1.Commands
}
[HttpGet]
[Produces("application/json")]
public List<CommandResource> GetStartedCommands()
{
return _commandQueueManager.All()

View File

@ -23,6 +23,7 @@ namespace Lidarr.Api.V1.Config
}
[HttpGet]
[Produces("application/json")]
public TResource GetConfig()
{
var resource = ToResource(_configService);
@ -32,6 +33,7 @@ namespace Lidarr.Api.V1.Config
}
[RestPutById]
[Consumes("application/json")]
public virtual ActionResult<TResource> SaveConfig(TResource resource)
{
var dictionary = resource.GetType()

View File

@ -23,12 +23,14 @@ namespace Lidarr.Api.V1.CustomFilters
}
[HttpGet]
[Produces("application/json")]
public List<CustomFilterResource> GetCustomFilters()
{
return _customFilterService.All().ToResource();
}
[RestPostById]
[Consumes("application/json")]
public ActionResult<CustomFilterResource> AddCustomFilter(CustomFilterResource resource)
{
var customFilter = _customFilterService.Add(resource.ToModel());
@ -37,6 +39,7 @@ namespace Lidarr.Api.V1.CustomFilters
}
[RestPutById]
[Consumes("application/json")]
public ActionResult<CustomFilterResource> UpdateCustomFilter(CustomFilterResource resource)
{
_customFilterService.Update(resource.ToModel());

View File

@ -16,6 +16,7 @@ namespace Lidarr.Api.V1.DiskSpace
}
[HttpGet]
[Produces("application/json")]
public List<DiskSpaceResource> GetFreeSpace()
{
return _diskSpaceService.GetFreeSpace().ConvertAll(DiskSpaceResourceMapper.MapToResource);

View File

@ -1,3 +1,4 @@
using System;
using System.Linq;
using Lidarr.Http;
using Microsoft.AspNetCore.Mvc;
@ -23,12 +24,14 @@ namespace Lidarr.Api.V1.FileSystem
}
[HttpGet]
[Produces("application/json")]
public IActionResult GetContents(string path, bool includeFiles = false, bool allowFoldersWithoutTrailingSlashes = false)
{
return Ok(_fileSystemLookupService.LookupContents(path, includeFiles, allowFoldersWithoutTrailingSlashes));
}
[HttpGet("type")]
[Produces("application/json")]
public object GetEntityType(string path)
{
if (_diskProvider.FileExists(path))
@ -41,11 +44,12 @@ namespace Lidarr.Api.V1.FileSystem
}
[HttpGet("mediafiles")]
[Produces("application/json")]
public object GetMediaFiles(string path)
{
if (!_diskProvider.FolderExists(path))
{
return global::System.Array.Empty<string>();
return Array.Empty<string>();
}
return _diskScanService.GetAudioFiles(path).Select(f => new

View File

@ -28,6 +28,7 @@ namespace Lidarr.Api.V1.Health
}
[HttpGet]
[Produces("application/json")]
public List<HealthResource> GetHealth()
{
return _healthCheckService.Results().ToResource();

View File

@ -21,6 +21,7 @@ namespace Lidarr.Api.V1.Localization
}
[HttpGet]
[Produces("application/json")]
public string GetLocalizationDictionary()
{
return JsonSerializer.Serialize(_localizationService.GetLocalizationDictionary().ToResource(), _serializerSettings);

View File

@ -17,6 +17,7 @@ namespace Lidarr.Api.V1.Logs
}
[HttpGet]
[Produces("application/json")]
public PagingResource<LogResource> GetLogs()
{
var pagingResource = Request.ReadPagingResourceFromRequest<LogResource>();

View File

@ -26,6 +26,7 @@ namespace Lidarr.Api.V1.Logs
}
[HttpGet]
[Produces("application/json")]
public List<LogFileResource> GetLogFilesResponse()
{
var result = new List<LogFileResource>();
@ -51,6 +52,7 @@ namespace Lidarr.Api.V1.Logs
}
[HttpGet(@"{filename:regex([[-.a-zA-Z0-9]]+?\.txt)}")]
[Produces("text/plain")]
public IActionResult GetLogFileResponse(string filename)
{
LogManager.Flush();

View File

@ -17,6 +17,7 @@ namespace Lidarr.Api.V1.Parse
}
[HttpGet]
[Produces("application/json")]
public ParseResource Parse(string title)
{
var parsedAlbumInfo = Parser.ParseAlbumTitle(title);

View File

@ -41,6 +41,7 @@ namespace Lidarr.Api.V1
}
[HttpGet]
[Produces("application/json")]
public List<TProviderResource> GetAll()
{
var providerDefinitions = _providerFactory.All();
@ -58,6 +59,7 @@ namespace Lidarr.Api.V1
}
[RestPostById]
[Consumes("application/json")]
public ActionResult<TProviderResource> CreateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
{
var providerDefinition = GetDefinition(providerResource, true, !forceSave, false);
@ -73,6 +75,7 @@ namespace Lidarr.Api.V1
}
[RestPutById]
[Consumes("application/json")]
public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
{
var providerDefinition = GetDefinition(providerResource, true, !forceSave, false);
@ -108,6 +111,7 @@ namespace Lidarr.Api.V1
}
[HttpGet("schema")]
[Produces("application/json")]
public List<TProviderResource> GetTemplates()
{
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
@ -131,6 +135,7 @@ namespace Lidarr.Api.V1
[SkipValidation(true, false)]
[HttpPost("test")]
[Consumes("application/json")]
public object Test([FromBody] TProviderResource providerResource)
{
var providerDefinition = GetDefinition(providerResource, true, true, true);
@ -164,6 +169,7 @@ namespace Lidarr.Api.V1
[SkipValidation]
[HttpPost("action/{name}")]
[Consumes("application/json")]
public IActionResult RequestAction(string name, [FromBody] TProviderResource resource)
{
var providerDefinition = GetDefinition(resource, false, false, false);

View File

@ -35,6 +35,7 @@ namespace Lidarr.Api.V1.Queue
}
[HttpPost("grab/bulk")]
[Consumes("application/json")]
public object Grab([FromBody] QueueBulkResource resource)
{
foreach (var id in resource.Ids)

View File

@ -90,6 +90,7 @@ namespace Lidarr.Api.V1.Queue
}
[HttpGet]
[Produces("application/json")]
public PagingResource<QueueResource> GetQueue(bool includeUnknownArtistItems = false, bool includeArtist = false, bool includeAlbum = false)
{
var pagingResource = Request.ReadPagingResourceFromRequest<QueueResource>();

View File

@ -32,6 +32,7 @@ namespace Lidarr.Api.V1.Queue
}
[HttpGet]
[Produces("application/json")]
public List<QueueResource> GetQueue(int? artistId, [FromQuery]List<int> albumIds, bool includeArtist = false, bool includeAlbum = true)
{
var queue = _queueService.GetQueue();

View File

@ -36,6 +36,7 @@ namespace Lidarr.Api.V1.Queue
}
[HttpGet]
[Produces("application/json")]
public QueueStatusResource GetQueueStatus()
{
_broadcastDebounce.Pause();

View File

@ -40,6 +40,7 @@ namespace Lidarr.Api.V1.RemotePathMappings
}
[RestPostById]
[Consumes("application/json")]
public ActionResult<RemotePathMappingResource> CreateMapping(RemotePathMappingResource resource)
{
var model = resource.ToModel();
@ -48,6 +49,7 @@ namespace Lidarr.Api.V1.RemotePathMappings
}
[HttpGet]
[Produces("application/json")]
public List<RemotePathMappingResource> GetMappings()
{
return _remotePathMappingService.All().ToResource();

View File

@ -60,6 +60,7 @@ namespace Lidarr.Api.V1.RootFolders
}
[RestPostById]
[Consumes("application/json")]
public ActionResult<RootFolderResource> CreateRootFolder(RootFolderResource rootFolderResource)
{
var model = rootFolderResource.ToModel();
@ -83,6 +84,7 @@ namespace Lidarr.Api.V1.RootFolders
}
[HttpGet]
[Produces("application/json")]
public List<RootFolderResource> GetRootFolders()
{
return _rootFolderService.AllWithSpaceStats().ToResource();

View File

@ -54,6 +54,7 @@ namespace Lidarr.Api.V1.System
}
[HttpGet("status")]
[Produces("application/json")]
public SystemResource GetStatus()
{
return new SystemResource
@ -93,6 +94,7 @@ namespace Lidarr.Api.V1.System
}
[HttpGet("routes")]
[Produces("application/json")]
public IActionResult GetRoutes()
{
using (var sw = new StringWriter())
@ -104,6 +106,7 @@ namespace Lidarr.Api.V1.System
}
[HttpGet("routes/duplicate")]
[Produces("application/json")]
public object DuplicateRoutes()
{
return _detector.GetDuplicateEndpoints(_endpointData);

View File

@ -28,18 +28,21 @@ namespace Lidarr.Api.V1.Tags
}
[HttpGet]
[Produces("application/json")]
public List<TagResource> GetAll()
{
return _tagService.All().ToResource();
}
[RestPostById]
[Consumes("application/json")]
public ActionResult<TagResource> Create(TagResource resource)
{
return Created(_tagService.Add(resource.ToModel()).Id);
}
[RestPutById]
[Consumes("application/json")]
public ActionResult<TagResource> Update(TagResource resource)
{
_tagService.Update(resource.ToModel());

View File

@ -22,6 +22,7 @@ namespace Lidarr.Api.V1.Tags
}
[HttpGet]
[Produces("application/json")]
public List<TagDetailsResource> GetAll()
{
var tags = _tagService.Details().ToResource();

View File

@ -21,6 +21,7 @@ namespace Lidarr.Api.V1.Update
}
[HttpGet]
[Produces("application/json")]
public List<UpdateResource> GetRecentUpdates()
{
var resources = _recentUpdateProvider.GetRecentUpdatePackages()

View File

@ -29,6 +29,7 @@ namespace Lidarr.Api.V1.Wanted
}
[HttpGet]
[Produces("application/json")]
public PagingResource<AlbumResource> GetCutoffUnmetAlbums(bool includeArtist = false)
{
var pagingResource = Request.ReadPagingResourceFromRequest<AlbumResource>();

View File

@ -25,6 +25,7 @@ namespace Lidarr.Api.V1.Wanted
}
[HttpGet]
[Produces("application/json")]
public PagingResource<AlbumResource> GetMissingAlbums(bool includeArtist = false)
{
var pagingResource = Request.ReadPagingResourceFromRequest<AlbumResource>();