/*
 * Artifact Keeper API
 *
 * REST API for Artifact Keeper, an open-source universal artifact registry. Covers user management, repositories, artifacts, search, security scanning, SBOM, dependency tracking, SSO, analytics, monitoring, telemetry, lifecycle policies, plugins, edge nodes, migration, and administration. Format-specific protocol endpoints (npm, PyPI, Maven, Docker/OCI, etc.) are not included; those follow their respective upstream specifications.
 *
 * The version of the OpenAPI document: 1.0.0-a2
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// ServiceHealthEntry : A single health check result recorded for a monitored service.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ServiceHealthEntry {
    /// Name of the monitored service.
    #[serde(rename = "service_name")]
    pub service_name: String,
    /// Health status determined by the check.
    #[serde(rename = "status")]
    pub status: Status,
    /// Status from the preceding check, or null if this is the first recorded check.
    #[serde(rename = "previous_status", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub previous_status: Option<Option<PreviousStatus>>,
    /// Human-readable diagnostic message, typically populated on degraded or unhealthy checks.
    #[serde(rename = "message", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub message: Option<Option<String>>,
    /// Time taken to complete the health probe in milliseconds, or null if the probe timed out.
    #[serde(rename = "response_time_ms", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub response_time_ms: Option<Option<i32>>,
    /// Timestamp when the health check was performed.
    #[serde(rename = "checked_at")]
    pub checked_at: String,
}

impl ServiceHealthEntry {
    /// A single health check result recorded for a monitored service.
    pub fn new(service_name: String, status: Status, checked_at: String) -> ServiceHealthEntry {
        ServiceHealthEntry {
            service_name,
            status,
            previous_status: None,
            message: None,
            response_time_ms: None,
            checked_at,
        }
    }
}
/// Health status determined by the check.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "healthy")]
    Healthy,
    #[serde(rename = "degraded")]
    Degraded,
    #[serde(rename = "unhealthy")]
    Unhealthy,
}

impl Default for Status {
    fn default() -> Status {
        Self::Healthy
    }
}
/// Status from the preceding check, or null if this is the first recorded check.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum PreviousStatus {
    #[serde(rename = "healthy")]
    Healthy,
    #[serde(rename = "degraded")]
    Degraded,
    #[serde(rename = "unhealthy")]
    Unhealthy,
}

impl Default for PreviousStatus {
    fn default() -> PreviousStatus {
        Self::Healthy
    }
}

