Skip to main content

Module api

Module api 

Source
Expand description

The HTTP surface, built by folding over the declared operations.

§The router is the declaration

Nothing here writes a route out. router walks OPERATIONS and registers one route per entry beneath the one versioned prefix, so the set served and the set declared cannot come apart — and the ten mutating operations share one handler which is given the ActionKind its own entry declares, so a request cannot reach an action the operation it was sent to does not name. The five spool commands share one handler of their own on the same terms.

§Every action takes the same one path

An action asked for here goes to Supervisor::request_action, which is the same call an operator’s action makes and an agent’s action makes. The policy is not re-implemented here and is not bypassed here: a rejected request answers the rejection the policy made, carrying its reason, the value asked for and the range allowed, and reaches no action method of the printer port at all.

§Nothing is served to a caller that did not present a credential

Every route beneath the versioned prefix — and the prefix’s own fallback, so that a path nothing serves is refused the same way — sits behind authenticate, which runs before any extractor reads a path, a query or a body. A request whose Authorization header is not exactly Bearer <credential>, for the operator’s credential or a live supervision turn’s, is answered 401 there, so it reaches no handler, no store, no printer port and no record. There is no route that skips it and no configuration that turns it off: ApiState cannot be built without what a credential is checked against.

§Every request is the identity its credential authenticated

What authenticate admitted is a Caller: the operator, or one turn — the agent, in one session, on one print. Every handler is given it, and the body’s actor is a claim held to it before the policy is asked anything: a claim that is not the caller — an operator credential claiming to be the agent, a turn claiming to be the operator or another session, and anybody claiming to be the system, whose actions are the server’s own — is refused 403 naming both, and nothing is decided or recorded. A turn’s credential reaches its own print alone, the listing of prints beside it, and neither of the two writes that are not about a running print: starting one and replacing a manifest. So the class the policy rules on, and the agent’s minimum interval with it, is the one the credential authenticated rather than the one the request claimed.

The spool ledger is the printer’s rather than one print’s, so its four reads are open to every caller — a turn included, which is how the agent reads what is loaded and what a file needs — and its commands are held to the same claim and then to the envelope’s own grants, which the domain rules on and records.

The recovery operations are the printer’s too: their read is open to every caller, answering what each action would meet for that caller, and each action is held to the same claim and then to the recovery grants and the machine’s own state, which the domain rules on and records.

Structs§

Admission
What authenticate checks a presented credential against.
ApiState
What every handler is given: the supervisor, and the stores the reads answer out of — the four aggregates a route reads, and not the actions, which reach the store through the supervisor alone.
HistoryParams
How many events a history read asks for, when it asks for a number.
LookParams
How long a look asks to wait for something to arrive, in whole seconds.
PreflightParams
The file a filament check is about.
SpoolsParams
Whether a spools read asks for the retired ones too.

Enums§

Caller
Who one request authenticated as.

Constants§

BODY_BOUND
How much of a request’s body this server reads, admitted or refused.
DRAIN_BOUND
How long authenticate waits for a refused request’s body to arrive.
SPOOL_RECENT_EVENTS
How many of a spool’s own events its read carries, newest first.

Functions§

authenticate
Admit a request that presented the operator’s credential or a live turn’s, hand every handler who it authenticated as, and refuse every other request before anything reads it.
router
Every public operation, beneath the one versioned prefix.