use async_trait::async_trait;
use serde::{Serialize, Serializer, ser::SerializeStruct};
use std::{fmt::Debug, sync::Arc};

use crate::{data::{Id, Version}, interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, inventory::Inventory, score::Score, topology::{
        oberservability::monitoring::{AlertChannelConfig, Monitor},HelmCommand, Topology
    }};


#[derive(Debug, Clone, Serialize)]
pub struct MonitoringAlertingScore {
    #[serde(skip)]
    pub alert_channel_configs: Option<Vec<Box<dyn AlertChannelConfig>>>,
}

impl<T: Topology + HelmCommand + Monitor> Score<T> for MonitoringAlertingScore {
    fn create_interpret(&self) -> Box<dyn Interpret<T>> {
        Box::new(MonitoringAlertingInterpret {
            score: self.clone(),
        })
    }

    fn name(&self) -> String {
        "MonitoringAlertingScore".to_string()
    }
}

#[derive(Debug)]
struct MonitoringAlertingInterpret {
    score: MonitoringAlertingScore,
}

#[async_trait]
impl<T: Topology + HelmCommand + Monitor> Interpret<T> for MonitoringAlertingInterpret {
    async fn execute(
        &self,
        inventory: &Inventory,
        topology: &T,
    ) -> Result<Outcome, InterpretError> {
        topology.provision_monitor(self.score.alert_channel_configs.clone()).await 
    }

    fn get_name(&self) -> InterpretName {
        todo!()
    }

    fn get_version(&self) -> Version {
        todo!()
    }

    fn get_status(&self) -> InterpretStatus {
        todo!()
    }

    fn get_children(&self) -> Vec<Id> {
        todo!()
    }
}


