using EntitlementBLL.Handlers; using FastEndpoints; using GB5Shared.Authorization; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EntitlementSL.Endpoints.Scheduler; // Internal system job, dispatched by GB5Framework's Track A scheduler (MJOBDEFINE/TSCHEDULER, // tracker §45) — replaces the standalone in-memory Quartz job of the same name that used to run // every 10 minutes inside EntitlementSL's own process. Gated the same way every other internal // GOODBOOKS_ADMIN-only action in this module is (Thread 0 §20's [MenuRights] convention) rather // than a JWT role — Track A calls this over plain HTTP with a Login header, never a JWT. [MenuRights("entkillsw", RightOperation.Update)] public class RunKillSwitchMonitor : BaseEndpoint> { private readonly ISchedulerTasksBLL _SchedulerTasksBLL; public RunKillSwitchMonitor(ISchedulerTasksBLL schedulerTasksBLL) => _SchedulerTasksBLL = schedulerTasksBLL; public override void Configure() { Get("/Entitlement/Scheduler/RunKillSwitchMonitor"); AllowAnonymous(); } public record Params([property: FromHeader] string Login); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO loginDTO, CancellationToken ct) { await _SchedulerTasksBLL.RunKillSwitchMonitorAsync(ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( "KillSwitchMonitor run completed.", CacheKeyLevel.NOT_REQUIRED, loginDTO); } }