rainy_sdk/endpoints/health.rs
1use crate::client::RainyClient;
2use crate::error::Result;
3use crate::models::HealthCheck;
4
5impl RainyClient {
6 /// Performs a basic health check on the Rainy API.
7 ///
8 /// This method is useful for quickly verifying that the API is up and running.
9 ///
10 /// # Returns
11 ///
12 /// A `Result` containing a `HealthCheck` struct with basic health information.
13 ///
14 /// # Example
15 ///
16 /// ```rust,no_run
17 /// # use rainy_sdk::RainyClient;
18 /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
19 /// let client = RainyClient::with_api_key("user-api-key")?;
20 /// let health = client.health_check().await?;
21 /// println!("API Status: {}", health.status);
22 /// # Ok(())
23 /// # }
24 /// ```
25 pub async fn health_check(&self) -> Result<HealthCheck> {
26 self.make_request(reqwest::Method::GET, "/health", None)
27 .await
28 }
29
30 /// Performs a detailed health check on the Rainy API and its underlying services.
31 ///
32 /// This method provides more in-depth information, including the status of the database,
33 /// Redis, and connections to AI providers.
34 ///
35 /// # Returns
36 ///
37 /// A `Result` containing a `HealthCheck` struct with detailed service status.
38 ///
39 /// # Example
40 ///
41 /// ```rust,no_run
42 /// # use rainy_sdk::RainyClient;
43 /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
44 /// let client = RainyClient::with_api_key("user-api-key")?;
45 /// let health = client.detailed_health_check().await?;
46 /// println!("Database status: {}", health.services.database);
47 /// println!("Providers status: {}", health.services.providers);
48 /// # Ok(())
49 /// # }
50 /// ```
51 pub async fn detailed_health_check(&self) -> Result<HealthCheck> {
52 self.make_request(reqwest::Method::GET, "/health?detailed=true", None)
53 .await
54 }
55}