github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/rust/src/apis/health_check_api.rs (about) 1 /* 2 * lakeFS API 3 * 4 * lakeFS HTTP API 5 * 6 * The version of the OpenAPI document: 1.0.0 7 * Contact: services@treeverse.io 8 * Generated by: https://openapi-generator.tech 9 */ 10 11 12 use reqwest; 13 14 use crate::{apis::ResponseContent, models}; 15 use super::{Error, configuration}; 16 17 18 /// struct for typed errors of method [`health_check`] 19 #[derive(Debug, Clone, Serialize, Deserialize)] 20 #[serde(untagged)] 21 pub enum HealthCheckError { 22 UnknownValue(serde_json::Value), 23 } 24 25 26 /// check that the API server is up and running 27 pub async fn health_check(configuration: &configuration::Configuration, ) -> Result<(), Error<HealthCheckError>> { 28 let local_var_configuration = configuration; 29 30 let local_var_client = &local_var_configuration.client; 31 32 let local_var_uri_str = format!("{}/healthcheck", local_var_configuration.base_path); 33 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 34 35 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 36 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 37 } 38 39 let local_var_req = local_var_req_builder.build()?; 40 let local_var_resp = local_var_client.execute(local_var_req).await?; 41 42 let local_var_status = local_var_resp.status(); 43 let local_var_content = local_var_resp.text().await?; 44 45 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 46 Ok(()) 47 } else { 48 let local_var_entity: Option<HealthCheckError> = serde_json::from_str(&local_var_content).ok(); 49 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 50 Err(Error::ResponseError(local_var_error)) 51 } 52 } 53