/*
 * 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};

/// AlertState : Current alert state for a monitored service.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AlertState {
    /// Name of the monitored service.
    #[serde(rename = "service_name")]
    pub service_name: String,
    /// Most recent health status.
    #[serde(rename = "current_status")]
    pub current_status: CurrentStatus,
    /// Number of consecutive health check failures. Resets to zero on a successful check.
    #[serde(rename = "consecutive_failures")]
    pub consecutive_failures: i32,
    /// Timestamp of the most recent alert notification, or null if no alert has been sent.
    #[serde(rename = "last_alert_sent_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_alert_sent_at: Option<Option<String>>,
    /// If set, alert notifications are suppressed until this timestamp.
    #[serde(rename = "suppressed_until", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub suppressed_until: Option<Option<String>>,
    /// Timestamp of the most recent state change.
    #[serde(rename = "updated_at")]
    pub updated_at: String,
}

impl AlertState {
    /// Current alert state for a monitored service.
    pub fn new(service_name: String, current_status: CurrentStatus, consecutive_failures: i32, updated_at: String) -> AlertState {
        AlertState {
            service_name,
            current_status,
            consecutive_failures,
            last_alert_sent_at: None,
            suppressed_until: None,
            updated_at,
        }
    }
}
/// Most recent health status.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CurrentStatus {
    #[serde(rename = "healthy")]
    Healthy,
    #[serde(rename = "degraded")]
    Degraded,
    #[serde(rename = "unhealthy")]
    Unhealthy,
}

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

