Skip to main content

uarp_sdk/generated/api/
health.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Health checks, readiness, and metrics
4
5#![allow(unused_imports, clippy::too_many_arguments)]
6
7use reqwest::Method;
8use serde::{Deserialize, Serialize};
9
10use crate::client::{Client, Request, NO_BODY, NO_QUERY};
11use crate::error::Result;
12use crate::generated::models;
13use crate::multipart::{field_text, FilePart};
14use crate::sse::EventStream;
15use crate::util::encode_path;
16
17/// Health checks, readiness, and metrics
18#[derive(Debug, Clone)]
19pub struct HealthApi {
20    pub(crate) client: Client,
21}
22
23impl Client {
24    /// Health checks, readiness, and metrics
25    pub fn health(&self) -> HealthApi {
26        HealthApi { client: self.clone() }
27    }
28}
29
30impl HealthApi {
31    /// Health check
32    ///
33    /// `GET /health`
34    pub async fn get(&self) -> Result<models::GetHealthResponse> {
35        self.client
36            .request_json(Request {
37                method: Method::GET,
38                path: "/health".to_string(),
39                query: NO_QUERY,
40                body: NO_BODY,
41                headers: Vec::new(),
42                idempotent: false,
43            })
44            .await
45    }
46
47    /// Prometheus-compatible metrics export
48    ///
49    /// `GET /metrics`
50    pub async fn get_metrics(&self) -> Result<String> {
51        self.client
52            .request_text(Request {
53                method: Method::GET,
54                path: "/metrics".to_string(),
55                query: NO_QUERY,
56                body: NO_BODY,
57                headers: Vec::new(),
58                idempotent: false,
59            })
60            .await
61    }
62
63    /// Readiness probe (checks KV connectivity)
64    ///
65    /// `GET /ready`
66    pub async fn get_ready(&self) -> Result<models::GetReadyResponse> {
67        self.client
68            .request_json(Request {
69                method: Method::GET,
70                path: "/ready".to_string(),
71                query: NO_QUERY,
72                body: NO_BODY,
73                headers: Vec::new(),
74                idempotent: false,
75            })
76            .await
77    }
78
79    /// Liveness (alias of /health)
80    ///
81    /// Identical body to `GET /health`. Kept for callers that assume every route lives under
82    /// `/api/v1`; new callers should use `/health`.
83    ///
84    /// `GET /api/v1/health`
85    pub async fn health_check_v1alias(&self) -> Result<models::HealthCheckV1aliasResponse> {
86        self.client
87            .request_json(Request {
88                method: Method::GET,
89                path: "/api/v1/health".to_string(),
90                query: NO_QUERY,
91                body: NO_BODY,
92                headers: Vec::new(),
93                idempotent: false,
94            })
95            .await
96    }
97
98    /// Kubernetes liveness probe
99    ///
100    /// `GET /health/live`
101    pub async fn health_live(&self) -> Result<models::HealthLiveResponse> {
102        self.client
103            .request_json(Request {
104                method: Method::GET,
105                path: "/health/live".to_string(),
106                query: NO_QUERY,
107                body: NO_BODY,
108                headers: Vec::new(),
109                idempotent: false,
110            })
111            .await
112    }
113
114    /// Kubernetes readiness probe
115    ///
116    /// `GET /health/ready`
117    pub async fn health_ready(&self) -> Result<models::ReadinessReport> {
118        self.client
119            .request_json(Request {
120                method: Method::GET,
121                path: "/health/ready".to_string(),
122                query: NO_QUERY,
123                body: NO_BODY,
124                headers: Vec::new(),
125                idempotent: false,
126            })
127            .await
128    }
129
130    /// SSE end-to-end health check
131    ///
132    /// `GET /health/sse`
133    ///
134    /// Returns a server-sent event stream.
135    pub fn health_sse(&self) -> EventStream {
136        self.client.request_stream(
137            "/health/sse",
138            NO_QUERY,
139            Vec::new(),
140        )
141    }
142
143    /// Health check alias (/healthz)
144    ///
145    /// `GET /healthz`
146    pub async fn healthz_alias(&self) -> Result<models::HealthzAliasResponse> {
147        self.client
148            .request_json(Request {
149                method: Method::GET,
150                path: "/healthz".to_string(),
151                query: NO_QUERY,
152                body: NO_BODY,
153                headers: Vec::new(),
154                idempotent: false,
155            })
156            .await
157    }
158
159    /// Readiness alias (/readyz)
160    ///
161    /// `GET /readyz`
162    pub async fn readyz_alias(&self) -> Result<models::ReadinessReport> {
163        self.client
164            .request_json(Request {
165                method: Method::GET,
166                path: "/readyz".to_string(),
167                query: NO_QUERY,
168                body: NO_BODY,
169                headers: Vec::new(),
170                idempotent: false,
171            })
172            .await
173    }
174}