Adding MaidBotApi

This commit is contained in:
Zeeshaun
2026-03-11 13:21:47 -05:00
parent f3cb730f3b
commit f004c8205a
122 changed files with 4227 additions and 0 deletions
@@ -0,0 +1,73 @@
using System;
using System.Threading.Tasks;
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using LCU.Api.Internal.MaidBotApi.Services;
using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Library.Internal.Exceptions;
namespace LCU.API.Internal.MaidBotApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class EventLogController : ControllerBase
{
private readonly IEventLogService _eventLogService;
public EventLogController(IEventLogService eventLogService)
{
_eventLogService = eventLogService;
}
[HttpGet]
[ProducesResponseType(200)]
[ProducesResponseType(204)]
[ProducesResponseType(typeof(EventLog), 400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Get()
{
try
{
var results = await _eventLogService.GetAsync();
if (results == null || !results.Any())
{
return NoContent();
}
return Ok(results);
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete()]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public IActionResult DeleteMany([FromBody] List<EventLog> eventLogs)
{
try
{
_eventLogService.DeleteMany(eventLogs);
return Ok();
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using LCU.Api.Internal.MaidBotApi.Exceptions;
using LCU.Api.Internal.MaidBotApi.Services;
using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Library.Internal.Exceptions;
namespace LCU.API.Internal.MaidBotApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class LoggingMatrixController : ControllerBase
{
private readonly ILoggingMatrixService _loggingMatrixService;
public LoggingMatrixController(ILoggingMatrixService loggingMatrixService)
{
_loggingMatrixService = loggingMatrixService;
}
[HttpGet(Name = "GetAllLoggingMatrixes")]
[ProducesResponseType(typeof(IEnumerable<LoggingMatrix>), 200)]
[ProducesResponseType(500)]
public async Task<ActionResult> Get()
{
try
{
var result = await _loggingMatrixService.GetAsync();
return Ok(result);
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
[ProducesResponseType(typeof(LoggingMatrix), 201)]
[ProducesResponseType(typeof(List<string>), 400)]
[ProducesResponseType(500)]
public async Task<ActionResult> Post([FromBody] LoggingMatrix loggingMatrix)
{
try
{
var result = await _loggingMatrixService.SaveAsync(loggingMatrix);
if (result == null)
{
Log.Error($"Result is null could not create Logging Matrix");
return StatusCode((StatusCodes.Status400BadRequest), "Could not create Logging Matrix.");
}
return StatusCode(StatusCodes.Status201Created, result);
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut]
[ProducesResponseType(typeof(LoggingMatrix), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
public async Task<IActionResult> Put([FromBody] LoggingMatrix loggingMatrix)
{
try
{
if (loggingMatrix.LoggingMatrixId <= 0)
{
return BadRequest("Invalid ID");
}
var result = await _loggingMatrixService.UpdateAsync(loggingMatrix);
if(result == null)
{
return NotFound($"The LoggingMatrix with LoggingMatrixId: {loggingMatrix.LoggingMatrixId} " +
"could not be found");
}
return Ok(result);
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using LCU.Api.Internal.MaidBotApi.Services;
using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Library.Internal.Exceptions;
namespace LCU.API.Internal.MaidBotApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class QueueEventLogController : ControllerBase
{
private readonly IQueueEventLogService _queueEventLogService;
public QueueEventLogController(IQueueEventLogService queueEventLogService)
{
_queueEventLogService = queueEventLogService;
}
[HttpPost]
[ProducesResponseType(202)]
[ProducesResponseType(typeof(List<string>), 400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] EventLog EventLog)
{
try
{
await _queueEventLogService.QueueEventLog(EventLog);
return Accepted();
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
@@ -0,0 +1,34 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using LCU.Api.Internal.MaidBotApi.EnvironmentView;
namespace LCU.API.Internal.MaidBotApi.Controllers;
[ApiController]
[Route("api/[controller]")]
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);
}
}
}