// Code generated by ogen, DO NOT EDIT. package api import ( "context" ) // Handler handles operations described by OpenAPI v3 specification. type Handler interface { // CheckLab implements CheckLab operation. // // The checker of the template connects from the host side of the lab management bridge to the nodes // (SSH or the RouterOS API) and evaluates the criteria of the variant that the seed selected. It only // reads the node state and never changes it, so a repeated call is harmless; the result is not stored // by `labd`. The call is synchronous and bounded by the check timeout of the provisioner. // // The result is checker state for the backend only: the backend scores the lab answer with it and // never forwards it to the candidate. // // A lab that is not `ready` answers 409 `state_conflict`. When the checker cannot reach a node or the // template has no working checker, the provisioner answers 503 `lab_unavailable`: nothing was // evaluated, and the outcome is never a failed check. // // POST /v1/labs/{lab_id}/check CheckLab(ctx context.Context, params CheckLabParams) (*LabCheckResult, error) // CreateLab implements CreateLab operation. // // Idempotent by `lab_id`: // // - a new ID that fits the capacity reserves it, stores the lab, and answers 202 with // `state: provisioning`; the nodes are cloned and booted in the background; // - the same ID with the same payload answers 200 with the current state of that lab, including // `deleted` or `failed`, and never creates a second one; // - the same ID with a different payload answers 422 `idempotency_key_reused` and changes nothing; // - a new ID that does not fit the memory budget or the lab limit, or arrives while the provisioner // is draining, answers 503 `lab_pool_busy` with Retry-After; nothing is stored, so the caller // retries with the same ID. // // Payloads are compared by a SHA-256 fingerprint of the decoded request. An unknown template or // template version, or a lifetime above the configured maximum, answers 400 `validation_failed` with a // pointer such as `/template_id` or `/ttl_seconds`. // // The lab is deleted at `expires_at` = creation time + `ttl_seconds`, also when it is still // provisioning. A lab that fails to provision or does not answer within the provisioning timeout // becomes `failed` and its resources are deleted; its capacity returns when they are gone. // // A record of a deleted or failed lab is kept for a bounded retention time; after it, the ID is // unknown again and a CreateLab with it starts a new lab. // // PUT /v1/labs/{lab_id} CreateLab(ctx context.Context, req *LabCreateRequest, params CreateLabParams) (CreateLabRes, error) // CreateLabConsoleToken implements CreateLabConsoleToken operation. // // The token lets the console gateway of the backend attach to the serial console of one node. It is // random, single-use, bound to the lab and the node, and valid for at most 120 seconds; `labd` keeps // only its SHA-256 digest in memory, so a restart invalidates every unused token. The token is never a // node password or an SSH key, and the response carries no node address. // // Attaching: the gateway opens a WebSocket to `attach_path` on the same `labd` origin with the service // bearer token and sends the console token in the `X-Lab-Console-Token` header. The WebSocket attach // is described here as the planned interface; until it is implemented, `labd` answers the attach path // with 501 and issuing a token changes nothing else. // // A lab that is not `ready` answers 409 `state_conflict`; an unknown node answers 400 // `validation_failed` with the pointer `/node`. // // POST /v1/labs/{lab_id}/console-tokens CreateLabConsoleToken(ctx context.Context, req *ConsoleTokenRequest, params CreateLabConsoleTokenParams) (*ConsoleTokenHeaders, error) // DeleteLab implements DeleteLab operation. // // Marks the lab for deletion and answers 202 with `state: deleting`; the provisioner removes its // instances and bridges in the background and retries until LXD confirms that they are gone, also // across its own restarts. Deleting a lab that is already `deleting` or `deleted` answers 200 with its // state and changes nothing. An unknown ID answers 404 `not_found`. // // DELETE /v1/labs/{lab_id} DeleteLab(ctx context.Context, params DeleteLabParams) (DeleteLabRes, error) // GetLab implements GetLab operation. // // Answers 404 `not_found` for an ID the provisioner does not hold, including a lab whose `deleted` // record outlived its retention time. The response never contains an address, a key, or an LXD object // name. // // GET /v1/labs/{lab_id} GetLab(ctx context.Context, params GetLabParams) (*LabStatus, error) // GetLabdHealthz implements GetLabdHealthz operation. // // Check whether the lab provisioner process is responding. // // GET /healthz GetLabdHealthz(ctx context.Context) (*LabdHealthResponse, error) // GetLabdReadyz implements GetLabdReadyz operation. // // Ready means that the lab records were loaded, the startup reconciliation with LXD finished, the LXD // API answered the latest probe, and the process is not draining. A provisioner without free capacity // is still ready; capacity is reported by CreateLab. // // GET /readyz GetLabdReadyz(ctx context.Context) (GetLabdReadyzRes, error) // NewError creates *ProblemStatusCode from error returned by handler. // // Used for common default response. NewError(ctx context.Context, err error) *ProblemStatusCode } // Server implements http server based on OpenAPI v3 specification and // calls Handler to handle requests. type Server struct { h Handler sec SecurityHandler baseServer } // NewServer creates new Server. func NewServer(h Handler, sec SecurityHandler, opts ...ServerOption) (*Server, error) { s, err := newServerConfig(opts...).baseServer() if err != nil { return nil, err } return &Server{ h: h, sec: sec, baseServer: s, }, nil }