package gateway

import (
	"github.com/acp/interceptor/internal/handlers"
	"github.com/gin-gonic/gin"
)

func registerRoutes(
	r *gin.Engine,
	tool *handlers.ToolHandler,
	insights *handlers.InsightsHandler,
	catalog *handlers.PolicyCatalogHandler,
	approvals *handlers.ApprovalHandler,
	agents *handlers.AgentHandler,
) {
	r.GET("/healthz", func(c *gin.Context) {
		c.JSON(200, gin.H{"status": "ok"})
	})

	r.POST("/tool-call", tool.HandleToolCall)

	api := r.Group("/api/v1")
	{
		api.GET("/events", insights.ListEvents)
		api.GET("/metrics/summary", insights.MetricsSummary)
		api.GET("/policies/catalog", catalog.ListCatalog)

		api.GET("/approvals", approvals.ListApprovals)
		api.GET("/approvals/:trace_id", approvals.GetApproval)
		api.POST("/approvals/:trace_id/approve", approvals.Approve)
		api.POST("/approvals/:trace_id/deny", approvals.Deny)

		api.GET("/agents", agents.ListAgents)
		api.GET("/agents/:agent_id", agents.GetAgent)
		api.POST("/agents", agents.RegisterAgent)
		api.PATCH("/agents/:agent_id", agents.PatchAgent)
	}
}
