polyte_data/api/
health.rs

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