polyte_data/api/
health.rs

1use polyte_core::RequestError;
2use reqwest::Client;
3use serde::{Deserialize, Serialize};
4use url::Url;
5
6use crate::error::DataApiError;
7
8/// Health namespace for API health operations
9#[derive(Clone)]
10pub struct Health {
11    pub(crate) client: Client,
12    pub(crate) base_url: Url,
13}
14
15impl Health {
16    /// Check API health status
17    pub async fn check(&self) -> Result<HealthResponse, DataApiError> {
18        let response = self.client.get(self.base_url.clone()).send().await?;
19        let status = response.status();
20
21        if !status.is_success() {
22            return Err(DataApiError::from_response(response).await);
23        }
24
25        let health: HealthResponse = response.json().await?;
26        Ok(health)
27    }
28}
29
30/// Health check response
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct HealthResponse {
33    /// Status indicator (returns "OK" when healthy)
34    pub data: String,
35}