"""What the queue's endpoints accept and promise back. Job-shaped, so they live with the router that serves them rather than in an app's schema module. The `Job`, `JobsSnapshot` and `Schedule` they sit alongside are in `pipeline/models.py`; these are only ever request bodies, or a stored shape with one derived field added for the client. """ from __future__ import annotations from typing import Any from pydantic import BaseModel from pipeline.models import Schedule class EnqueueBody(BaseModel): """Start a job. `payload` is spread over the handler's keyword arguments, so what a kind accepts is the signature of its function and nothing else has to restate it.""" kind: str payload: dict[str, Any] = {} class JobKind(BaseModel): """One entry from the job registry, for a UI that wants to offer them.""" kind: str label: str solo: bool class NewSchedule(BaseModel): """Add a schedule. `name` is optional because the kind is usually answer enough — one `tick` schedule wants no name of its own, and the second is named by counting rather than by making somebody think of one.""" kind: str cadence: str name: str = "" label: str = "" payload: dict[str, Any] = {} enabled: bool = True class ScheduleEdit(BaseModel): """Change part of a schedule. Every field optional, and read with `exclude_unset`, so sending `{"enabled": false}` switches one off without also resubmitting a cadence somebody edited in another tab a second ago. `name` is not here: it is the handle a declared default is matched on, and renaming a row would hand its edits to a fresh one inserted under the old name on the next start. """ kind: str | None = None label: str | None = None cadence: str | None = None payload: dict[str, Any] | None = None enabled: bool | None = None class ScheduleRow(Schedule): """A schedule as it is served: the row, plus whether anything still runs it. `unknown` is not stored, because it is a fact about the code that is loaded rather than about the row — a handler removed in a deploy makes it true without the table changing, and reinstalling the plugin makes it false again. The element greys such a row and says `unknown kind`; the queue never fires one. """ unknown: bool = False