uarp-sdk 0.5.7

Async Rust client for the UARP (Snaga) Universal Agent Runtime Platform API
Documentation
// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
//!
//! Health checks, readiness, and metrics

#![allow(unused_imports, clippy::too_many_arguments)]

use reqwest::Method;
use serde::{Deserialize, Serialize};

use crate::client::{Client, Request, NO_BODY, NO_QUERY};
use crate::error::Result;
use crate::generated::models;
use crate::multipart::{field_text, FilePart};
use crate::sse::EventStream;
use crate::util::encode_path;

/// Health checks, readiness, and metrics
#[derive(Debug, Clone)]
pub struct HealthApi {
    pub(crate) client: Client,
}

impl Client {
    /// Health checks, readiness, and metrics
    pub fn health(&self) -> HealthApi {
        HealthApi { client: self.clone() }
    }
}

impl HealthApi {
    /// Health check
    ///
    /// `GET /health`
    pub async fn get(&self) -> Result<models::GetHealthResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/health".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Prometheus-compatible metrics export
    ///
    /// `GET /metrics`
    pub async fn get_metrics(&self) -> Result<String> {
        self.client
            .request_text(Request {
                method: Method::GET,
                path: "/metrics".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Readiness probe (checks KV connectivity)
    ///
    /// `GET /ready`
    pub async fn get_ready(&self) -> Result<models::GetReadyResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/ready".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Kubernetes liveness probe
    ///
    /// `GET /health/live`
    pub async fn health_live(&self) -> Result<models::HealthLiveResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/health/live".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Kubernetes readiness probe
    ///
    /// `GET /health/ready`
    pub async fn health_ready(&self) -> Result<serde_json::Map<String, serde_json::Value>> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/health/ready".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// SSE end-to-end health check
    ///
    /// `GET /health/sse`
    ///
    /// Returns a server-sent event stream.
    pub fn health_sse(&self) -> EventStream {
        self.client.request_stream(
            "/health/sse",
            NO_QUERY,
            Vec::new(),
        )
    }

    /// Health check alias (/healthz)
    ///
    /// `GET /healthz`
    pub async fn healthz_alias(&self) -> Result<models::HealthzAliasResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/healthz".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Readiness alias (/readyz)
    ///
    /// `GET /readyz`
    pub async fn readyz_alias(&self) -> Result<serde_json::Map<String, serde_json::Value>> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/readyz".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }
}