Skip to main content

windmill_api/apis/
health_api.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.634.3
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`get_health_detailed`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetHealthDetailedError {
22    Status503(models::DetailedHealthResponse),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`get_health_status`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum GetHealthStatusError {
30    Status503(models::HealthStatusResponse),
31    UnknownValue(serde_json::Value),
32}
33
34
35/// Returns detailed health information including database pool stats, worker details, and queue status. Requires authentication. Use for monitoring dashboards and debugging. This endpoint always returns fresh data (no caching). 
36pub 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/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
59    } else {
60        let local_var_entity: Option<GetHealthDetailedError> = crate::from_str_patched/* Externally injected from /build.nu */(&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
66/// Health status endpoint. Returns cached health status (database connectivity, worker count). Cache TTL is fixed at 5 seconds. Use force=true query parameter to bypass cache. Note: This endpoint is intentionally different from Kubernetes probes to avoid confusion. For k8s liveness/readiness probes, use /version endpoint. 
67pub 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/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
90    } else {
91        let local_var_entity: Option<GetHealthStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&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