This commit is contained in:
Zeeshaun
2026-03-24 15:26:03 -05:00
parent 1e5beb292a
commit 9cc87337b8
333 changed files with 17931 additions and 0 deletions
@@ -0,0 +1,42 @@
using LCU.Api.Internal.Dispatcher.Services.DispatcherOperationServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[ApiController]
[Route("api/[controller]")]
public class CleanUpJobProcessController : ControllerBase
{
private readonly ICleanUpJobsService _cleanUpJobsService;
public CleanUpJobProcessController(ICleanUpJobsService cleanUpJobsService)
{
_cleanUpJobsService = cleanUpJobsService;
}
[HttpPost("RunCleanUpJobProcessNow", Name = "RunCleanUpJobProcessNow")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> RunCleanUpJobNow()
{
try
{
Log.Information("Manually Kicked Off Dispatcher's Clean Up Job Hosted Service.");
var token = new CancellationToken();
await _cleanUpJobsService.PerformCleanUpJobs(token);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,161 @@
using LCU.Api.Internal.Dispatcher.Services;
using LCU.Api.Internal.Dispatcher.Services.DispatcherOperationServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[ApiController]
[Route("api/[controller]")]
public class CleanUpJobSettingController : ControllerBase
{
private readonly ICleanUpJobSettingService _cleanUpJobSettingService;
public CleanUpJobSettingController(ICleanUpJobSettingService cleanUpJobSettingService)
{
_cleanUpJobSettingService = cleanUpJobSettingService;
}
[HttpGet("GetAllCleanUpJobSetting", Name = "GetAllCleanUpJobSetting")]
[ProducesResponseType(typeof(IEnumerable<CleanUpJobSetting>), 200)]
[ProducesResponseType(204)]
[ProducesResponseType(500)]
public async Task<IActionResult> Get()
{
try
{
var result = await _cleanUpJobSettingService.GetAsync();
if (result == null || !result.Any())
{
return NoContent();
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetByCleanUpJobSettingIdAsync", Name = "GetByCleanUpJobSettingIdAsync")]
[ProducesResponseType(typeof(CleanUpJobSetting), 200)]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetByCleanUpJobSettingIdAsync(int cleanUpJobSettingId)
{
try
{
if (cleanUpJobSettingId <= 0)
{
return BadRequest("Invalid CleanUpJobSettingId.");
}
var result = await _cleanUpJobSettingService.GetByCleanUpJobSettingIdAsync(cleanUpJobSettingId);
if (result == null)
{
return NoContent();
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
[ProducesResponseType(typeof(CleanUpJobSetting), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(406)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] CleanUpJobSetting request)
{
try
{
var result = await _cleanUpJobSettingService.SaveAsync(request);
if (result == null)
{
return StatusCode(StatusCodes.Status406NotAcceptable);
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut()]
[ProducesResponseType(typeof(CleanUpJobSetting), 200)]
[ProducesResponseType(406)]
[ProducesResponseType(500)]
public async Task<IActionResult> Put([FromBody] CleanUpJobSetting request)
{
try
{
var result = await _cleanUpJobSettingService.UpdateAsync(request);
if (result == null)
{
return StatusCode(StatusCodes.Status406NotAcceptable);
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete()]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Delete(int cleanUpJobSettingId)
{
try
{
if (cleanUpJobSettingId <= 0)
{
return BadRequest("Invalid CleanUpJobSettingId");
}
await _cleanUpJobSettingService.DeleteAsync(cleanUpJobSettingId);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,192 @@
using LCU.Api.Internal.Dispatcher.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("api/[controller]")]
[ApiController]
public class CleanUpJobTagController : ControllerBase
{
private readonly ICleanUpJobTagService _cleanUpJobTagService;
public CleanUpJobTagController(ICleanUpJobTagService cleanUpJobTagService)
{
_cleanUpJobTagService = cleanUpJobTagService;
}
[HttpGet(Name = "GetAllCleanUpJobTag")]
[ProducesResponseType(typeof(IEnumerable<CleanUpJobTag>), 200)]
[ProducesResponseType(204)]
[ProducesResponseType(500)]
public async Task<IActionResult> Get()
{
try
{
var result = await _cleanUpJobTagService.GetAsync();
if (result == null || !result.Any())
{
return NoContent();
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetByCleanUpJobTagIdAsync", Name = "GetByCleanUpJobTagIdAsync")]
[ProducesResponseType(typeof(CleanUpJobTag), 200)]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetByCleanUpJobTagIdAsync(int cleanUpJobTagId)
{
try
{
if (cleanUpJobTagId <= 0)
{
return BadRequest("Invalid CleanUpJobTagIdId.");
}
var result = await _cleanUpJobTagService.GetByCleanUpJobTagIdAsync(cleanUpJobTagId);
if (result == null)
{
return NoContent();
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetTagsByCleanUpJobSettingIdAsync", Name = "GetTagsByCleanUpJobSettingIdAsync")]
[ProducesResponseType(typeof(IEnumerable<CleanUpJobTag>), 200)]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetByCleanUpJobSettingIdAsync(int cleanUpJobSettingId)
{
try
{
if (cleanUpJobSettingId <= 0)
{
return BadRequest("Invalid CleanUpJobSettingId.");
}
var result = await _cleanUpJobTagService.GetByCleanUpJobSettingIdAsync(cleanUpJobSettingId);
if (result == null)
{
return NoContent();
}
return Ok(result);
}
catch (ArgumentNullException)
{
return StatusCode(StatusCodes.Status404NotFound);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost()]
[ProducesResponseType(typeof(CleanUpJobTag), 200)]
[ProducesResponseType(406)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] CleanUpJobTag request)
{
try
{
var result = await _cleanUpJobTagService.SaveAsync(request);
if (result == null)
{
return StatusCode(StatusCodes.Status406NotAcceptable);
}
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete("DeleteByCleanUpJobTagId", Name = "DeleteByCleanUpJobTagId")]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Delete(int cleanUpJobTagId)
{
try
{
if (cleanUpJobTagId <= 0)
{
return BadRequest("Invalid CleanUpJobTagId");
}
await _cleanUpJobTagService.DeleteAsync(cleanUpJobTagId);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete("DeleteByCleanUpJobSettingId", Name = "DeleteByCleanUpJobSettingId")]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> DeleteByCleanUpJobSettingId(int cleanUpJobSettingId)
{
try
{
if (cleanUpJobSettingId <= 0)
{
return BadRequest("Invalid CleanUpJobSettingId");
}
await _cleanUpJobTagService.DeleteByCleanUpJobSettingIdAsync(cleanUpJobSettingId);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Services;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("[controller]")]
[ApiController]
public class ExecutionMessageController : ControllerBase
{
private readonly IExecutionMessageService _executionMessageService;
public ExecutionMessageController(IExecutionMessageService executionMessageService)
{
_executionMessageService = executionMessageService;
}
[HttpPost()]
[ProducesResponseType(typeof(List<ExecutionMessage>), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] List<ExecutionMessage> request)
{
try
{
if (request == null || !request.Any())
{
return BadRequest("Execution messages are required.");
}
await _executionMessageService.SaveExecutionMessages(request);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,163 @@
using LCU.Api.Internal.Dispatcher.HostedServices;
using LCU.Library.Internal.ApiSecurity.Attributes;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace LCU.Api.Internal.Dispatcher.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class HostedServicesController : ControllerBase
{
private readonly ICleanUpJobsHostedService _cleanUpJobsHostedServiceStarter;
private readonly IBatchErroredJobsHostedService _batchErroredJobsServiceStarter;
private readonly IJobSchedulerHostedService _jobSchedulerHostedServiceStarter;
public HostedServicesController(ICleanUpJobsHostedService cleanUpJobsHostedService,
IBatchErroredJobsHostedService batchErroredJobsServiceStarter,
IJobSchedulerHostedService jobSchedulerHostedServiceStarter)
{
_cleanUpJobsHostedServiceStarter = cleanUpJobsHostedService;
_batchErroredJobsServiceStarter = batchErroredJobsServiceStarter;
_jobSchedulerHostedServiceStarter = jobSchedulerHostedServiceStarter;
}
[ApiKey]
[HttpPost("StartCleanUpJobs", Name = "StartCleanUpJobs")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> StartCleanUpJobs()
{
try
{
await _cleanUpJobsHostedServiceStarter.StartAsync();
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[ApiKey]
[HttpPost("StopCleanUpJobs", Name = "StopCleanUpJobs")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> StopCleanUpJobs()
{
try
{
await _cleanUpJobsHostedServiceStarter.StopAsync();
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[ApiKey]
[HttpPost("StartBatchErroredJobs", Name = "StartBatchErroredJobs")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> StartBatchErroredJobs()
{
try
{
await _batchErroredJobsServiceStarter.StartAsync();
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[ApiKey]
[HttpPost("StopBatchErroredJobs", Name = "StopBatchErroredJobs")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> StopBatchErroredJobs()
{
try
{
await _batchErroredJobsServiceStarter.StopAsync();
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[ApiKey]
[HttpPost("StartJobScheduler", Name = "StartJobScheduler")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> StartJobScheduler()
{
try
{
await _jobSchedulerHostedServiceStarter.StartAsync();
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[ApiKey]
[HttpPost("StopJobScheduler", Name = "StopJobScheduler")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<IActionResult> StopJobScheduler()
{
try
{
await _jobSchedulerHostedServiceStarter.StopAsync();
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}
@@ -0,0 +1,51 @@
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<string>), 400)]
[ProducesResponseType(500)]
public async Task<IActionResult> 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);
}
}
}
@@ -0,0 +1,304 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Services;
using LCU.Library.Internal.DispatcherModels.Models.Requests;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("api/[controller]")]
[ApiController]
public class JobController : ControllerBase
{
private readonly IJobService _jobService;
public JobController(IJobService jobService)
{
_jobService = jobService;
}
[HttpPost("GetFilteredJobs")]
[ProducesResponseType(typeof(PagedResponse<Job>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetFilteredJobs([FromBody] Filter filter)
{
try
{
var filterResult = await _jobService.GetFilteredJobs(filter);
var result = new PagedResponse<Job>(filterResult, filter);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet(Name = "GetAllJobs")]
[ProducesResponseType(typeof(IEnumerable<Job>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> Get()
{
try
{
var result = await _jobService.GetAsync();
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetInactiveJobs", Name = "GetInactiveJobs")]
[ProducesResponseType(typeof(IEnumerable<Job>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetInactive()
{
try
{
var result = await _jobService.GetInactiveAsync();
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetInactiveJobsExcludeSoftDeleted", Name = "GetInactiveJobsExcludeSoftDeleted")]
[ProducesResponseType(typeof(IEnumerable<Job>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetInactiveExcludeSoftDeleted()
{
try
{
var result = await _jobService.GetInactiveExcludeSoftDeletedTrackedAsync();
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetSoftDeletedJobs", Name = "GetSoftDeletedJobs")]
[ProducesResponseType(typeof(IEnumerable<Job>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetSoftDeleted(DateTime cutOffDate)
{
try
{
var result = await _jobService.GetSoftDeletedTrackedAsync(cutOffDate);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetJobByIdExcludingWorkItems", Name = "GetJobByIdExcludingWorkItems")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetJobByIdExcludingWorkItems(int jobId)
{
try
{
var result = await _jobService.GetByIdExcludingWorkItemsAsync(jobId);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("RunJobNow", Name = "RunJobNow")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> RunJobNow([FromBody] Job job)
{
try
{
var result = await _jobService.RunJobNowAsync(job);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("RunJobNowById", Name = "RunJobNowById")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> RunJobNowById(int id)
{
try
{
var result = await _jobService.RunJobNowByIdAsync(id);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("DeactivateJob", Name = "DeactivateJob")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> DeactivateJob([FromBody] Job job)
{
try
{
var result = await _jobService.DeactivateJobAsync(job);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("RescheduleJob", Name = "RescheduleJob")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> RescheduleJob([FromBody] Job job)
{
try
{
var result = await _jobService.RescheduleJobAsync(job);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("RemoveSoftDeleteById", Name = "RemoveSoftDeleteById")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> RemoveSoftDeleteById(int id)
{
try
{
var result = await _jobService.RemoveSoftDeleteById(id);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete()]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Delete(int jobId)
{
try
{
if (jobId <= 0)
{
return BadRequest("Invalid Id");
}
await _jobService.DeleteAsync(jobId);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost("Copy")]
[ProducesResponseType(typeof(Job), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Copy(CopyJobRequest request)
{
try
{
if (request == null)
{
return BadRequest("Request cannot be null");
}
var job = await _jobService.CopyJobAsync(request);
return Ok(job);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,112 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Services;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("[controller]")]
[ApiController]
public class JobTagController : ControllerBase
{
private readonly IJobTagService _jobTagService;
public JobTagController(IJobTagService jobTagService)
{
_jobTagService = jobTagService;
}
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<JobTag>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> Get()
{
try
{
var result = await _jobTagService.GetAsync();
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetByTagIdAsync")]
[ProducesResponseType(typeof(IEnumerable<JobTag>), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetByTagIdAsync(int tagId)
{
try
{
if (tagId <= 0)
{
return BadRequest("Invalid TagId.");
}
var result = await _jobTagService.GetByTagIdAsync(tagId);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost()]
[ProducesResponseType(typeof(JobTag), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] JobTag request)
{
try
{
var result = await _jobTagService.SaveAsync(request);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete()]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Delete(int jobTagId)
{
try
{
if (jobTagId <= 0)
{
return BadRequest("Invalid JobTagId");
}
await _jobTagService.Delete(jobTagId);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,45 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Extensions;
using LCU.Api.Internal.Dispatcher.Services.QueueServices;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("api/[controller]")]
[ApiController]
public class QueueCompletionController : ControllerBase
{
private readonly IQueueCompletionService _queueCompletionService;
public QueueCompletionController(IQueueCompletionService completionService)
{
_queueCompletionService = completionService;
}
[HttpPost]
[ProducesResponseType(202)]
[ProducesResponseType(typeof(List<string>), 400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] DispatcherReturnResponse request)
{
try
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState.GetErrorMessages());
}
await _queueCompletionService.QueueCompletion(request);
return Accepted();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,45 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Extensions;
using LCU.Api.Internal.Dispatcher.Services.QueueServices;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("api/[controller]")]
[ApiController]
public class QueueExecutionController : ControllerBase
{
private readonly IQueueExecutionService _queueExecutionService;
public QueueExecutionController(IQueueExecutionService executionService)
{
_queueExecutionService = executionService;
}
[HttpPost("QueueRetryExecution")]
[ProducesResponseType(202)]
[ProducesResponseType(typeof(List<string>), 400)]
[ProducesResponseType(500)]
public async Task<IActionResult> QueueRetryExecutionController([FromBody] WorkItemExecution request)
{
try
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState.GetErrorMessages());
}
await _queueExecutionService.QueueRetryExecution(request);
return Accepted();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Models;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("api/[controller]")]
[ApiController]
public class StatusController : ControllerBase
{
private readonly IEnvironmentView _environmentView;
public StatusController(IEnvironmentView environmentView)
{
_environmentView = environmentView;
}
[HttpGet()]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public IActionResult Get()
{
try
{
return Ok(_environmentView);
}
catch (Exception ex)
{
Log.Error(ex, "Failure to return status");
return StatusCode((int)System.Net.HttpStatusCode.InternalServerError);
}
}
}
@@ -0,0 +1,137 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Services;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("[controller]")]
[ApiController]
public class TagController : ControllerBase
{
private readonly ITagService _tagService;
public TagController(ITagService tagService)
{
_tagService = tagService;
}
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<Tag>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> Get()
{
try
{
var result = await _tagService.GetAsync();
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("GetByIdAsync")]
[ProducesResponseType(typeof(Tag), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetByIdAsync(int tagId)
{
try
{
if (tagId <= 0)
{
return BadRequest("Invalid TagId.");
}
var result = await _tagService.GetByIdAsync(tagId);
return Ok(result);
}
catch (ArgumentNullException)
{
return StatusCode(StatusCodes.Status404NotFound);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost()]
[ProducesResponseType(typeof(Tag), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] Tag request)
{
try
{
var result = await _tagService.SaveAsync(request);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut()]
[ProducesResponseType(typeof(Tag), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> Put([FromBody] Tag request)
{
try
{
var result = await _tagService.UpdateAsync(request);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete()]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Delete(int tagId)
{
try
{
if (tagId <= 0)
{
return BadRequest("Invalid TagId");
}
await _tagService.DeleteAsync(tagId);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,39 @@
using LCU.Api.Internal.Dispatcher.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("api/[controller]")]
[ApiController]
public class WorkItemController : ControllerBase
{
private readonly IWorkItemService _workItemService;
public WorkItemController(IWorkItemService workItemService)
{
_workItemService = workItemService;
}
[HttpPost("GetWorkItemsByJobId")]
[ProducesResponseType(typeof(IEnumerable<WorkItem>), 200)]
[ProducesResponseType(500)]
public async Task<IActionResult> GetWorkItemsByJobId(int jobId)
{
try
{
var result = await _workItemService.GetByJobIdWithExecutionsAsync(jobId);
return Ok(result);
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}