fundaia 0.36.2

Command line for the Fundaia deployment platform: projects, services, variables, deployments, logs and metrics
//! The rows inside a database component.

use super::*;

impl ApiClient {
    /// The tables of a database service, and whether it can be reached at all.
    pub async fn data_overview(&self, service_environment_id: &str) -> Result<DataOverview> {
        self.get(&format!(
            "/api/infra/services/{service_environment_id}/data"
        ))
        .await
    }

    /// One read-only statement. The server opens the transaction READ ONLY.
    pub async fn query_data(
        &self,
        service_environment_id: &str,
        sql: &str,
        limit: Option<u64>,
    ) -> Result<QueryOutcome> {
        self.post(
            &format!("/api/infra/services/{service_environment_id}/data/query"),
            &serde_json::json!({ "sql": sql, "limit": limit }),
        )
        .await
    }

    /// One statement that writes, committed unless `preview` — then it runs
    /// and is rolled back, and the answer says what it would have touched.
    pub async fn execute_sql(
        &self,
        service_environment_id: &str,
        sql: &str,
        preview: bool,
    ) -> Result<ExecutionOutcome> {
        self.post(
            &format!("/api/infra/services/{service_environment_id}/data/execute"),
            &serde_json::json!({ "sql": sql, "preview": preview }),
        )
        .await
    }
}