using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using IceImportBLL.IceMapFtpSource; using IceImportDAL.DTO.IceMapFtpSource; using IceImportSL.Parameters.FtpSource; using static GB5Shared.GB5Constant.Constant; namespace IceImportSL.Endpoints.FtpSource; // Minimal config CRUD for MICEMAPFTPSOURCE — Phase 4 only needs *some* way to set this up without // direct DB manipulation for testing; a full validation/UX pass (FE screen) is explicitly deferred. // Never accepts or returns plaintext credentials — only the *VaultRef mount-relative paths // (Vault holds the actual secret values; see IIceImportSecretResolver's doc comment). public class SaveIceMapFtpSource : BaseEndpoint> { private readonly IIceMapFtpSourceBLL _bll; public SaveIceMapFtpSource(IIceMapFtpSourceBLL bll) => _bll = bll; public override void Configure() { Post("/IceImport/SaveIceMapFtpSource"); AllowAnonymous(); } // Mutation endpoint — never cached. protected override string? GetCacheKey(SaveIceMapFtpSourceParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SaveIceMapFtpSourceParameters req, LoginDTO login, CancellationToken ct) { try { var config = new MicemapFtpSourceDTO { IceMapId = req.IceMapId, ConnectionType = req.ConnectionType, HostVaultRef = req.HostVaultRef, UsernameVaultRef = req.UsernameVaultRef, CredentialVaultRef = req.CredentialVaultRef, RemoteFolderPath = req.RemoteFolderPath, FileNamePattern = req.FileNamePattern, PostProcessAction = req.PostProcessAction, ArchiveFolderPath = req.ArchiveFolderPath }; await _bll.SaveAsync(config, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( new { req.IceMapId }, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }