Files
nexus/backend/Controllers/IncidentsController.cs
T
AzuTear f5552218bc
CI - Build & Test / Backend (.NET) (push) Successful in 42s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 2m46s
CI - Build & Test / Security Check (push) Successful in 3s
CI - Build & Test / Deploy Nexus (push) Successful in 56s
feat: ship agent-first mission control v0.2.57
2026-07-31 22:39:47 +02:00

56 lines
1.9 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Nexus.Api.Models;
using Nexus.Api.Services;
namespace Nexus.Api.Controllers;
[Authorize(Roles = "owner")]
[ProducesResponseType(
typeof(OpenClawAgentConfigurationErrorDto),
StatusCodes.Status403Forbidden)]
[ProducesResponseType(
typeof(OpenClawAgentConfigurationErrorDto),
StatusCodes.Status409Conflict)]
[ProducesResponseType(
typeof(OpenClawAgentConfigurationErrorDto),
StatusCodes.Status502BadGateway)]
[ProducesResponseType(
typeof(OpenClawAgentConfigurationErrorDto),
StatusCodes.Status503ServiceUnavailable)]
[ProducesResponseType(
typeof(OpenClawAgentConfigurationErrorDto),
StatusCodes.Status504GatewayTimeout)]
[ApiController]
[Route("api/v1/incidents")]
public class IncidentsController(IIncidentService incidentService) : ControllerBase
{
[HttpGet]
[ProducesResponseType(typeof(IReadOnlyList<IncidentSummary>), StatusCodes.Status200OK)]
public Task<IResult> GetAll(
[FromQuery] string agentId = "iris",
CancellationToken cancellationToken = default)
=> OpenClawContentReadEndpoint.ExecuteAsync(async () =>
Results.Ok(await incidentService.GetAllAsync(
agentId,
cancellationToken)));
[HttpGet("{name}")]
[ProducesResponseType(typeof(IncidentDetail), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public Task<IResult> GetOne(
string name,
[FromQuery] string agentId = "iris",
CancellationToken cancellationToken = default)
=> OpenClawContentReadEndpoint.ExecuteAsync(async () =>
{
var incident = await incidentService.GetByNameAsync(
name,
agentId,
cancellationToken);
return incident is null
? Results.NotFound()
: Results.Ok(incident);
});
}