MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / FetchReport

Method FetchReport

server-source-code/internal/handler/hosts.go:476–500  ·  view source on GitHub ↗

FetchReport handles POST /hosts/:hostId/fetch-report.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

474
475// FetchReport handles POST /hosts/:hostId/fetch-report.
476func (h *HostsHandler) FetchReport(w http.ResponseWriter, r *http.Request) {
477 if h.queueClient == nil {
478 Error(w, http.StatusServiceUnavailable, "Queue service unavailable")
479 return
480 }
481 hostID := chi.URLParam(r, "hostId")
482 host, err := h.hosts.GetByID(r.Context(), hostID)
483 if err != nil || host == nil {
484 Error(w, http.StatusNotFound, "Host not found")
485 return
486 }
487 task, err := queue.NewReportNowTask(host.ApiID, hostFromRequest(r))
488 if err != nil {
489 Error(w, http.StatusInternalServerError, "Failed to create fetch report task")
490 return
491 }
492 if _, err := h.queueClient.Enqueue(task); err != nil {
493 Error(w, http.StatusInternalServerError, "Failed to enqueue fetch report")
494 return
495 }
496 JSON(w, http.StatusOK, map[string]interface{}{
497 "message": "Fetch report requested",
498 "success": true,
499 })
500}
501
502// FetchReportBulk handles POST /hosts/bulk/fetch-report.
503func (h *HostsHandler) FetchReportBulk(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 4

ErrorFunction · 0.85
hostFromRequestFunction · 0.85
JSONFunction · 0.70
GetByIDMethod · 0.45

Tested by

no test coverage detected