fundaia 0.55.0

Command line for the Fundaia deployment platform: projects, services, variables, deployments, logs and metrics
use super::*;

impl ApiClient {
    pub async fn monitors(&self, project_id: &str) -> Result<Answer<MonitorsPage>> {
        self.get_answer(&format!(
            "/api/infra/projects/{project_id}/monitors{}",
            self.environment_query('?')
        ))
        .await
    }

    pub async fn monitor(&self, project_id: &str, monitor: &str) -> Result<Answer<MonitorPage>> {
        self.get_answer(&format!(
            "/api/infra/projects/{project_id}/monitors/{}",
            utf8_percent_encode(monitor, NON_ALPHANUMERIC)
        ))
        .await
    }

    pub async fn create_monitor(
        &self,
        project_id: &str,
        body: &serde_json::Value,
    ) -> Result<Answer<MonitorPage>> {
        self.post_answer(&format!("/api/infra/projects/{project_id}/monitors"), body)
            .await
    }

    pub async fn update_monitor(
        &self,
        project_id: &str,
        monitor: &str,
        body: &serde_json::Value,
    ) -> Result<Answer<MonitorPage>> {
        self.answer(
            Method::PATCH,
            &format!(
                "/api/infra/projects/{project_id}/monitors/{}",
                utf8_percent_encode(monitor, NON_ALPHANUMERIC)
            ),
            Some(body),
        )
        .await
    }

    pub async fn delete_monitor(&self, project_id: &str, monitor: &str) -> Result<Removal> {
        self.delete_for(&format!(
            "/api/infra/projects/{project_id}/monitors/{}",
            utf8_percent_encode(monitor, NON_ALPHANUMERIC)
        ))
        .await
    }

    pub async fn alerts(&self, project_id: &str) -> Result<Answer<AlertsPage>> {
        self.get_answer(&format!(
            "/api/infra/projects/{project_id}/alerts{}",
            self.environment_query('?')
        ))
        .await
    }

    pub async fn alert(&self, project_id: &str, alert: &str) -> Result<Answer<AlertPage>> {
        self.get_answer(&format!(
            "/api/infra/projects/{project_id}/alerts/{}",
            utf8_percent_encode(alert, NON_ALPHANUMERIC)
        ))
        .await
    }

    pub async fn create_alert(
        &self,
        project_id: &str,
        body: &serde_json::Value,
    ) -> Result<Answer<AlertPage>> {
        self.post_answer(&format!("/api/infra/projects/{project_id}/alerts"), body)
            .await
    }

    pub async fn update_alert(
        &self,
        project_id: &str,
        alert: &str,
        body: &serde_json::Value,
    ) -> Result<Answer<AlertPage>> {
        self.answer(
            Method::PATCH,
            &format!(
                "/api/infra/projects/{project_id}/alerts/{}",
                utf8_percent_encode(alert, NON_ALPHANUMERIC)
            ),
            Some(body),
        )
        .await
    }

    pub async fn delete_alert(&self, project_id: &str, alert: &str) -> Result<Removal> {
        self.delete_for(&format!(
            "/api/infra/projects/{project_id}/alerts/{}",
            utf8_percent_encode(alert, NON_ALPHANUMERIC)
        ))
        .await
    }
}