Add endpoints for RecActions and improve documentation
Added new endpoints for invoking, retrieving, creating, and deleting RecActions, including support for both specific and fake/test profiles. Endpoints include: - `Invoke` for batch invocation of RecActions. - `Get` for retrieving RecActions by profile. - `CreateAction` for creating new RecActions. - `CreateFakeAction` for creating test RecActions. - `Delete` for deleting RecActions by profile. Enhanced all endpoints with XML documentation for clarity and added `ProducesResponseType` attributes to specify expected HTTP status codes.
This commit is contained in:
parent
dbfae5cdad
commit
b8074cfaf1
@ -12,14 +12,27 @@ namespace ReC.API.Controllers;
|
||||
[ApiController]
|
||||
public class RecActionController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Invokes a batch of RecActions for a given profile.
|
||||
/// </summary>
|
||||
/// <param name="profileId">The ID of the profile.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
||||
[HttpPost("invoke/{profileId}")]
|
||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId, CancellationToken cancel)
|
||||
{
|
||||
await mediator.InvokeBatchRecAction(profileId, cancel);
|
||||
return Accepted();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes a batch of RecActions for a fake/test profile.
|
||||
/// </summary>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
||||
[HttpPost("invoke/fake")]
|
||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||
public async Task<IActionResult> Invoke(CancellationToken cancel)
|
||||
{
|
||||
await mediator.InvokeBatchRecAction(config.GetFakeProfileId(), cancel);
|
||||
@ -27,19 +40,39 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
||||
}
|
||||
|
||||
#region CRUD
|
||||
/// <summary>
|
||||
/// Gets all RecActions for a given profile.
|
||||
/// </summary>
|
||||
/// <param name="profileId">The ID of the profile.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>A list of RecActions for the specified profile.</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Get([FromQuery] long profileId, CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery()
|
||||
{
|
||||
ProfileId = profileId
|
||||
}, cancel));
|
||||
|
||||
/// <summary>
|
||||
/// Gets all RecActions for a fake/test profile.
|
||||
/// </summary>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>A list of RecActions for the fake profile.</returns>
|
||||
[HttpGet("fake")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery()
|
||||
{
|
||||
ProfileId = config.GetFakeProfileId()
|
||||
}, cancel));
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new RecAction.
|
||||
/// </summary>
|
||||
/// <param name="command">The command containing the details for the new RecAction.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 201 Created response.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.Send(command, cancel);
|
||||
@ -47,7 +80,17 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
||||
return CreatedAtAction(nameof(CreateAction), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new fake RecAction for testing purposes.
|
||||
/// </summary>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <param name="request">The optional request body and header for the fake action.</param>
|
||||
/// <param name="endpointUri">The target endpoint URI.</param>
|
||||
/// <param name="endpointPath">The optional path to append to the endpoint URI.</param>
|
||||
/// <param name="type">The HTTP method type (e.g., GET, POST).</param>
|
||||
/// <returns>An HTTP 201 Created response.</returns>
|
||||
[HttpPost("fake")]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> CreateFakeAction(
|
||||
CancellationToken cancel,
|
||||
[FromBody] FakeRequest? request = null,
|
||||
@ -75,7 +118,14 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
||||
return CreatedAtAction(nameof(CreateFakeAction), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all RecActions associated with a specific profile.
|
||||
/// </summary>
|
||||
/// <param name="profileId">The ID of the profile whose RecActions should be deleted.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromQuery] int profileId, CancellationToken cancel)
|
||||
{
|
||||
await mediator.Send(new DeleteRecActionsCommand()
|
||||
@ -86,7 +136,13 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all RecActions for a fake/test profile.
|
||||
/// </summary>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
||||
[HttpDelete("fake")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete(CancellationToken cancel)
|
||||
{
|
||||
await mediator.Send(new DeleteRecActionsCommand()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user