Browse Source

Address code review feedback

- FFmpegProfileController: Use RESTful routes for CRUD operations
  - POST /api/ffmpeg/profiles (was /new)
  - PUT /api/ffmpeg/profiles (was /update)
  - DELETE /api/ffmpeg/profiles/{id} (was /api/ffmpeg/delete/{id})

- SmartCollectionController: Use RESTful routes
  - POST /api/collections/smart (was /new)
  - PUT /api/collections/smart (was /update)
  - DELETE /api/collections/smart/{id} (was /delete/{id})
  - Return NoContent() for DELETE instead of Ok()

- ScannerController: Remove redundant OpenAPI attributes since
  controller has [ApiExplorerSettings(IgnoreApi = true)]

- MaintenanceController: Preserve backward compatibility
  - Keep HttpGet for /gc endpoint
  - Keep underscore in /empty_trash route
pull/2735/head
Adam Jacob Muller 7 months ago
parent
commit
c79bd3610e
  1. 6
      ErsatzTV/Controllers/Api/FFmpegProfileController.cs
  2. 4
      ErsatzTV/Controllers/Api/MaintenanceController.cs
  3. 6
      ErsatzTV/Controllers/Api/ScannerController.cs
  4. 8
      ErsatzTV/Controllers/Api/SmartCollectionController.cs

6
ErsatzTV/Controllers/Api/FFmpegProfileController.cs

@ -29,7 +29,7 @@ public class FFmpegProfileController(IMediator mediator) : ControllerBase @@ -29,7 +29,7 @@ public class FFmpegProfileController(IMediator mediator) : ControllerBase
return result.Match<IActionResult>(Ok, () => NotFound());
}
[HttpPost("/api/ffmpeg/profiles/new", Name = "CreateFFmpegProfile")]
[HttpPost("/api/ffmpeg/profiles", Name = "CreateFFmpegProfile")]
[Tags("FFmpeg")]
[EndpointSummary("Create FFmpeg profile")]
[EndpointGroupName("general")]
@ -42,7 +42,7 @@ public class FFmpegProfileController(IMediator mediator) : ControllerBase @@ -42,7 +42,7 @@ public class FFmpegProfileController(IMediator mediator) : ControllerBase
return result.Match<IActionResult>(Ok, error => Problem(error.ToString()));
}
[HttpPut("/api/ffmpeg/profiles/update", Name = "UpdateFFmpegProfile")]
[HttpPut("/api/ffmpeg/profiles", Name = "UpdateFFmpegProfile")]
[Tags("FFmpeg")]
[EndpointSummary("Update FFmpeg profile")]
[EndpointGroupName("general")]
@ -55,7 +55,7 @@ public class FFmpegProfileController(IMediator mediator) : ControllerBase @@ -55,7 +55,7 @@ public class FFmpegProfileController(IMediator mediator) : ControllerBase
return result.Match<IActionResult>(Ok, error => Problem(error.ToString()));
}
[HttpDelete("/api/ffmpeg/delete/{id:int}", Name = "DeleteFFmpegProfile")]
[HttpDelete("/api/ffmpeg/profiles/{id:int}", Name = "DeleteFFmpegProfile")]
[Tags("FFmpeg")]
[EndpointSummary("Delete FFmpeg profile")]
[EndpointGroupName("general")]

4
ErsatzTV/Controllers/Api/MaintenanceController.cs

@ -9,7 +9,7 @@ namespace ErsatzTV.Controllers.Api; @@ -9,7 +9,7 @@ namespace ErsatzTV.Controllers.Api;
public class MaintenanceController(IMediator mediator) : ControllerBase
{
[HttpPost("/api/maintenance/gc", Name = "GarbageCollection")]
[HttpGet("/api/maintenance/gc", Name = "GarbageCollection")]
[Tags("Maintenance")]
[EndpointSummary("Garbage collect")]
[EndpointGroupName("general")]
@ -19,7 +19,7 @@ public class MaintenanceController(IMediator mediator) : ControllerBase @@ -19,7 +19,7 @@ public class MaintenanceController(IMediator mediator) : ControllerBase
return Ok();
}
[HttpPost("/api/maintenance/empty-trash", Name = "EmptyTrash")]
[HttpPost("/api/maintenance/empty_trash", Name = "EmptyTrash")]
[Tags("Maintenance")]
[EndpointSummary("Empty trash")]
[EndpointGroupName("general")]

