qcs_api/apis/
default_api.rs1use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetHealthError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum HealthCheckError {
27 Status422(crate::models::ValidationError),
28 UnknownValue(serde_json::Value),
29}
30
31pub async fn get_health(
33 configuration: &configuration::Configuration,
34) -> Result<crate::models::Health, Error<GetHealthError>> {
35 let local_var_configuration = configuration;
36
37 let local_var_client = &local_var_configuration.client;
38
39 let local_var_uri_str = format!("{}/", local_var_configuration.base_path);
40 let mut local_var_req_builder =
41 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
42
43 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
44 local_var_req_builder =
45 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
46 }
47
48 let local_var_req = local_var_req_builder.build()?;
49 let local_var_resp = local_var_client.execute(local_var_req).await?;
50
51 let local_var_status = local_var_resp.status();
52 let local_var_content = local_var_resp.text().await?;
53
54 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
55 serde_json::from_str(&local_var_content).map_err(Error::from)
56 } else {
57 let local_var_entity: Option<GetHealthError> =
58 serde_json::from_str(&local_var_content).ok();
59 let local_var_error = ResponseContent {
60 status: local_var_status,
61 content: local_var_content,
62 entity: local_var_entity,
63 };
64 Err(Error::ResponseError(local_var_error))
65 }
66}
67
68pub async fn health_check(
70 configuration: &configuration::Configuration,
71) -> Result<serde_json::Value, Error<HealthCheckError>> {
72 let local_var_configuration = configuration;
73
74 let local_var_client = &local_var_configuration.client;
75
76 let local_var_uri_str = format!("{}/v1/", local_var_configuration.base_path);
77 let mut local_var_req_builder =
78 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
79
80 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
81 local_var_req_builder =
82 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
83 }
84
85 let local_var_req = local_var_req_builder.build()?;
86 let local_var_resp = local_var_client.execute(local_var_req).await?;
87
88 let local_var_status = local_var_resp.status();
89 let local_var_content = local_var_resp.text().await?;
90
91 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
92 serde_json::from_str(&local_var_content).map_err(Error::from)
93 } else {
94 let local_var_entity: Option<HealthCheckError> =
95 serde_json::from_str(&local_var_content).ok();
96 let local_var_error = ResponseContent {
97 status: local_var_status,
98 content: local_var_content,
99 entity: local_var_entity,
100 };
101 Err(Error::ResponseError(local_var_error))
102 }
103}