use crate::common::ApiState;
use crate::common::{ApiError, ApiResult, Json, State};
use serde_json::{json, Value};
use std::collections::HashMap;
#[utoipa::path(
post,
path = "/v1/simulation/upload/string",
tag = "simulation",
responses(
(status = 200, description = "Stimulation script uploaded", body = HashMap<String, String>),
(status = 500, description = "Internal server error")
)
)]
pub async fn post_stimulation_upload(
State(_state): State<ApiState>,
Json(request): Json<HashMap<String, Value>>,
) -> ApiResult<Json<HashMap<String, String>>> {
let _script = request
.get("stimulation_script")
.ok_or_else(|| ApiError::invalid_input("Missing 'stimulation_script' field"))?;
tracing::info!(target: "feagi-api", "Stimulation script upload requested");
Ok(Json(HashMap::from([(
"message".to_string(),
"Stimulation script uploaded successfully".to_string(),
)])))
}
#[utoipa::path(
post,
path = "/v1/simulation/reset",
tag = "simulation",
responses(
(status = 200, description = "Simulation reset", body = HashMap<String, String>),
(status = 500, description = "Internal server error")
)
)]
pub async fn post_reset(
State(_state): State<ApiState>,
) -> ApiResult<Json<HashMap<String, String>>> {
Ok(Json(HashMap::from([(
"message".to_string(),
"Simulation reset successfully".to_string(),
)])))
}
#[utoipa::path(
get,
path = "/v1/simulation/status",
tag = "simulation",
responses(
(status = 200, description = "Simulation status", body = HashMap<String, serde_json::Value>),
(status = 500, description = "Internal server error")
)
)]
pub async fn get_status(State(_state): State<ApiState>) -> ApiResult<Json<HashMap<String, Value>>> {
let mut response = HashMap::new();
response.insert("active".to_string(), json!(false));
response.insert("stimulation_running".to_string(), json!(false));
Ok(Json(response))
}
#[utoipa::path(
get,
path = "/v1/simulation/stats",
tag = "simulation",
responses(
(status = 200, description = "Simulation statistics", body = HashMap<String, serde_json::Value>),
(status = 500, description = "Internal server error")
)
)]
pub async fn get_stats(State(_state): State<ApiState>) -> ApiResult<Json<HashMap<String, Value>>> {
let mut response = HashMap::new();
response.insert("total_stimulations".to_string(), json!(0));
response.insert("active_scripts".to_string(), json!(0));
Ok(Json(response))
}
#[utoipa::path(
post,
path = "/v1/simulation/config",
tag = "simulation",
responses(
(status = 200, description = "Simulation configured", body = HashMap<String, String>),
(status = 500, description = "Internal server error")
)
)]
pub async fn post_config(
State(_state): State<ApiState>,
Json(_request): Json<HashMap<String, Value>>,
) -> ApiResult<Json<HashMap<String, String>>> {
Ok(Json(HashMap::from([(
"message".to_string(),
"Simulation configured successfully".to_string(),
)])))
}