pub async fn get_status(
configuration: &Configuration,
) -> Result<StatusResponse, Error<GetStatusError>>Examples found in repository?
examples/status_example.rs (line 52)
36async fn main() -> Result<(), Box<dyn std::error::Error>> {
37 // Setup configuration using the common helper
38 let config = match common::setup_configuration() {
39 Ok(cfg) => cfg,
40 Err(e) => {
41 eprintln!("Configuration error: {}", e);
42 eprintln!("Please ensure CORTEX_ENDPOINT and CORTEX_API_KEY environment variables are set.");
43 eprintln!("Example usage:");
44 eprintln!(" export CORTEX_ENDPOINT=\"http://localhost:9000/api\"");
45 eprintln!(" export CORTEX_API_KEY=\"your_api_key_here\"");
46 eprintln!(" cargo run --example status_example");
47 return Err(e.into());
48 }
49 };
50
51 println!("Fetching API status (/status)...");
52 match status_api::get_status(&config).await {
53 Ok(status_response) => {
54 println!("Successfully fetched API status:");
55 println!("{:#?}", status_response);
56
57 if let Some(versions) = status_response.versions {
58 println!("\nVersions:");
59 println!(" Cortex: {}", versions.cortex.as_deref().unwrap_or("N/A"));
60 println!(" Elastic4Play: {}", versions.elastic4_play.as_deref().unwrap_or("N/A"));
61 }
62 if let Some(api_config) = status_response.config {
63 println!("\nAPI Configuration:");
64 println!(" Auth Type: {:?}", api_config.auth_type);
65 println!(" Capabilities: {:?}", api_config.capabilities.unwrap_or_default());
66 }
67 }
68 Err(e) => {
69 eprintln!("Error fetching API status: {:?}", e);
70 }
71 }
72
73 Ok(())
74}