6
ErsatzTV/Controllers/Api/ScannerController.cs

@ -14,8 +14,6 @@ public class ScannerController( @@ -14,8 +14,6 @@ public class ScannerController(
ChannelWriter<ISearchIndexBackgroundServiceRequest> channelWriter)
{
[HttpPost("progress")]
[EndpointSummary("Scanner progress update")]
[EndpointGroupName("general")]
public async Task<IActionResult> Progress(Guid scanId, [FromBody] decimal percentComplete)
{
await scannerProxyService.Progress(scanId, percentComplete);
@ -23,8 +21,6 @@ public class ScannerController( @@ -23,8 +21,6 @@ public class ScannerController(
}
[HttpPost("items/reindex")]
[EndpointSummary("Scanner reindex items in search index")]
[EndpointGroupName("general")]
public async Task<IActionResult> UpdateItems(
Guid scanId,
[FromBody] List<int> itemsToUpdate,
@ -39,8 +35,6 @@ public class ScannerController( @@ -39,8 +35,6 @@ public class ScannerController(
}
[HttpPost("items/remove")]
[EndpointSummary("Scanner remove items from search index")]
[EndpointGroupName("general")]
public async Task<IActionResult> RemoveItems(
Guid scanId,
[FromBody] List<int> itemsToRemove,

8
ErsatzTV/Controllers/Api/SmartCollectionController.cs

@ -15,7 +15,7 @@ public class SmartCollectionController(IMediator mediator) : ControllerBase @@ -15,7 +15,7 @@ public class SmartCollectionController(IMediator mediator) : ControllerBase
public async Task<List<SmartCollectionResponseModel>> GetAll() =>
await mediator.Send(new GetAllSmartCollectionsForApi());
[HttpPost("/api/collections/smart/new", Name = "CreateSmartCollection")]
[HttpPost("/api/collections/smart", Name = "CreateSmartCollection")]
[EndpointGroupName("general")]
public async Task<IActionResult> AddOne(
[Required] [FromBody]
@ -26,7 +26,7 @@ public class SmartCollectionController(IMediator mediator) : ControllerBase @@ -26,7 +26,7 @@ public class SmartCollectionController(IMediator mediator) : ControllerBase
return result.Match<IActionResult>(Ok, error => Problem(error.ToString()));
}
[HttpPut("/api/collections/smart/update", Name="UpdateSmartCollection")]
[HttpPut("/api/collections/smart", Name="UpdateSmartCollection")]
[EndpointGroupName("general")]
public async Task<IActionResult> UpdateOne(
[Required] [FromBody]
@ -36,11 +36,11 @@ public class SmartCollectionController(IMediator mediator) : ControllerBase @@ -36,11 +36,11 @@ public class SmartCollectionController(IMediator mediator) : ControllerBase
return result.Match<IActionResult>(Ok, error => Problem(error.ToString()));
}
[HttpDelete("/api/collections/smart/delete/{id:int}", Name="DeleteSmartCollection")]
[HttpDelete("/api/collections/smart/{id:int}", Name="DeleteSmartCollection")]
[EndpointGroupName("general")]
public async Task<IActionResult> DeleteSmartCollection(int id)
{
Either<BaseError, Unit> result = await mediator.Send(new DeleteSmartCollection(id));
return result.Match<IActionResult>(_ => Ok(), error => Problem(error.ToString()));
return result.Match<IActionResult>(_ => NoContent(), error => Problem(error.ToString()));
}
}

Loading…
Cancel
Save