namespace Chronos.Protocol;
///
/// The parameters of a schedule's action (owner review 2, R10), flat: each action reads its own fields, the others stay
/// null (and are not stored). scan: (full scan), (background deep analysis of
/// what it indexes). verify: (only sequences not verified for that many days; 0: any),
/// (share of the archive's sequences per run, least recently verified first). thumbnails,
/// proxies: (make again those already made). analysis: (deep instead of
/// light). maintenance: . backup: (copies kept). cleanup:
/// (step names) and (what is older goes; 0 keeps everything).
/// duplicates, orphans: none.
///
public sealed record ScheduleParametersDto(
int? OlderThanDays = null,
int? Percent = null,
bool? Deep = null,
bool? DryRun = null,
bool? Force = null,
IReadOnlyList? Steps = null,
int? Keep = null);
///
/// When a schedule fires, structured. = every ( and :
/// minutes, hours or days; at least 5 minutes), daily (), weekly
/// (: mon … sun; ) or monthly ( 1–28;
/// ). is HH:MM, wall-clock time of the host's time zone.
///
public sealed record RecurrenceDto(
string Kind,
int? Every = null,
string? Unit = null,
string? Time = null,
IReadOnlyList? Days = null,
int? DayOfMonth = null);
///
/// A schedule (owner review 2, R10). is set on the host's system schedules (the timers it runs,
/// shown so nothing runs out of sight): they can be edited, disabled and reset, never deleted. is the
/// priority of the jobs it queues (background, normal, user). :
/// queued, skipped-pending, skipped-offline, skipped-nothing, unavailable or
/// failed:<reason>. is null while the schedule is disabled.
///
public sealed record ScheduleDto(
Guid Id,
string? SystemKey,
string Name,
string Action,
string Target,
ScheduleParametersDto Parameters,
RecurrenceDto Recurrence,
bool CatchUp,
string Priority,
bool Enabled,
DateTimeOffset? NextRun,
DateTimeOffset? LastRun,
Guid? LastJobId,
string? LastOutcome,
Guid? CreatedBy,
DateTimeOffset Created,
DateTimeOffset Updated);
/// An action a schedule can take and whether this host runs it; says why not (a code: no-handler, postgres, proxies-disabled…).
public sealed record ScheduleActionDto(string Name, bool Available, string? Reason);
///
/// GET /api/v1/schedules: the schedules, system ones first, the actions with their availability, the host's time
/// zone (IANA or Windows id, as the host names it) and the clean-up steps its cleanup action runs.
///
public sealed record SchedulesDto(IReadOnlyList Items, IReadOnlyList Actions, string TimeZone,
IReadOnlyList? Steps = null);
/// POST /api/v1/schedules: a new schedule; defaults to current, to background.
public sealed record CreateScheduleRequest(
string Name,
string Action,
RecurrenceDto Recurrence,
ScheduleParametersDto? Parameters = null,
bool CatchUp = true,
string? Priority = null,
bool Enabled = true,
string? Target = null);
///
/// PATCH /api/v1/schedules/{id}: the fields given replace the stored ones ( as a whole). A
/// system schedule keeps its name and action.
///
public sealed record UpdateScheduleRequest(
string? Name = null,
string? Action = null,
RecurrenceDto? Recurrence = null,
ScheduleParametersDto? Parameters = null,
bool? CatchUp = null,
string? Priority = null,
bool? Enabled = null);
/// POST /api/v1/schedules/{id}/run: what running the schedule now did, and the schedule afterwards.
public sealed record ScheduleRunDto(ScheduleDto Schedule, string Outcome, Guid? JobId);