Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
package api
import (
"net/http"
"strings"
"github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/pkg/auth"
)
func (r *Router) registerMonitoringResourceRoutes(
guestMetadataHandler *GuestMetadataHandler,
dockerMetadataHandler *DockerMetadataHandler,
hostMetadataHandler *HostMetadataHandler,
infraUpdateHandlers *UpdateDetectionHandlers,
) {
r.mux.HandleFunc("/api/monitoring/scheduler/health", RequireAuth(r.config, r.handleSchedulerHealth))
r.mux.HandleFunc("/api/storage/", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleStorage)))
r.mux.HandleFunc("/api/storage-charts", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleStorageCharts)))
r.mux.HandleFunc("/api/charts", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleCharts)))
r.mux.HandleFunc("/api/charts/workloads", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleWorkloadCharts)))
r.mux.HandleFunc("/api/charts/infrastructure", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleInfrastructureCharts)))
r.mux.HandleFunc("/api/metrics-store/stats", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleMetricsStoreStats)))
// A history read can wait for inventory or its provider after admission.
// Both entry points retain monitoring-read authority until disclosure;
// the canonical agent lookup must be inside that lifetime too.
r.mux.HandleFunc("/api/metrics-store/history", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.handleMetricsHistory))))
// Batch history can also wait while reading its POST body. Revocation or
// logout during that wait must cover the result and any handler error.
r.mux.HandleFunc("/api/availability-history", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.handleAvailabilityHistory))))
r.mux.HandleFunc("/api/recovery/points", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.recoveryHandlers.HandleListPoints)))
r.mux.HandleFunc("/api/recovery/series", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.recoveryHandlers.HandleListSeries)))
r.mux.HandleFunc("/api/recovery/facets", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.recoveryHandlers.HandleListFacets)))
r.mux.HandleFunc("/api/recovery/rollups", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.recoveryHandlers.HandleListRollups)))
r.mux.HandleFunc("/api/recovery/postures", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.recoveryHandlers.HandleListProtectionPostures)))
r.registerReplicationRoutes()
r.registerPVEBackupsRoutes()
r.registerBackupJobsRoutes()
r.registerPBSBackupsRoutes()
r.registerPMGRoutes()
// Unified query results can wait on inventory or retained evidence after
// admission. Keep the admitted reader through every response (including
// errors), without changing mutation admission or the work's lifetime.
// Unified resources API
r.mux.HandleFunc("/api/resources", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleListResources))))
r.mux.HandleFunc("/api/resources/storage-incidents", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleStorageIncidents))))
r.mux.HandleFunc("/api/resources/storage-summary", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleStorageSummary))))
r.mux.HandleFunc("/api/resources/stats", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleStats))))
r.mux.HandleFunc("/api/resources/k8s/namespaces", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleK8sNamespaces))))
r.mux.HandleFunc("/api/resources/timeline", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleListResourceTimeline))))
r.mux.HandleFunc("/api/resources/{id}/facets", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleGetResourceFacets))))
r.mux.HandleFunc("/api/resources/{id}/timeline", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleGetResourceTimeline))))
// Per-resource operator-set state. GET is read; PUT/DELETE are
// governance-shaping writes (suppress findings, refuse remediation,
// schedule maintenance) so they require the write scope. Method-keyed
// scope wrap mirrors the guests-metadata and docker-metadata pattern
// elsewhere in this file.
r.mux.HandleFunc("/api/resources/{id}/operator-state", RequireAuth(r.config, func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet:
if !ensureScope(w, req, config.ScopeMonitoringRead) {
return
}
r.recordExternalAgentCapabilityActivity(req, agentcapabilities.GetOperatorStateCapabilityName)
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.resourceHandlers.HandleResourceOperatorState)(w, req)
return
case http.MethodPut, http.MethodDelete:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
if req.Method == http.MethodPut {
r.recordExternalAgentCapabilityActivity(req, agentcapabilities.SetOperatorStateCapabilityName)
} else {
r.recordExternalAgentCapabilityActivity(req, agentcapabilities.ClearOperatorStateCapabilityName)
}
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
r.resourceHandlers.HandleResourceOperatorState(w, req)
}))
// Per-resource Maintenance Verification Reports. Listing and reading
// are monitoring-read; rerun is monitoring-write because it produces
// a new persisted record. Review (mark-reviewed) is monitoring-write
// for the same reason. Wired before the broad `/api/resources/`
// catch-all so the more specific paths route here.
if r.maintenanceVerificationHandlers != nil {
r.mux.HandleFunc("/api/resources/{id}/maintenance-verifications", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.maintenanceVerificationHandlers.HandleListForResource))))
r.mux.HandleFunc("POST /api/resources/{id}/maintenance-verifications/rerun", RequireAuth(r.config, RequireScope(config.ScopeMonitoringWrite, r.maintenanceVerificationHandlers.HandleRerun)))
r.mux.HandleFunc("/api/maintenance-verifications/{reportId}", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.maintenanceVerificationHandlers.HandleGet))))
r.mux.HandleFunc("POST /api/maintenance-verifications/{reportId}/review", RequireAuth(r.config, RequireScope(config.ScopeMonitoringWrite, r.maintenanceVerificationHandlers.HandleReview)))
}
// HandleResourceRoutes also dispatches POST link, unlink and report-merge,
// which persist resource identity changes, so anything other than a read
// needs the write scope.
r.mux.HandleFunc("/api/resources/", RequireAuth(r.config, func(w http.ResponseWriter, req *http.Request) {
scope := config.ScopeMonitoringRead
if req.Method != http.MethodGet && req.Method != http.MethodHead {
scope = config.ScopeMonitoringWrite
}
if !ensureScope(w, req, scope) {
return
}
if scope == config.ScopeMonitoringRead {
retainTokenResponseAuthority(r.config, scope, false, r.resourceHandlers.HandleResourceRoutes)(w, req)
return
}
r.resourceHandlers.HandleResourceRoutes(w, req)
}))
// Agent-consumable bundled context — substrate for any LLM agent
// (in-process Patrol/Assistant or external) that needs the full
// situated picture of a resource in one read instead of chaining
// resource + operator-state + findings + audit calls.
r.mux.HandleFunc("/api/agent/resource-context/{id}", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.ResourceContextCapabilityName,
retainAgentCommandResponseAuthority(r.config, r.agentContextHandler.HandleResourceContext),
))))
// Agent-consumable structured capability surface for a single resource.
// Companion to the resource-context bundle above: that renders capabilities
// as count-limited prose facts; this returns the structured list (names +
// parameter schemas) an agent needs to populate plan_action.capabilityName
// and params without guessing.
r.mux.HandleFunc("/api/agent/resource-capabilities/{id}", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.ListResourceCapabilitiesCapabilityName,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.agentContextHandler.HandleResourceCapabilities),
))))
// Agent-consumable fleet triage view — thin per-resource rollups
// across the org so an agent can pick a focus in one read instead
// of walking every resource id and bundling each. Companion to the
// per-resource context endpoint: this is "where do I look?", that
// is "tell me everything about this one."
r.mux.HandleFunc("/api/agent/fleet-context", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.FleetContextCapabilityName,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.agentContextHandler.HandleFleetContext),
))))
// Agent-consumable change history — "what happened?" across the fleet,
// read from the existing resource change store. Companion to the fleet
// triage view above, which answers "where do I look now?".
r.mux.HandleFunc(agentcapabilities.RecentChangesCapabilityPath, RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.ListRecentChangesCapabilityName,
retainAgentCommandResponseAuthority(r.config, r.agentContextHandler.HandleRecentChanges),
))))
// Agent-consumable metric history — "how did it move?" for one resource,
// served by the same history read the charts use.
r.mux.HandleFunc(agentcapabilities.MetricHistoryCapabilityPath, RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.GetMetricHistoryCapabilityName,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.handleAgentMetricHistory),
))))
// Content-safe Patrol control status: the shared Patrol, Assistant,
// governed action, verification, Patrol control proof, and optional MCP
// readiness projection for native UI and external agents.
r.mux.HandleFunc(agentcapabilities.PatrolControlStatusCapabilityPath, RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.PatrolControlStatusCapabilityName,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.agentContextHandler.HandleOperationsLoopStatus),
))))
// Legacy operations-loop route kept for older external-agent clients. New
// clients should discover the Patrol control route from the manifest.
r.mux.HandleFunc(agentcapabilities.OperationsLoopStatusCompatibilityPath, RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.OperationsLoopStatusCapabilityName,
retainTokenResponseAuthority(r.config, config.ScopeMonitoringRead, false, r.agentContextHandler.HandleOperationsLoopStatus),
))))
// Agent capabilities manifest — discovery document. Unauthenticated
// because it only describes the agent surface; the capabilities
// themselves keep their own auth scopes. Agents fetch this once at
// startup to learn what's available.
r.mux.HandleFunc("/api/agent/capabilities", HandleAgentCapabilitiesManifest)
r.mux.HandleFunc("POST /api/agent/workflow-prompt-activity", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.HandleAgentWorkflowPromptActivity)))
r.mux.HandleFunc("POST /api/usage/workload-history", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.HandleWorkloadHistoryActivity)))
// Agent SSE event stream — agents subscribe once and receive
// real-time notifications instead of polling. Auth at
// monitoring:read because the stream surfaces the same
// information already available via the read endpoints.
if r.agentEventBroadcaster != nil {
r.mux.HandleFunc("/api/agent/events", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.withExternalAgentCapabilityActivity(
agentcapabilities.EventSubscriptionCapabilityName,
r.handleAgentEvents,
))))
}
r.mux.HandleFunc("POST /api/actions/plan", RequireAuth(r.config, RequireAnyScope([]string{config.ScopeActionsPlan, config.ScopeAIExecute}, requireActionCapability(r.config, r.authorizer, auth.ActionPlan, r.withExternalAgentCapabilityActivity(
agentcapabilities.PlanActionCapabilityName,
r.resourceHandlers.HandlePlanAction,
)))))
r.mux.HandleFunc("GET /api/actions/pending", RequireAuth(r.config, requireRelayMobileRuntimeRoute(relayMobileRoutePendingActions,
requireActionCapability(r.config, r.authorizer, auth.ActionApprove, r.resourceHandlers.HandleListPendingActions),
)))
r.mux.HandleFunc("GET /api/actions", RequireAuth(r.config, requireRelayMobileRuntimeRoute(relayMobileRouteActionsList,
requireActionCapability(r.config, r.authorizer, auth.ActionApprove, r.resourceHandlers.HandleListActions),
)))
r.mux.HandleFunc("GET /api/actions/{id}", RequireAuth(r.config, requireRelayMobileRuntimeRoute(relayMobileRouteActionDetail,
requireActionCapability(r.config, r.authorizer, auth.ActionApprove, r.resourceHandlers.HandleGetAction),
)))
r.mux.HandleFunc("POST /api/actions/{id}/refresh", RequireAuth(r.config, RequireAnyScope([]string{config.ScopeActionsPlan, config.ScopeAIExecute}, r.withExternalAgentCapabilityActivity(
agentcapabilities.PlanActionCapabilityName,
requireActionCapability(r.config, r.authorizer, auth.ActionPlan, r.resourceHandlers.HandleRefreshAction),
))))
r.mux.HandleFunc("POST /api/actions/{id}/decision", RequireAuth(r.config, requireRelayMobileRuntimeRoute(relayMobileRouteActionDecision, r.withExternalAgentCapabilityActivity(
agentcapabilities.DecideActionCapabilityName,
requireActionCapability(r.config, r.authorizer, auth.ActionApprove, r.resourceHandlers.HandleDecideAction),
))))
r.mux.HandleFunc("POST /api/actions/{id}/execute", RequireAuth(r.config, requireRelayMobileRuntimeRoute(relayMobileRouteActionExecute, r.withExternalAgentCapabilityActivity(
agentcapabilities.ExecuteActionCapabilityName,
requireActionCapability(r.config, r.authorizer, auth.ActionExecute, r.resourceHandlers.HandleExecuteAction),
))))
// Operator override for an action wedged in executing without agent
// completion evidence. It is deliberately not an agent capability and not
// a relay-mobile route: it is a local admin repair, gated harder than
// execute (admin plus settings:write on top of the execute capability)
// because it writes terminal audit truth Pulse could not observe.
r.mux.HandleFunc("POST /api/actions/{id}/force-fail", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite,
requireActionCapability(r.config, r.authorizer, auth.ActionExecute, r.resourceHandlers.HandleForceFailAction),
)))
// Guest metadata routes
r.mux.HandleFunc("/api/guests/metadata", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, guestMetadataHandler.HandleGetMetadata)))
r.mux.HandleFunc("/api/guests/metadata/", RequireAuth(r.config, func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet:
if !ensureScope(w, req, config.ScopeMonitoringRead) {
return
}
guestMetadataHandler.HandleGetMetadata(w, req)
case http.MethodPut, http.MethodPost:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
guestMetadataHandler.HandleUpdateMetadata(w, req)
case http.MethodDelete:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
guestMetadataHandler.HandleDeleteMetadata(w, req)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
}))
// Docker metadata routes
r.mux.HandleFunc("/api/docker/metadata", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, dockerMetadataHandler.HandleGetMetadata)))
r.mux.HandleFunc("/api/docker/metadata/", RequireAuth(r.config, func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet:
if !ensureScope(w, req, config.ScopeMonitoringRead) {
return
}
dockerMetadataHandler.HandleGetMetadata(w, req)
case http.MethodPut, http.MethodPost:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
dockerMetadataHandler.HandleUpdateMetadata(w, req)
case http.MethodDelete:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
dockerMetadataHandler.HandleDeleteMetadata(w, req)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
}))
// Docker runtime metadata routes (for custom display names, URLs, notes).
r.mux.HandleFunc("/api/docker/runtimes/metadata", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, dockerMetadataHandler.HandleGetRuntimeMetadata)))
r.mux.HandleFunc("/api/docker/runtimes/metadata/", RequireAuth(r.config, func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet:
if !ensureScope(w, req, config.ScopeMonitoringRead) {
return
}
dockerMetadataHandler.HandleGetRuntimeMetadata(w, req)
case http.MethodPut, http.MethodPost:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
dockerMetadataHandler.HandleUpdateRuntimeMetadata(w, req)
case http.MethodDelete:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
dockerMetadataHandler.HandleDeleteRuntimeMetadata(w, req)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
}))
// Agent metadata routes (v6 canonical naming).
handleAgentMetadataWriteRoute := func(w http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet:
if !ensureScope(w, req, config.ScopeMonitoringRead) {
return
}
hostMetadataHandler.HandleGetMetadata(w, req)
case http.MethodPut, http.MethodPost:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
hostMetadataHandler.HandleUpdateMetadata(w, req)
case http.MethodDelete:
if !ensureScope(w, req, config.ScopeMonitoringWrite) {
return
}
hostMetadataHandler.HandleDeleteMetadata(w, req)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
}
r.mux.HandleFunc("/api/agents/metadata", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, hostMetadataHandler.HandleGetMetadata)))
r.mux.HandleFunc("/api/agents/metadata/", RequireAuth(r.config, handleAgentMetadataWriteRoute))
// Infrastructure update detection routes (Docker containers, packages, etc.)
r.mux.HandleFunc("/api/infra-updates", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, infraUpdateHandlers.HandleGetInfraUpdates)))
r.mux.HandleFunc("/api/infra-updates/summary", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, infraUpdateHandlers.HandleGetInfraUpdatesSummary)))
r.mux.HandleFunc("/api/infra-updates/check", RequireAuth(r.config, RequireScope(config.ScopeMonitoringWrite, infraUpdateHandlers.HandleTriggerInfraUpdateCheck)))
r.mux.HandleFunc("/api/infra-updates/agent/", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, func(w http.ResponseWriter, req *http.Request) {
// Extract agent ID from path: /api/infra-updates/agent/{agentId}
agentID := strings.TrimPrefix(req.URL.Path, "/api/infra-updates/agent/")
agentID = strings.TrimSuffix(agentID, "/")
if agentID == "" {
writeErrorResponse(w, http.StatusBadRequest, "missing_agent_id", "Agent ID is required", nil)
return
}
infraUpdateHandlers.HandleGetInfraUpdatesForAgent(w, req, agentID)
})))
r.mux.HandleFunc("/api/infra-updates/", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, func(w http.ResponseWriter, req *http.Request) {
// Extract resource ID from path: /api/infra-updates/{resourceId}
resourceID := strings.TrimPrefix(req.URL.Path, "/api/infra-updates/")
resourceID = strings.TrimSuffix(resourceID, "/")
if resourceID == "" || resourceID == "summary" || resourceID == "check" || strings.HasPrefix(resourceID, "agent/") {
// Let specific handlers deal with these
http.NotFound(w, req)
return
}
infraUpdateHandlers.HandleGetInfraUpdateForResource(w, req, resourceID)
})))
r.mux.HandleFunc("/api/discover", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, r.withExternalAgentCapabilityActivity(
agentcapabilities.DiscoverLANCapabilityName,
r.configHandlers.HandleDiscoverServers,
))))
// Alert routes enforce read/write scopes inside HandleAlerts per endpoint method.
r.mux.HandleFunc("/api/alerts/", RequireAuth(r.config, r.alertHandlers.HandleAlerts))
// Notification routes
r.mux.HandleFunc("/api/notifications/", RequireAdmin(r.config, r.notificationHandlers.HandleNotifications))
// Notification queue/DLQ routes
// Security tokens are handled later in the setup with RBAC
// SECURITY: DLQ endpoints require settings:read/write scope because DLQ entries may contain
// notification configs with webhook URLs, SMTP credentials, or other sensitive data
r.mux.HandleFunc("/api/notifications/dlq", RequireAdmin(r.config, RequireScope(config.ScopeSettingsRead, func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodGet {
r.notificationQueueHandlers.GetDLQ(w, req)
} else {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})))
r.mux.HandleFunc("/api/notifications/queue/stats", RequireAdmin(r.config, RequireScope(config.ScopeSettingsRead, func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodGet {
r.notificationQueueHandlers.GetQueueStats(w, req)
} else {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})))
r.mux.HandleFunc("/api/notifications/dlq/retry", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodPost {
r.notificationQueueHandlers.RetryDLQItem(w, req)
} else {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})))
r.mux.HandleFunc("/api/notifications/dlq/delete", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodPost || req.Method == http.MethodDelete {
r.notificationQueueHandlers.DeleteDLQItem(w, req)
} else {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})))
r.mux.HandleFunc("/api/notifications/terminal-failures/retry", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodPost {
r.notificationQueueHandlers.RetryTerminalFailures(w, req)
} else {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})))
r.mux.HandleFunc("/api/notifications/terminal-failures/dismiss", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodPost {
r.notificationQueueHandlers.DismissTerminalFailures(w, req)
} else {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})))
}