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 deploy_without_cache(&self, service_environment_id: &str) -> Result<Deployment> {
        Ok(self
            .post::<DeploymentAccepted, _>(
                &self.released(&format!(
                    "/api/infra/services/{service_environment_id}/deploy"
                )),
                &serde_json::json!({ "noCache": true }),
            )
            .await?
            .deployment)
    }

    pub async fn bulk(
        &self,
        project_id: &str,
        action: &str,
        services: &[String],
    ) -> Result<Answer<BulkAnswer>> {
        let mut body = serde_json::Map::new();
        body.insert("action".into(), action.into());
        if !services.is_empty() {
            body.insert("services".into(), services.to_vec().into());
        }
        if let Some(environment) = self.environment() {
            body.insert("environment".into(), environment.into());
        }

        self.post_answer(
            &self.released(&format!("/api/infra/projects/{project_id}/bulk")),
            &serde_json::Value::Object(body),
        )
        .await
    }

    pub async fn deploy_hooks(
        &self,
        service_environment_id: &str,
    ) -> Result<Answer<DeployHooksPage>> {
        self.get_answer(&format!(
            "/api/infra/services/{service_environment_id}/hooks"
        ))
        .await
    }

    pub async fn create_deploy_hook(
        &self,
        service_environment_id: &str,
        name: &str,
    ) -> Result<Answer<CreatedDeployHook>> {
        self.post_answer(
            &format!("/api/infra/services/{service_environment_id}/hooks"),
            &serde_json::json!({ "name": name }),
        )
        .await
    }

    pub async fn revoke_deploy_hook(
        &self,
        service_environment_id: &str,
        hook: &str,
    ) -> Result<serde_json::Value> {
        self.delete_for(&format!(
            "/api/infra/services/{service_environment_id}/hooks/{}",
            utf8_percent_encode(hook, NON_ALPHANUMERIC)
        ))
        .await
    }
}