use reqwest::{Method, header::HeaderMap}; use serde::Deserialize; use serde_json::{Map, Value}; use crate::{Error, PocketBase}; #[derive(Clone, Debug)] /// Service that handles the Health APIs. pub struct HealthService<'a> { /// Reference to the PocketBase client. pub(super) client: &'a PocketBase, /// Optional comma-separated list of fields to include in the response. pub(super) fields: Option, } #[derive(Clone, Debug, Deserialize)] pub struct HealthCheck { /// Status message. pub message: String, /// Additional data. pub data: Map, } impl HealthService<'_> { /// Checks the health status of the api. pub async fn check(self) -> Result { let mut params = Vec::new(); if let Some(fields) = self.fields { params.push(("fields", fields)); } self.client .send( "/api/health", Method::GET, HeaderMap::new(), ¶ms, None::<&()>, ) .await } }