using System.Security.Claims;
namespace ZB.MOM.WW.MxGateway.Server.Dashboard;
///
/// Dashboard surface for the destructive session-management actions —
/// Close (graceful shutdown) and Kill (force-terminate) — exposed by the
/// Admin role.
///
///
/// The dashboard binds the destructive Close/Kill UI to this service so
/// the underlying calls flow through
/// a single audited and role-gated entry point. All operations are gated
/// by ; non-Admin callers are rejected with a
/// Succeeded = false result rather than throwing. Missing sessions
/// also surface as so
/// Razor pages can render the message without an error boundary. Each
/// successful call is logged at Information including the acting user
/// (from 's name) and the remote
/// address resolved from .
///
public interface IDashboardSessionAdminService
{
///
/// Returns whether the given principal is authorized to perform
/// destructive session-management actions.
///
///
/// Requires
/// to be true and membership in the
/// role. Pages typically gate the
/// Close/Kill buttons on this value at render time so non-Admin
/// viewers never see them.
///
/// Caller principal.
/// true when the caller may close or kill sessions; otherwise false.
bool CanManage(ClaimsPrincipal user);
///
/// Closes the given session gracefully (worker is given the configured
/// shutdown grace period before being terminated).
///
///
/// Returns
/// when the caller is not Admin, when the session id is blank, or when
/// raises a
/// (including the
///
/// case). Successful closes are audit-logged with the caller name,
/// session id, and remote address.
///
/// Caller principal.
/// Session identifier to close.
/// Cancellation token.
/// Result describing success/failure and a user-facing message.
Task CloseSessionAsync(
ClaimsPrincipal user,
string sessionId,
CancellationToken cancellationToken);
///
/// Force-terminates the worker process backing the given session without
/// attempting a graceful shutdown.
///
///
/// Invoked from the dashboard Kill button. Uses the
/// dashboard-admin-kill reason constant — that string reaches
/// the audit log and the mxgateway.workers.killed metric tag.
/// Returns for
/// non-Admin callers, blank session ids, or any
/// from the underlying
/// manager (the
/// case is recognized and reported as "not found"). Successful kills
/// are audit-logged with the caller name, session id, and remote
/// address.
///
/// Caller principal.
/// Session identifier to kill.
/// Cancellation token.
/// Result describing success/failure and a user-facing message.
Task KillWorkerAsync(
ClaimsPrincipal user,
string sessionId,
CancellationToken cancellationToken);
}