RefreshDocker handles POST /hosts/:hostId/refresh-docker.
(w http.ResponseWriter, r *http.Request)
| 581 | |
| 582 | // RefreshDocker handles POST /hosts/:hostId/refresh-docker. |
| 583 | func (h *HostsHandler) RefreshDocker(w http.ResponseWriter, r *http.Request) { |
| 584 | if h.queueClient == nil { |
| 585 | Error(w, http.StatusServiceUnavailable, "Queue service unavailable") |
| 586 | return |
| 587 | } |
| 588 | hostID := chi.URLParam(r, "hostId") |
| 589 | host, err := h.hosts.GetByID(r.Context(), hostID) |
| 590 | if err != nil || host == nil { |
| 591 | Error(w, http.StatusNotFound, "Host not found") |
| 592 | return |
| 593 | } |
| 594 | task, err := queue.NewDockerInventoryRefreshTask(host.ApiID, hostFromRequest(r)) |
| 595 | if err != nil { |
| 596 | Error(w, http.StatusInternalServerError, "Failed to create Docker refresh task") |
| 597 | return |
| 598 | } |
| 599 | info, err := h.queueClient.Enqueue(task) |
| 600 | if err != nil { |
| 601 | Error(w, http.StatusInternalServerError, "Failed to refresh Docker inventory") |
| 602 | return |
| 603 | } |
| 604 | JSON(w, http.StatusOK, map[string]interface{}{ |
| 605 | "success": true, |
| 606 | "message": "Docker inventory refresh queued", |
| 607 | "jobId": info.ID, |
| 608 | "host": map[string]interface{}{ |
| 609 | "id": host.ID, |
| 610 | "friendlyName": host.FriendlyName, |
| 611 | "apiId": host.ApiID, |
| 612 | }, |
| 613 | }) |
| 614 | } |
| 615 | |
| 616 | // ForceAgentUpdate handles POST /hosts/:hostId/force-agent-update. |
| 617 | func (h *HostsHandler) ForceAgentUpdate(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected