33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using IntegrationGateway.Core.Abstractions;
|
|
using IntegrationGateway.Core.Infrastructure;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace IntegrationGateway.Host.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/gateway/alarms")]
|
|
public class AlarmsController : ControllerBase
|
|
{
|
|
private readonly AdapterRegistry _registry;
|
|
|
|
public AlarmsController(AdapterRegistry registry) => _registry = registry;
|
|
|
|
[HttpGet("{adapter}")]
|
|
public async Task<IActionResult> GetAlarms(string adapter, [FromQuery] DateTime from, [FromQuery] DateTime to,
|
|
[FromQuery] int page = 1, [FromQuery] int size = 50)
|
|
{
|
|
var a = _registry.Get(adapter);
|
|
if (a is not IHasAlarms al) return NotFound();
|
|
return Ok(await al.GetAlarmsAsync(page, size, from, to));
|
|
}
|
|
|
|
[HttpPost("{adapter}/{alarmId}/confirm")]
|
|
public async Task<IActionResult> Confirm(string adapter, string alarmId)
|
|
{
|
|
var a = _registry.Get(adapter);
|
|
if (a is not IHasAlarms al) return NotFound();
|
|
await al.ConfirmAlarmAsync(alarmId);
|
|
return Ok(new { status = "confirmed" });
|
|
}
|
|
}
|