hypercall_admin/monitoring/
env.rs1use axum::{
4 extract::State,
5 http::StatusCode,
6 response::{IntoResponse, Response},
7};
8use serde::Serialize;
9
10use crate::state::AdminState;
11use hypercall_runtime_api::sonic_json::SonicJson;
12
13#[derive(Debug, Serialize, utoipa::ToSchema)]
15pub struct EnvConfigResponse {
16 pub boot_id: String,
18 pub db_host: String,
20 pub db_name: String,
22 pub server_started_at: String,
24 pub current_time: String,
26}
27
28#[utoipa::path(
33 get,
34 path = "/monitoring/env",
35 tag = "monitoring",
36 responses(
37 (status = 200, description = "Environment configuration", body = EnvConfigResponse)
38 ),
39 security(
40 ("admin_key" = [])
41 )
42)]
43pub async fn get_monitoring_env(State(state): State<AdminState>) -> Response {
44 let response = EnvConfigResponse {
45 boot_id: state.boot_id.clone(),
46 db_host: state.runtime_config.db_host.clone(),
47 db_name: state.runtime_config.db_name.clone(),
48 server_started_at: state.server_started_at.to_rfc3339(),
49 current_time: chrono::Utc::now().to_rfc3339(),
50 };
51
52 (StatusCode::OK, SonicJson(response)).into_response()
53}