From 6bbca70b99353d3f7f253168f7fd723811ac4159 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 25 Jul 2023 08:19:52 +0200 Subject: [PATCH] Make execute sql call Signed-off-by: Ryan Levick --- Cargo.lock | 2 +- Cargo.toml | 5 +++-- crates/cloud/Cargo.toml | 4 ++-- crates/cloud/src/client.rs | 11 ++--------- src/commands/sqlite.rs | 10 ++-------- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab704f8..b00aa1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -442,7 +442,7 @@ dependencies = [ [[package]] name = "cloud-openapi" version = "0.1.0" -source = "git+https://github.com/kate-goldenring/cloud-openapi?rev=95482744a7656553b600fdc9e91bed5812176941#95482744a7656553b600fdc9e91bed5812176941" +source = "git+https://github.com/fermyon/cloud-openapi?rev=c37c0f28c06a206ebe05a811c2b886290a5bab40#c37c0f28c06a206ebe05a811c2b886290a5bab40" dependencies = [ "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 4d7f6c6..b2bf6c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,12 +14,12 @@ edition = "2021" [dependencies] anyhow = "1.0" bindle = { git = "https://github.com/fermyon/bindle", tag = "v0.8.2", default-features = false, features = [ - "client", + "client", ] } chrono = "0.4" clap = { version = "3.2.24", features = ["derive", "env"] } cloud = { path = "crates/cloud" } -cloud-openapi = { git = "https://github.com/kate-goldenring/cloud-openapi", rev = "95482744a7656553b600fdc9e91bed5812176941" } +cloud-openapi = { workspace = true } dirs = "5.0" dialoguer = "0.10" tokio = { version = "1.23", features = ["full"] } @@ -48,6 +48,7 @@ openssl = { version = "0.10" } [workspace.dependencies] tracing = { version = "0.1", features = ["log"] } +cloud-openapi = { git = "https://github.com/fermyon/cloud-openapi", rev = "c37c0f28c06a206ebe05a811c2b886290a5bab40" } [build-dependencies] vergen = { version = "^8.2.1", default-features = false, features = [ diff --git a/crates/cloud/Cargo.toml b/crates/cloud/Cargo.toml index a01cfa4..d15f1ea 100644 --- a/crates/cloud/Cargo.toml +++ b/crates/cloud/Cargo.toml @@ -6,11 +6,11 @@ edition = { workspace = true } [dependencies] anyhow = "1.0" -cloud-openapi = { git = "https://github.com/kate-goldenring/cloud-openapi", rev = "95482744a7656553b600fdc9e91bed5812176941" } +cloud-openapi = { workspace = true } mime_guess = { version = "2.0" } reqwest = { version = "0.11", features = ["stream"] } semver = "1.0" -serde = {version = "1.0", features = ["derive"]} +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.17", features = ["full"] } tokio-util = { version = "0.7.3", features = ["codec"] } diff --git a/crates/cloud/src/client.rs b/crates/cloud/src/client.rs index c3bd08d..d3f085a 100644 --- a/crates/cloud/src/client.rs +++ b/crates/cloud/src/client.rs @@ -399,20 +399,13 @@ impl Client { .map_err(format_response_error) } - pub async fn execute_sql( - &self, - app_id: Uuid, - database: String, - statement: String, - ) -> anyhow::Result<()> { - let default = true; + pub async fn execute_sql(&self, database: String, statement: String) -> anyhow::Result<()> { api_sql_databases_execute_post( &self.configuration, ExecuteSqlStatementCommand { database, - app_id, statement, - default, + default: false, }, None, ) diff --git a/src/commands/sqlite.rs b/src/commands/sqlite.rs index 149a1ff..53de6fc 100644 --- a/src/commands/sqlite.rs +++ b/src/commands/sqlite.rs @@ -4,7 +4,7 @@ use cloud::client::Client as CloudClient; use cloud_openapi::models::Database; use dialoguer::Input; -use crate::commands::{create_cloud_client, get_app_id_cloud}; +use crate::commands::create_cloud_client; use crate::opts::*; /// Manage Fermyon Cloud SQLite databases @@ -40,10 +40,6 @@ pub struct ExecuteCommand { ///Statement to execute statement: String, - /// Name of Spin app - #[clap(name = "app", long = "app")] - pub app: String, - #[clap(flatten)] common: CommonArgs, } @@ -93,9 +89,7 @@ impl SqliteCommand { if !list.iter().any(|d| d.name == cmd.name) { anyhow::bail!("No database found with name \"{}\"", cmd.name); } - let app_id = get_app_id_cloud(&client, &cmd.app).await?; - println!("Executing SQL: {}", cmd.statement); - CloudClient::execute_sql(&client, app_id, cmd.name, cmd.statement) + CloudClient::execute_sql(&client, cmd.name, cmd.statement) .await .context("Problem executing SQL")?; }