//! REST API routes //! //! Provides endpoints for: //! - Agent management (registration, listing, deletion) //! - Client and site management //! - Metrics retrieval //! - Command execution //! - User authentication pub mod agents; pub mod auth; pub mod clients; pub mod commands; pub mod metrics; pub mod sites; use axum::{ routing::{delete, get, post, put}, Router, }; use crate::AppState; /// Build all API routes pub fn routes() -> Router { Router::new() // Authentication .route("/auth/login", post(auth::login)) .route("/auth/register", post(auth::register)) .route("/auth/me", get(auth::me)) // Clients .route("/clients", get(clients::list_clients)) .route("/clients", post(clients::create_client)) .route("/clients/:id", get(clients::get_client)) .route("/clients/:id", put(clients::update_client)) .route("/clients/:id", delete(clients::delete_client)) .route("/clients/:id/sites", get(sites::list_sites_by_client)) // Sites .route("/sites", get(sites::list_sites)) .route("/sites", post(sites::create_site)) .route("/sites/:id", get(sites::get_site)) .route("/sites/:id", put(sites::update_site)) .route("/sites/:id", delete(sites::delete_site)) .route("/sites/:id/regenerate-key", post(sites::regenerate_api_key)) // Agents .route("/agents", get(agents::list_agents_with_details)) .route("/agents", post(agents::register_agent)) .route("/agents/stats", get(agents::get_stats)) .route("/agents/unassigned", get(agents::list_unassigned_agents)) .route("/agents/:id", get(agents::get_agent)) .route("/agents/:id", delete(agents::delete_agent)) .route("/agents/:id/move", post(agents::move_agent)) .route("/agents/:id/state", get(agents::get_agent_state)) // Metrics .route("/agents/:id/metrics", get(metrics::get_agent_metrics)) .route("/metrics/summary", get(metrics::get_summary)) // Commands .route("/agents/:id/command", post(commands::send_command)) .route("/commands", get(commands::list_commands)) .route("/commands/:id", get(commands::get_command)) // Legacy Agent (PowerShell for 2008 R2) .route("/agent/register-legacy", post(agents::register_legacy)) .route("/agent/heartbeat", post(agents::heartbeat)) .route("/agent/command-result", post(agents::command_result)) }