defmodule SyntropyWeb.Router do use SyntropyWeb, :router pipeline :api_read do plug :accepts, ["json"] plug SyntropyWeb.Plugs.RateLimiter, class: :read plug SyntropyWeb.Plugs.ApiAuth, scope: :read end pipeline :api_write do plug :accepts, ["json"] plug SyntropyWeb.Plugs.RateLimiter, class: :write plug SyntropyWeb.Plugs.ApiAuth, scope: :write end pipeline :api_admin do plug :accepts, ["json"] plug SyntropyWeb.Plugs.RateLimiter, class: :write plug SyntropyWeb.Plugs.ApiAuth, scope: :admin end pipeline :api_public do plug :accepts, ["json"] end # Open wherever token auth is disabled (dev/test); in prod ApiAuth is # required, so scraping needs a bearer token with at least read scope # (SYNTROPY_API_TOKEN or a scoped API token). pipeline :metrics do plug SyntropyWeb.Plugs.ApiAuth, scope: :read end scope "/api", SyntropyWeb.Api, as: :api do pipe_through :api_public get "/health", StatusController, :health get "/ready", StatusController, :ready end scope "/", SyntropyWeb do pipe_through :metrics get "/metrics", MetricsController, :index end scope "/api", SyntropyWeb.Api, as: :api do pipe_through :api_read get "/cluster", ClusterController, :show get "/runtime-config", RuntimeConfigController, :show get "/retention", RetentionController, :show get "/usage", UsageController, :show get "/agents", AgentController, :index get "/agents/:id", AgentController, :show get "/graph", GraphController, :show get "/perspectives", PerspectiveController, :index get "/tasks", TaskController, :index get "/tasks/:id", TaskController, :show get "/runs", RunController, :index get "/runs/:id", RunController, :show get "/history", HistoryController, :index get "/history/:id", HistoryController, :show get "/recommendations", RecommendationController, :index get "/recommendations/:id", RecommendationController, :show get "/events", EventController, :index get "/webhooks", WebhookController, :index end scope "/api", SyntropyWeb.Api, as: :api do pipe_through :api_write post "/agents", AgentController, :create delete "/agents/:id", AgentController, :delete post "/tasks", TaskController, :create post "/runs", RunController, :create post "/runs/:id/cancel", RunController, :cancel post "/recommendations/:id/approve", RecommendationController, :approve post "/recommendations/:id/reject", RecommendationController, :reject post "/webhooks", WebhookController, :create patch "/webhooks/:id", WebhookController, :update delete "/webhooks/:id", WebhookController, :delete end scope "/api", SyntropyWeb.Api, as: :api do pipe_through :api_admin put "/runtime-config/provider", RuntimeConfigController, :update_provider post "/runtime-config/provider/test", RuntimeConfigController, :test_provider put "/runtime-config/limits", RuntimeConfigController, :update_limits put "/retention", RetentionController, :update get "/tokens", TokenController, :index post "/tokens", TokenController, :create delete "/tokens/:id", TokenController, :delete end end