windmill_api/apis/
health_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetHealthDetailedError {
22 Status503(models::DetailedHealthResponse),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum GetHealthStatusError {
30 Status503(models::HealthStatusResponse),
31 UnknownValue(serde_json::Value),
32}
33
34
35pub async fn get_health_detailed(configuration: &configuration::Configuration, ) -> Result<models::DetailedHealthResponse, Error<GetHealthDetailedError>> {
37 let local_var_configuration = configuration;
38
39 let local_var_client = &local_var_configuration.client;
40
41 let local_var_uri_str = format!("{}/health/detailed", local_var_configuration.base_path);
42 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
43
44 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
45 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
46 }
47 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
48 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
49 };
50
51 let local_var_req = local_var_req_builder.build()?;
52 let local_var_resp = local_var_client.execute(local_var_req).await?;
53
54 let local_var_status = local_var_resp.status();
55 let local_var_content = local_var_resp.text().await?;
56
57 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
58 crate::from_str_patched(&local_var_content).map_err(Error::from)
59 } else {
60 let local_var_entity: Option<GetHealthDetailedError> = crate::from_str_patched(&local_var_content).ok();
61 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
62 Err(Error::ResponseError(local_var_error))
63 }
64}
65
66pub async fn get_health_status(configuration: &configuration::Configuration, force: Option<bool>) -> Result<models::HealthStatusResponse, Error<GetHealthStatusError>> {
68 let local_var_configuration = configuration;
69
70 let local_var_client = &local_var_configuration.client;
71
72 let local_var_uri_str = format!("{}/health/status", local_var_configuration.base_path);
73 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
74
75 if let Some(ref local_var_str) = force {
76 local_var_req_builder = local_var_req_builder.query(&[("force", &local_var_str.to_string())]);
77 }
78 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
79 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
80 }
81
82 let local_var_req = local_var_req_builder.build()?;
83 let local_var_resp = local_var_client.execute(local_var_req).await?;
84
85 let local_var_status = local_var_resp.status();
86 let local_var_content = local_var_resp.text().await?;
87
88 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
89 crate::from_str_patched(&local_var_content).map_err(Error::from)
90 } else {
91 let local_var_entity: Option<GetHealthStatusError> = crate::from_str_patched(&local_var_content).ok();
92 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
93 Err(Error::ResponseError(local_var_error))
94 }
95}
96