--------------------------------------------------------------------------- Handlers --------------------------------------------------------------------------- InitiateListModels creates a pending model list request for a runtime. Called by the frontend; the daemon picks it up on its next heartbeat
(w http.ResponseWriter, r *http.Request)
| 286 | // InitiateListModels creates a pending model list request for a runtime. |
| 287 | // Called by the frontend; the daemon picks it up on its next heartbeat. |
| 288 | func (h *Handler) InitiateListModels(w http.ResponseWriter, r *http.Request) { |
| 289 | runtimeID := chi.URLParam(r, "runtimeId") |
| 290 | runtimeUUID, ok := parseUUIDOrBadRequest(w, runtimeID, "runtime_id") |
| 291 | if !ok { |
| 292 | return |
| 293 | } |
| 294 | |
| 295 | rt, err := h.Queries.GetAgentRuntime(r.Context(), runtimeUUID) |
| 296 | if err != nil { |
| 297 | writeError(w, http.StatusNotFound, "runtime not found") |
| 298 | return |
| 299 | } |
| 300 | if _, ok := h.requireWorkspaceMember(w, r, uuidToString(rt.WorkspaceID), "runtime not found"); !ok { |
| 301 | return |
| 302 | } |
| 303 | if rt.Status != "online" { |
| 304 | writeError(w, http.StatusServiceUnavailable, "runtime is offline") |
| 305 | return |
| 306 | } |
| 307 | |
| 308 | req, err := h.ModelListStore.Create(r.Context(), uuidToString(rt.ID)) |
| 309 | if err != nil { |
| 310 | writeError(w, http.StatusInternalServerError, "failed to enqueue model list request: "+err.Error()) |
| 311 | return |
| 312 | } |
| 313 | writeJSON(w, http.StatusOK, req) |
| 314 | } |
| 315 | |
| 316 | // GetModelListRequest returns the status of a model list request. |
| 317 | func (h *Handler) GetModelListRequest(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected