Files
llmgw/internal/control/adminapi/replies.go
T
Ilker ManapandClaude Opus 5.5 a95c519bc5 The admin API described in OpenAPI 3.1: generated from a route table by docgen, served at /api/v1/openapi.json
adminapi.Routes lists every endpoint with its query parameters and Go values
of the bodies it reads and answers with; internal/docgen/openapi turns that
into docs/admin-api.openapi.json by reflection, the way encoding/json encodes
the types, with the fields' comments as descriptions. A test fails when an
endpoint is registered and not in the table, another when the committed
document is stale. The binary embeds it and serves it with the token.

Handlers that wrote map literals and decoded anonymous structs now use named
types, so the document can see them. GET /api/v1/models/{name} answers with a
model's whole definition as it is in force, which a tool managing it needs.
docs/admin-api.md: reaching the API, the token, what a request must carry.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 23:47:59 +02:00

85 lines
2.3 KiB
Go

package adminapi
// The small bodies the endpoints read and answer with. Named types rather
// than maps and anonymous structs, so the OpenAPI document generated from
// Routes describes exactly what a handler decodes and writes: a map literal
// in a handler is a shape no generator can see.
// ErrorView is every refusal: a 4xx or 5xx status with what went wrong.
type ErrorView struct {
Error string `json:"error"`
}
// Result is what a change that has no other answer says it did.
type Result struct {
Result string `json:"result"`
}
// ModelAdded names the model added to the catalog.
type ModelAdded struct {
Added string `json:"added"`
}
// Removed names what was taken away: a model, or a quota's scope.
type Removed struct {
Removed string `json:"removed"`
}
// ClassRequest sets a model's capacity class: critical, standard or
// opportunistic, or empty to go back to what its scaling implies.
type ClassRequest struct {
Class string `json:"class"`
}
// ClassView is a model's capacity class now.
type ClassView struct {
Model string `json:"model"`
Class string `json:"class"`
}
// RetryView says whether the model had been parked, given up on after
// failing to start, before it was retried.
type RetryView struct {
WasParked bool `json:"was_parked"`
}
// NodeStateRequest cordons, drains or readies a node: ready (or uncordon),
// cordoned (or cordon), draining (or drain).
type NodeStateRequest struct {
State string `json:"state"`
}
// NodeStateView is a node's state after the change.
type NodeStateView struct {
ID string `json:"id"`
State string `json:"state"`
}
// NodeRemoved names the node forgotten. Removed is the string "true".
type NodeRemoved struct {
ID string `json:"id"`
Removed string `json:"removed"`
}
// UpgradeView is the release a node was told to run.
type UpgradeView struct {
Node string `json:"node"`
Version string `json:"version"`
}
// FabricTestRequest is a bandwidth test between two nodes.
type FabricTestRequest struct {
A string `json:"a"`
B string `json:"b"`
// Fabric is the declared fabric to test over; empty is the one the two
// nodes share.
Fabric string `json:"fabric,omitempty"`
// Seconds each rail is measured for, from 1 to 30.
Seconds int `json:"seconds,omitempty"`
}
// ReplayRequest names the model a kept request is sent to again.
type ReplayRequest struct {
Model string `json:"model"`
}