namespace Chronos.Protocol;
///
/// GET/PUT /api/v1/server/settings (admin): the editable part of the server configuration. Settings named in
/// come from environment variables and cannot be changed here; names the
/// variable that fixes each of them (ignored when saving); says
/// that saved values (ports, TLS, chunk size) wait for a restart; is what the housekeeping
/// schedule is reset to (owner review 2, R10). is set in responses when TLS mode is proxy and
/// the request did not come through a trusted proxy over HTTPS (ignored when saving).
/// is how many photos the running job processes at once (jobs run one at a time), and
/// with the priority queue (owner review 1); both apply at once, as
/// do (owner review 2, R11; a request without them keeps them as they are).
/// and (owner review 3) are the ports clients reach the server
/// on when the host publishes the listening ports as others (a container): null in a response when they are the
/// listening ports; in a request, null keeps them as they are (a client that predates them) and 0 clears them. They
/// apply at once (LAN discovery, the admin panel's HTTPS redirect). (responses only) says the
/// server runs in a container, whose listening ports the template fixes: they are then locked, named in
/// with the variable DOTNET_RUNNING_IN_CONTAINER unless one of their own fixes them. The
/// members added since are last and optional, so clients and panels of the shape before them keep working.
///
public sealed record ServerSettingsDto(
string ServerName,
int HttpPort,
int HttpsPort,
string TlsMode,
string? TlsCert,
string? TlsKey,
string Language,
int Parallelism,
bool PriorityQueue,
IReadOnlyList JobPriorities,
bool Discovery,
long MaxUploadBytes,
int ChunkSizeBytes,
int JobHistoryDays,
int TokenLifetimeDays,
int UploadRetentionHours,
LogSettingsDto Logs,
IReadOnlyList Locked,
IReadOnlyDictionary LockedBy,
bool RestartRequired,
bool ProxyWarning,
int? PublicHttpPort = null,
int? PublicHttpsPort = null,
bool InContainer = false);
///
/// The log settings of (owner review 2, R11): the least severe level of the files and of the
/// console (trace, debug, information, warning, error, critical, none), the
/// days log files are kept, the size at which a file continues in a numbered one and the size of all of them (MB of 2²⁰
/// bytes, 0 = no limit), the rotation (daily or hourly, UTC), the days audit entries are kept (the audit
/// clean-up schedule's age limit; 0 = forever, as while that schedule is off) and the MB of the end of each log file in
/// the diagnostics zip. Their locks use the server.json names (LogLevel, ConsoleLogLevel,
/// LogRetentionDays, LogMaxFileMb, LogMaxTotalMb, LogRotation, AuditRetentionDays,
/// DiagnosticsLogMb).
///
public sealed record LogSettingsDto(
string FileLevel,
string ConsoleLevel,
int RetentionDays,
int MaxFileMb,
int MaxTotalMb,
string Rotation,
int AuditRetentionDays,
int DiagnosticsLogMb);
/// A kind of job (render) and its level in the server's priority queue: high, normal or low.
public sealed record JobPriorityDto(string Kind, string Level);
/// A server log file (GET /api/v1/logs/files).
public sealed record LogFileDto(string Name, long Size, DateTimeOffset Modified);
/// The last lines of the current server log (GET /api/v1/logs).
public sealed record LogTailDto(string File, IReadOnlyList Lines);
/// Jobs per state; done and failed count today's (UTC) jobs.
public sealed record JobCountsDto(int Queued, int Running, int Paused, int DoneToday, int FailedToday);
/// Frames committed by uploads on one UTC day.
public sealed record UploadDayDto(DateOnly Day, long Frames, long Bytes);
///
/// GET /api/v1/server/dashboard (admin): everything the dashboard page shows in one call (BRIEF §14.8).
/// : TLS mode is proxy and this request did not come through a trusted proxy over HTTPS.
///
public sealed record DashboardDto(
string ServerName,
string Version,
long UptimeSeconds,
string Database,
string TlsMode,
bool Discovery,
int Users,
ArchiveStatsDto Archive,
JobCountsDto Jobs,
int Parallelism,
bool PriorityQueue,
IReadOnlyList Nodes,
IReadOnlyList Uploads,
IReadOnlyList Activity,
IReadOnlyList ActiveJobs,
bool ProxyWarning);