use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AlertThreshold {
    pub id: i32,
    pub name: String,
    pub subscription_id: Option<i32>,
    pub metric_type: String,
    pub threshold_value: f64,
    pub comparison_operator: String,
    pub action: String,
    pub notification_channels: Vec<String>,
    pub is_active: bool,
    pub last_triggered: Option<String>,
}

#[derive(Debug, Deserialize)]
pub struct AlertThresholdCreate {
    pub name: String,
    pub subscription_id: Option<i32>,
    pub metric_type: String,
    pub threshold_value: f64,
    pub comparison_operator: String,
    pub action: String,
    #[serde(default)]
    pub notification_channels: Vec<String>,
    pub is_active: bool,
}

#[derive(Debug, Deserialize)]
pub struct AlertThresholdUpdate {
    #[serde(default)]
    pub name: Option<String>,
    pub threshold_value: Option<f64>,
    pub is_active: Option<bool>,
}

#[derive(Debug, Serialize)]
pub struct AlertHistoryItem {
    pub id: i32,
    pub threshold_id: i32,
    pub threshold_name: String,
    pub actual_value: f64,
    pub triggered_at: String,
    pub action_taken: Option<String>,
    pub notification_sent: bool,
}

#[derive(Debug, Serialize)]
pub struct AlertCheckResult {
    pub threshold_id: i32,
    pub threshold_name: String,
    pub actual_value: f64,
    pub triggered: bool,
    pub action_taken: Option<String>,
}
