Updating
This commit is contained in:
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Api.Internal.ArchiverApi.Extensions;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ApplicationMappingController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationMappingService _applicationMappingService;
|
||||
|
||||
public ApplicationMappingController(IApplicationMappingService applicationMappingService)
|
||||
{
|
||||
_applicationMappingService = applicationMappingService;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetAllJobs")]
|
||||
[ProducesResponseType(typeof(IEnumerable<ApplicationMapping>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _applicationMappingService.GetAsync();
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}", Name = "GetById")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _applicationMappingService.GetByIdAsync(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] ApplicationMapping applicationMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _applicationMappingService.SaveAsync(applicationMapping);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("Update", Name = "Update")]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Update([FromBody] ApplicationMapping applicationMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _applicationMappingService.Update(applicationMapping);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete()]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Delete(int jobId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (jobId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
|
||||
_applicationMappingService.DeleteAsync(jobId);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Serilog;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class QueueArchiverController : ControllerBase
|
||||
{
|
||||
private readonly IQueueArchiverService _queueArchiverService;
|
||||
|
||||
public QueueArchiverController(IQueueArchiverService queueArchiverService)
|
||||
{
|
||||
_queueArchiverService = queueArchiverService;
|
||||
}
|
||||
|
||||
[HttpPost("QueueArchiver")]
|
||||
public IActionResult QueueArchiver(ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.Values);
|
||||
}
|
||||
|
||||
_queueArchiverService.QueueArchiver(archiveRequest);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Api.Internal.ArchiverApi.Extensions;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class RegexMappingController : ControllerBase
|
||||
{
|
||||
IRegexMappingService _regexMappingService;
|
||||
public RegexMappingController(IRegexMappingService regexMappingService)
|
||||
{
|
||||
_regexMappingService = regexMappingService;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetAllRegex")]
|
||||
[ProducesResponseType(typeof(IEnumerable<RegexMapping>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _regexMappingService.GetAsync();
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("GetByRegexId/{regexMappingId:int}", Name = "GetByRegexId")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(204)]
|
||||
[ProducesResponseType(typeof(RegexMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByRegexMappingId(int regexMappingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (regexMappingId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
var result = await _regexMappingService.GetByRegexMappingIdAsync(regexMappingId);
|
||||
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("GetByApplicationMappingId/{applicationMappingid:int}", Name = "GetByApplicationMappingId")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(204)]
|
||||
[ProducesResponseType(typeof(RegexMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByApplicationMappingId(int applicationMappingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (applicationMappingId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
var result = await _regexMappingService.GetByApplicationMappingIdAsync(applicationMappingId);
|
||||
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(201)]
|
||||
[ProducesResponseType(typeof(RegexMapping), 400)]
|
||||
[ProducesResponseType(406)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] RegexMapping regexMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _regexMappingService.SaveAsync(regexMapping);
|
||||
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("UpdateRegex", Name = "UpdateRegex")]
|
||||
[ProducesResponseType(typeof(RegexMapping), 200)]
|
||||
[ProducesResponseType(406)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Update([FromBody] RegexMapping regexMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _regexMappingService.Update(regexMapping);
|
||||
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(typeof(RegexMapping), 200)]
|
||||
[ProducesResponseType(400)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Delete(int regexId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (regexId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
|
||||
_regexMappingService.DeleteAsync(regexId);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
using LCU.Api.Internal.ArchiverApi.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class StatusController : ControllerBase
|
||||
{
|
||||
private readonly IEnvironmentView _environmentView;
|
||||
|
||||
public StatusController(IEnvironmentView environmentView)
|
||||
{
|
||||
_environmentView = environmentView;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Verbose($"{_environmentView.Application}'s status endpoint was hit in {_environmentView.Environment}");
|
||||
return Ok(_environmentView);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error("Failure return status, message: {0} {1}", e.Message, e.StackTrace);
|
||||
return StatusCode((int)System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user