Documentation
¶
Overview ¶
Package api implements beacon's REST configuration API: a huma-on-chi HTTP interface for CRUD over sources, sinks, and connectors. internal/app mounts the handler this package returns under the admin server's /api/ prefix. Every write goes through internal/config.Service, so the same structural + CEL validation and hot-apply reconcile that already governs the CLI (Phase 4) and internal/config's own tests governs the HTTP surface too — this package is a thin, typed HTTP skin over Service, not a second place business rules live.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(svc *config.Service, reg *stats.Registry, version string, log *slog.Logger, runtimeInfo ...RuntimeInfo) (http.Handler, huma.API)
New builds beacon's config REST API: a chi router with huma registered on it. Every operation is registered with its full "/api/v1/..." path (rather than relying on router-mount prefix stripping), so the returned handler can be mounted directly on a stdlib http.ServeMux via mux.Handle("/api/", handler) and still see the paths it registered.
reg backs the live-metrics endpoints (get-connector-metrics, list-metrics); it is unused by the entity CRUD endpoints.
version is embedded as the OpenAPI document's info.version and returned verbatim by GET /api/v1/system.
log receives the underlying error whenever a handler is about to answer 500 (the client only ever sees a sanitized "internal error" body); nil defaults to slog.Default(), the same convention as config.NewService.
Types ¶
type RuntimeInfo ¶
type RuntimeInfo struct {
Identity identity.Appliance
Devices func() []bus.DeviceInfo
Buses func() []bus.EndpointStatus
Inventory *inventory.Registry
Statuses func() []supervisor.Status
}
type StatusBody ¶
type StatusBody struct {
Status []supervisor.Status `json:"status" doc:"Supervisor statuses for the affected entity (filtered to its id)."`
}
StatusBody is the response body for every write endpoint (PUT, DELETE): the subset of the supervisor's live component statuses that pertain to the entity just written, letting a caller see the effect of a hot apply without a second round trip to a statuses endpoint.