trieve_client/apis/
health_api.rs

1/*
2 * Trieve API
3 *
4 * Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5 *
6 * The version of the OpenAPI document: 0.11.7
7 * Contact: developers@trieve.ai
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`health_check`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum HealthCheckError {
22    Status400(models::ErrorResponseBody),
23    UnknownValue(serde_json::Value),
24}
25
26
27/// Confirmation that the service is healthy and can make embedding vectors
28pub async fn health_check(configuration: &configuration::Configuration, ) -> Result<(), Error<HealthCheckError>> {
29    let local_var_configuration = configuration;
30
31    let local_var_client = &local_var_configuration.client;
32
33    let local_var_uri_str = format!("{}/api/health", local_var_configuration.base_path);
34    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
35
36    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
37        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
38    }
39
40    let local_var_req = local_var_req_builder.build()?;
41    let local_var_resp = local_var_client.execute(local_var_req).await?;
42
43    let local_var_status = local_var_resp.status();
44    let local_var_content = local_var_resp.text().await?;
45
46    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
47        Ok(())
48    } else {
49        let local_var_entity: Option<HealthCheckError> = serde_json::from_str(&local_var_content).ok();
50        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
51        Err(Error::ResponseError(local_var_error))
52    }
53}
54