Files
monorepo/LCU.API.Internal.FTP/LCU.Api.Internal.FTP/Controllers/SshFtpController.cs
T
2026-03-24 15:28:37 -05:00

49 lines
1.4 KiB
C#

using System;
using Serilog;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.FTP.Extensions;
using LCU.Api.Internal.FTP.Services;
using LCU.Api.Internal.FTPLib.Models;
using LCU.Library.Internal.Exceptions;
namespace LCU.Api.Internal.FTP.Controllers;
[Route("[controller]")]
[ApiController]
public class SshFtpController : ControllerBase
{
private readonly IQueueSshFtpService _queueSshFtpService;
public SshFtpController(IQueueSshFtpService queueSshFtpService)
{
_queueSshFtpService = queueSshFtpService;
}
[HttpPost("QueueSshFtpRequest")]
[ProducesResponseType(201)]
[ProducesResponseType(typeof(List<string>), 400)]
[ProducesResponseType(500)]
public IActionResult QueueSshFtpRequest([FromBody] SshFtpRequest request)
{
try
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState.GetErrorMessages());
}
_queueSshFtpService.QueueSshFtpRequest(request);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}