ebbmem_client_generated/apis/
health_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum HealthError {
22 Status400(models::ErrorResponse),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum ReadyError {
30 Status400(models::ErrorResponse),
31 UnknownValue(serde_json::Value),
32}
33
34
35pub async fn health(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<HealthError>> {
37
38 let uri_str = format!("{}/healthz", configuration.base_path);
39 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
40
41 if let Some(ref user_agent) = configuration.user_agent {
42 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
43 }
44
45 let req = req_builder.build()?;
46 let resp = configuration.client.execute(req).await?;
47
48 let status = resp.status();
49 let content_type = resp
50 .headers()
51 .get("content-type")
52 .and_then(|v| v.to_str().ok())
53 .unwrap_or("application/octet-stream");
54 let content_type = super::ContentType::from(content_type);
55
56 if !status.is_client_error() && !status.is_server_error() {
57 let content = resp.text().await?;
58 match content_type {
59 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
60 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
61 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
62 }
63 } else {
64 let content = resp.text().await?;
65 let entity: Option<HealthError> = serde_json::from_str(&content).ok();
66 Err(Error::ResponseError(ResponseContent { status, content, entity }))
67 }
68}
69
70pub async fn ready(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ReadyError>> {
72
73 let uri_str = format!("{}/readyz", configuration.base_path);
74 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
75
76 if let Some(ref user_agent) = configuration.user_agent {
77 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
78 }
79
80 let req = req_builder.build()?;
81 let resp = configuration.client.execute(req).await?;
82
83 let status = resp.status();
84 let content_type = resp
85 .headers()
86 .get("content-type")
87 .and_then(|v| v.to_str().ok())
88 .unwrap_or("application/octet-stream");
89 let content_type = super::ContentType::from(content_type);
90
91 if !status.is_client_error() && !status.is_server_error() {
92 let content = resp.text().await?;
93 match content_type {
94 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
95 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
96 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
97 }
98 } else {
99 let content = resp.text().await?;
100 let entity: Option<ReadyError> = serde_json::from_str(&content).ok();
101 Err(Error::ResponseError(ResponseContent { status, content, entity }))
102 }
103}
104