using System.Collections.Generic; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using LCU.Api.Internal.Dispatcher.Extensions; using LCU.Api.Internal.Dispatcher.Services.DispatcherOperationServices; namespace LCU.Api.Internal.Dispatcher.Controllers; [Route("api/[controller]")] [ApiController] public class IngestionController : ControllerBase { private readonly IIngestionService _ingestionService; public IngestionController(IIngestionService ingestionService) { _ingestionService = ingestionService; } // POST api/Post [HttpPost] [ProducesResponseType(201)] [ProducesResponseType(typeof(List), 400)] [ProducesResponseType(500)] public async Task Post([FromBody] Job request) { try { if (!ModelState.IsValid) { return BadRequest(ModelState.GetErrorMessages()); } if (!request.WorkItems.Any()) { return BadRequest("Workitems are required."); } await _ingestionService.HandleIngestionRequest(request); return Ok(); } catch (ServiceException) { return StatusCode(StatusCodes.Status500InternalServerError); } catch (Exception exception) { Log.Error(exception, "Unexpected Exception"); return StatusCode(StatusCodes.Status500InternalServerError); } } }