Synced files: - Session logs updated - Latest context and credentials - Command/directive updates Machine: DESKTOP-0O8A1RL Timestamp: 2026-04-02 19:20:43 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
67 lines
2.6 KiB
Rust
67 lines
2.6 KiB
Rust
//! 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<AppState> {
|
|
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).delete(commands::clear_command_history))
|
|
.route("/commands/:id", get(commands::get_command).delete(commands::delete_command))
|
|
.route("/commands/:id/cancel", post(commands::cancel_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))
|
|
}
|