From cc969fc56a7538e69fd1a68c84178e9e81b55a85 Mon Sep 17 00:00:00 2001 From: Edoardo Marangoni Date: Tue, 29 Oct 2024 13:48:14 +0100 Subject: [PATCH 1/2] feat: Rename `wasmer-api` to `wasmer-backend-api` --- lib/backend-api/Cargo.toml | 4 +- lib/backend-api/README.md | 2 +- lib/cli/Cargo.toml | 2 +- lib/cli/src/commands/add.rs | 4 +- lib/cli/src/commands/app/create.rs | 13 ++--- lib/cli/src/commands/app/delete.rs | 2 +- lib/cli/src/commands/app/deploy.rs | 17 ++++--- lib/cli/src/commands/app/deployments/get.rs | 2 +- lib/cli/src/commands/app/deployments/list.rs | 4 +- lib/cli/src/commands/app/deployments/logs.rs | 2 +- lib/cli/src/commands/app/get.rs | 2 +- lib/cli/src/commands/app/list.rs | 8 +-- lib/cli/src/commands/app/logs.rs | 8 +-- lib/cli/src/commands/app/purge_cache.rs | 4 +- lib/cli/src/commands/app/regions/list.rs | 2 +- .../src/commands/app/regions/utils/render.rs | 2 +- lib/cli/src/commands/app/secrets/create.rs | 8 +-- lib/cli/src/commands/app/secrets/delete.rs | 5 +- lib/cli/src/commands/app/secrets/update.rs | 8 +-- lib/cli/src/commands/app/secrets/utils/mod.rs | 14 ++--- .../src/commands/app/secrets/utils/render.rs | 2 +- lib/cli/src/commands/app/util.rs | 18 ++++--- lib/cli/src/commands/app/version/activate.rs | 2 +- lib/cli/src/commands/app/version/get.rs | 2 +- lib/cli/src/commands/app/version/list.rs | 7 +-- .../commands/app/volumes/credentials/mod.rs | 3 +- .../app/volumes/credentials/rotate_secrets.rs | 2 +- lib/cli/src/commands/app/volumes/list.rs | 3 +- lib/cli/src/commands/auth/login/mod.rs | 51 ++++++++++--------- lib/cli/src/commands/auth/logout.rs | 4 +- lib/cli/src/commands/auth/whoami.rs | 2 +- lib/cli/src/commands/config.rs | 4 +- lib/cli/src/commands/domain/get.rs | 3 +- lib/cli/src/commands/domain/list.rs | 4 +- lib/cli/src/commands/domain/register.rs | 2 +- lib/cli/src/commands/domain/zonefile.rs | 4 +- lib/cli/src/commands/init.rs | 2 +- lib/cli/src/commands/namespace/create.rs | 4 +- lib/cli/src/commands/namespace/get.rs | 2 +- lib/cli/src/commands/namespace/list.rs | 2 +- lib/cli/src/commands/package/common/mod.rs | 4 +- lib/cli/src/commands/package/common/wait.rs | 7 +-- lib/cli/src/commands/package/download.rs | 4 +- lib/cli/src/commands/package/publish.rs | 2 +- lib/cli/src/commands/package/push.rs | 8 +-- lib/cli/src/commands/package/tag.rs | 20 ++++---- lib/cli/src/commands/ssh.rs | 11 ++-- lib/cli/src/config/env.rs | 4 +- lib/cli/src/config/mod.rs | 6 ++- lib/cli/src/types.rs | 10 ++-- lib/cli/src/utils/package_wizard/mod.rs | 4 +- lib/cli/src/utils/prompts.rs | 31 +++++++---- 52 files changed, 189 insertions(+), 158 deletions(-) diff --git a/lib/backend-api/Cargo.toml b/lib/backend-api/Cargo.toml index b2471e12683..4fc31701911 100644 --- a/lib/backend-api/Cargo.toml +++ b/lib/backend-api/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-api" +name = "wasmer-backend-api" version = "0.1.0" description = "Client library for the Wasmer GraphQL API" readme = "README.md" -documentation = "https://docs.rs/wasmer-api" +documentation = "https://docs.rs/wasmer-backend-api" authors.workspace = true edition.workspace = true diff --git a/lib/backend-api/README.md b/lib/backend-api/README.md index f1583b1ae2b..1d241bc0ff3 100644 --- a/lib/backend-api/README.md +++ b/lib/backend-api/README.md @@ -1,4 +1,4 @@ -# wasmer-api +# wasmer-backend-api GraphQL API client for the [Wasmer](https://wasmer.io) backend. diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 513d4350700..e7c8baa4c2a 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -144,7 +144,7 @@ virtual-mio = { version = "0.5.0", path = "../virtual-io" } # Wasmer-owned dependencies. webc = { workspace = true } -wasmer-api = { version = "=0.1.0", path = "../backend-api" } +wasmer-backend-api = { version = "=0.1.0", path = "../backend-api" } lazy_static = "1.4.0" # Used by the mount command diff --git a/lib/cli/src/commands/add.rs b/lib/cli/src/commands/add.rs index 77b61858902..83b232143bf 100644 --- a/lib/cli/src/commands/add.rs +++ b/lib/cli/src/commands/add.rs @@ -3,7 +3,7 @@ use crate::config::WasmerEnv; use anyhow::{Context, Error}; use clap::Parser; use std::process::{Command, Stdio}; -use wasmer_api::{ +use wasmer_backend_api::{ types::{Bindings, ProgrammingLanguage}, WasmerClient, }; @@ -102,7 +102,7 @@ async fn lookup_bindings_for_package( pkg: &NamedPackageIdent, language: &ProgrammingLanguage, ) -> Result { - let all_bindings = wasmer_api::query::list_bindings( + let all_bindings = wasmer_backend_api::query::list_bindings( client, &pkg.name, pkg.version_opt().map(|v| v.to_string()).as_deref(), diff --git a/lib/cli/src/commands/app/create.rs b/lib/cli/src/commands/app/create.rs index b98ec43da05..209cc581952 100644 --- a/lib/cli/src/commands/app/create.rs +++ b/lib/cli/src/commands/app/create.rs @@ -14,7 +14,7 @@ use colored::Colorize; use dialoguer::{theme::ColorfulTheme, Confirm, Select}; use futures::stream::TryStreamExt; use is_terminal::IsTerminal; -use wasmer_api::{ +use wasmer_backend_api::{ types::{AppTemplate, TemplateLanguage}, WasmerClient, }; @@ -190,7 +190,7 @@ impl CmdAppCreate { } let user = if let Some(client) = client { - Some(wasmer_api::query::current_user_with_namespaces(client, None).await?) + Some(wasmer_backend_api::query::current_user_with_namespaces(client, None).await?) } else { None }; @@ -359,10 +359,10 @@ impl CmdAppCreate { // Fetch the first page. // If first item matches, then no need to re-fetch. // - let stream = wasmer_api::query::fetch_all_app_templates_from_language( + let stream = wasmer_backend_api::query::fetch_all_app_templates_from_language( client, 10, - Some(wasmer_api::types::AppTemplatesSortBy::Newest), + Some(wasmer_backend_api::types::AppTemplatesSortBy::Newest), language.to_string(), ); @@ -446,7 +446,7 @@ impl CmdAppCreate { // Either no cache present, or cache has exceeded max age. // Fetch the first page. // If first item matches, then no need to re-fetch. - let mut stream = Box::pin(wasmer_api::query::fetch_all_app_template_languages( + let mut stream = Box::pin(wasmer_backend_api::query::fetch_all_app_template_languages( client, None, )); @@ -489,7 +489,8 @@ impl CmdAppCreate { if let Ok(url) = url::Url::parse(template) { url } else if let Some(template) = - wasmer_api::query::fetch_app_template_from_slug(client, template.clone()).await? + wasmer_backend_api::query::fetch_app_template_from_slug(client, template.clone()) + .await? { url::Url::parse(&template.repo_url)? } else { diff --git a/lib/cli/src/commands/app/delete.rs b/lib/cli/src/commands/app/delete.rs index d11d77f4ba0..6ae4ca19dbc 100644 --- a/lib/cli/src/commands/app/delete.rs +++ b/lib/cli/src/commands/app/delete.rs @@ -53,7 +53,7 @@ impl AsyncCliCommand for CmdAppDelete { app.name, app.id.inner(), ); - wasmer_api::query::delete_app(&client, app.id.into_inner()).await?; + wasmer_backend_api::query::delete_app(&client, app.id.into_inner()).await?; eprintln!("App '{}/{}' was deleted!", app.owner.global_name, app.name); diff --git a/lib/cli/src/commands/app/deploy.rs b/lib/cli/src/commands/app/deploy.rs index 3891d0e0b61..15aea9ba164 100644 --- a/lib/cli/src/commands/app/deploy.rs +++ b/lib/cli/src/commands/app/deploy.rs @@ -11,7 +11,7 @@ use dialoguer::Confirm; use is_terminal::IsTerminal; use std::io::Write; use std::{path::PathBuf, str::FromStr, time::Duration}; -use wasmer_api::{ +use wasmer_backend_api::{ types::{DeployApp, DeployAppVersion}, WasmerClient, }; @@ -185,7 +185,7 @@ impl CmdAppDeploy { anyhow::bail!("No owner specified: use --owner XXX"); } - let user = wasmer_api::query::current_user_with_namespaces(client, None).await?; + let user = wasmer_backend_api::query::current_user_with_namespaces(client, None).await?; let owner = crate::utils::prompts::prompt_for_namespace( "Who should own this app?", None, @@ -274,7 +274,7 @@ impl AsyncCliCommand for CmdAppDeploy { // We want to allow the user to specify the app name interactively. let mut app_yaml: serde_yaml::Value = serde_yaml::from_str(&config_str)?; let maybe_edge_app = if let Some(app_id) = app_yaml.get("app_id").and_then(|s| s.as_str()) { - wasmer_api::query::get_app_by_id(&client, app_id.to_owned()) + wasmer_backend_api::query::get_app_by_id(&client, app_id.to_owned()) .await .ok() } else { @@ -285,12 +285,13 @@ impl AsyncCliCommand for CmdAppDeploy { .get_owner(&client, &mut app_yaml, maybe_edge_app.as_ref()) .await?; - if !wasmer_api::query::viewer_can_deploy_to_namespace(&client, &owner).await? { + if !wasmer_backend_api::query::viewer_can_deploy_to_namespace(&client, &owner).await? { eprintln!("It seems you don't have access to {}", owner.bold()); if self.non_interactive { anyhow::bail!("Please, change the owner before deploying or check your current user with `{} whoami`.", std::env::args().next().unwrap_or("wasmer".into())); } else { - let user = wasmer_api::query::current_user_with_namespaces(&client, None).await?; + let user = + wasmer_backend_api::query::current_user_with_namespaces(&client, None).await?; owner = crate::utils::prompts::prompt_for_namespace( "Who should own this app?", None, @@ -624,9 +625,9 @@ pub async fn deploy_app( // TODO: respect allow_create flag - let version = wasmer_api::query::publish_deploy_app( + let version = wasmer_backend_api::query::publish_deploy_app( client, - wasmer_api::types::PublishDeployAppVars { + wasmer_backend_api::types::PublishDeployAppVars { config: raw_config, name: app.name.clone().into(), owner: opts.owner.map(|o| o.into()), @@ -665,7 +666,7 @@ pub async fn wait_app( .inner() .to_string(); - let app = wasmer_api::query::get_app_by_id(client, app_id.clone()) + let app = wasmer_backend_api::query::get_app_by_id(client, app_id.clone()) .await .context("could not fetch app from backend")?; diff --git a/lib/cli/src/commands/app/deployments/get.rs b/lib/cli/src/commands/app/deployments/get.rs index 07ccb4150ea..30a3e5656ba 100644 --- a/lib/cli/src/commands/app/deployments/get.rs +++ b/lib/cli/src/commands/app/deployments/get.rs @@ -21,7 +21,7 @@ impl AsyncCliCommand for CmdAppDeploymentGet { async fn run_async(mut self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let item = wasmer_api::query::app_deployment(&client, self.id).await?; + let item = wasmer_backend_api::query::app_deployment(&client, self.id).await?; println!("{}", self.fmt.get().render(&item)); Ok(()) diff --git a/lib/cli/src/commands/app/deployments/list.rs b/lib/cli/src/commands/app/deployments/list.rs index e8e118568c7..f1beea5b11e 100644 --- a/lib/cli/src/commands/app/deployments/list.rs +++ b/lib/cli/src/commands/app/deployments/list.rs @@ -30,14 +30,14 @@ impl AsyncCliCommand for CmdAppDeploymentList { let client = self.env.client()?; let (_ident, app) = self.ident.load_app(&client).await?; - let vars = wasmer_api::types::GetAppDeploymentsVariables { + let vars = wasmer_backend_api::types::GetAppDeploymentsVariables { after: None, first: self.limit.map(|x| x as i32), name: app.name.clone(), offset: self.offset.map(|x| x as i32), owner: app.owner.global_name, }; - let items = wasmer_api::query::app_deployments(&client, vars).await?; + let items = wasmer_backend_api::query::app_deployments(&client, vars).await?; if items.is_empty() { eprintln!("App {} has no deployments!", app.name); diff --git a/lib/cli/src/commands/app/deployments/logs.rs b/lib/cli/src/commands/app/deployments/logs.rs index 426cb3b71a9..f9165608aa8 100644 --- a/lib/cli/src/commands/app/deployments/logs.rs +++ b/lib/cli/src/commands/app/deployments/logs.rs @@ -26,7 +26,7 @@ impl AsyncCliCommand for CmdAppDeploymentLogs { async fn run_async(mut self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let item = wasmer_api::query::app_deployment(&client, self.id).await?; + let item = wasmer_backend_api::query::app_deployment(&client, self.id).await?; let url = item .log_url diff --git a/lib/cli/src/commands/app/get.rs b/lib/cli/src/commands/app/get.rs index 12143139a31..0961163d607 100644 --- a/lib/cli/src/commands/app/get.rs +++ b/lib/cli/src/commands/app/get.rs @@ -1,6 +1,6 @@ //! Get information about an edge app. -use wasmer_api::types::DeployApp; +use wasmer_backend_api::types::DeployApp; use super::util::AppIdentOpts; diff --git a/lib/cli/src/commands/app/list.rs b/lib/cli/src/commands/app/list.rs index 94bb6221ad7..23e955d1875 100644 --- a/lib/cli/src/commands/app/list.rs +++ b/lib/cli/src/commands/app/list.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use futures::{Stream, StreamExt}; -use wasmer_api::types::{DeployApp, DeployAppsSortBy}; +use wasmer_backend_api::types::{DeployApp, DeployAppsSortBy}; use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts}; @@ -65,11 +65,11 @@ impl AsyncCliCommand for CmdAppList { let apps_stream: Pin< Box, anyhow::Error>> + Send + Sync>, > = if let Some(ns) = self.namespace.clone() { - Box::pin(wasmer_api::query::namespace_apps(&client, ns, sort).await) + Box::pin(wasmer_backend_api::query::namespace_apps(&client, ns, sort).await) } else if self.all { - Box::pin(wasmer_api::query::user_accessible_apps(&client, sort).await?) + Box::pin(wasmer_backend_api::query::user_accessible_apps(&client, sort).await?) } else { - Box::pin(wasmer_api::query::user_apps(&client, sort).await) + Box::pin(wasmer_backend_api::query::user_apps(&client, sort).await) }; let mut apps_stream = std::pin::pin!(apps_stream); diff --git a/lib/cli/src/commands/app/logs.rs b/lib/cli/src/commands/app/logs.rs index f04832e8a4d..4ecd47275db 100644 --- a/lib/cli/src/commands/app/logs.rs +++ b/lib/cli/src/commands/app/logs.rs @@ -5,7 +5,7 @@ use colored::Colorize; use comfy_table::{Cell, Table}; use futures::StreamExt; use time::{format_description::well_known::Rfc3339, OffsetDateTime}; -use wasmer_api::types::{Log, LogStream}; +use wasmer_backend_api::types::{Log, LogStream}; use crate::{config::WasmerEnv, opts::ListFormatOpts, utils::render::CliRender}; @@ -127,7 +127,7 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs { // Code duplication to avoid a dependency to `OR` streams. if let Some(instance_id) = &self.instance_id { - let logs_stream = wasmer_api::query::get_app_logs_paginated_filter_instance( + let logs_stream = wasmer_backend_api::query::get_app_logs_paginated_filter_instance( &client, app.name.clone(), app.owner.global_name.to_string(), @@ -162,7 +162,7 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs { } } } else if let Some(request_id) = &self.request_id { - let logs_stream = wasmer_api::query::get_app_logs_paginated_filter_request( + let logs_stream = wasmer_backend_api::query::get_app_logs_paginated_filter_request( &client, app.name.clone(), app.owner.global_name.to_string(), @@ -197,7 +197,7 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs { } } } else { - let logs_stream = wasmer_api::query::get_app_logs_paginated( + let logs_stream = wasmer_backend_api::query::get_app_logs_paginated( &client, app.name.clone(), app.owner.global_name.to_string(), diff --git a/lib/cli/src/commands/app/purge_cache.rs b/lib/cli/src/commands/app/purge_cache.rs index 1d0bef3fc49..0069f79b52b 100644 --- a/lib/cli/src/commands/app/purge_cache.rs +++ b/lib/cli/src/commands/app/purge_cache.rs @@ -46,8 +46,8 @@ impl AsyncCliCommand for CmdAppPurgeCache { version_id.inner() ); - let vars = wasmer_api::types::PurgeCacheForAppVersionVars { id: version_id }; - wasmer_api::query::purge_cache_for_app_version(&client, vars).await?; + let vars = wasmer_backend_api::types::PurgeCacheForAppVersionVars { id: version_id }; + wasmer_backend_api::query::purge_cache_for_app_version(&client, vars).await?; println!("🚽 swirl! All caches have been purged!"); diff --git a/lib/cli/src/commands/app/regions/list.rs b/lib/cli/src/commands/app/regions/list.rs index 88b5e398308..9828d24abb4 100644 --- a/lib/cli/src/commands/app/regions/list.rs +++ b/lib/cli/src/commands/app/regions/list.rs @@ -26,7 +26,7 @@ impl AsyncCliCommand for CmdAppRegionsList { async fn run_async(self) -> Result { let client = self.env.client()?; - let regions = wasmer_api::query::get_all_app_regions(&client).await?; + let regions = wasmer_backend_api::query::get_all_app_regions(&client).await?; println!("{}", self.fmt.format.render(regions.as_slice())); diff --git a/lib/cli/src/commands/app/regions/utils/render.rs b/lib/cli/src/commands/app/regions/utils/render.rs index bb03497fc40..14f0a57bc9c 100644 --- a/lib/cli/src/commands/app/regions/utils/render.rs +++ b/lib/cli/src/commands/app/regions/utils/render.rs @@ -1,6 +1,6 @@ use crate::utils::render::CliRender; use comfy_table::{Cell, Table}; -use wasmer_api::types::AppRegion; +use wasmer_backend_api::types::AppRegion; impl CliRender for AppRegion { fn render_item_table(&self) -> String { diff --git a/lib/cli/src/commands/app/secrets/create.rs b/lib/cli/src/commands/app/secrets/create.rs index 77301e752c9..f0570562aaa 100644 --- a/lib/cli/src/commands/app/secrets/create.rs +++ b/lib/cli/src/commands/app/secrets/create.rs @@ -11,7 +11,7 @@ use std::{ collections::{HashMap, HashSet}, path::{Path, PathBuf}, }; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; /// Create a new app secret. #[derive(clap::Parser, Debug)] @@ -95,7 +95,7 @@ impl CmdAppSecretsCreate { ) -> anyhow::Result> { let names = secrets.iter().map(|s| &s.name); let app_secrets = - wasmer_api::query::get_all_app_secrets_filtered(client, app_id, names).await?; + wasmer_backend_api::query::get_all_app_secrets_filtered(client, app_id, names).await?; let mut sset = HashSet::::from_iter(app_secrets.iter().map(|s| s.name.clone())); let mut ret = HashMap::new(); @@ -142,7 +142,7 @@ impl CmdAppSecretsCreate { app_id: &str, secrets: Vec, ) -> Result<(), anyhow::Error> { - let res = wasmer_api::query::upsert_app_secrets( + let res = wasmer_backend_api::query::upsert_app_secrets( client, app_id, secrets.iter().map(|s| (s.name.as_str(), s.value.as_str())), @@ -173,7 +173,7 @@ impl CmdAppSecretsCreate { }; if should_redeploy { - wasmer_api::query::redeploy_app_by_id(client, app_id).await?; + wasmer_backend_api::query::redeploy_app_by_id(client, app_id).await?; eprintln!("{} Deployment complete", "𖥔".yellow().bold()); } else { eprintln!( diff --git a/lib/cli/src/commands/app/secrets/delete.rs b/lib/cli/src/commands/app/secrets/delete.rs index eba87c7eae7..093b243905c 100644 --- a/lib/cli/src/commands/app/secrets/delete.rs +++ b/lib/cli/src/commands/app/secrets/delete.rs @@ -6,7 +6,7 @@ use colored::Colorize; use dialoguer::theme::ColorfulTheme; use is_terminal::IsTerminal; use std::path::{Path, PathBuf}; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use super::utils::{self, get_secrets}; @@ -91,7 +91,8 @@ impl CmdAppSecretsDelete { } } - let res = wasmer_api::query::delete_app_secret(client, secret.id.into_inner()).await?; + let res = wasmer_backend_api::query::delete_app_secret(client, secret.id.into_inner()) + .await?; match res { Some(res) if !res.success => { diff --git a/lib/cli/src/commands/app/secrets/update.rs b/lib/cli/src/commands/app/secrets/update.rs index 32c20bd586d..ba14eb61480 100644 --- a/lib/cli/src/commands/app/secrets/update.rs +++ b/lib/cli/src/commands/app/secrets/update.rs @@ -11,7 +11,7 @@ use std::{ collections::HashSet, path::{Path, PathBuf}, }; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; /// Update an existing app secret. #[derive(clap::Parser, Debug)] @@ -100,7 +100,7 @@ impl CmdAppSecretsUpdate { ) -> anyhow::Result> { let names = secrets.iter().map(|s| &s.name); let app_secrets = - wasmer_api::query::get_all_app_secrets_filtered(client, app_id, names).await?; + wasmer_backend_api::query::get_all_app_secrets_filtered(client, app_id, names).await?; let sset = HashSet::<&str>::from_iter(app_secrets.iter().map(|s| s.name.as_str())); let mut ret = vec![]; @@ -136,7 +136,7 @@ impl CmdAppSecretsUpdate { app_id: &str, secrets: Vec, ) -> Result<(), anyhow::Error> { - let res = wasmer_api::query::upsert_app_secrets( + let res = wasmer_backend_api::query::upsert_app_secrets( client, app_id, secrets.iter().map(|s| (s.name.as_str(), s.value.as_str())), @@ -167,7 +167,7 @@ impl CmdAppSecretsUpdate { }; if should_redeploy { - wasmer_api::query::redeploy_app_by_id(client, app_id).await?; + wasmer_backend_api::query::redeploy_app_by_id(client, app_id).await?; eprintln!("{} Deployment complete", "𖥔".yellow().bold()); } else { eprintln!( diff --git a/lib/cli/src/commands/app/secrets/utils/mod.rs b/lib/cli/src/commands/app/secrets/utils/mod.rs index 745a716dd9a..a70f8657cf5 100644 --- a/lib/cli/src/commands/app/secrets/utils/mod.rs +++ b/lib/cli/src/commands/app/secrets/utils/mod.rs @@ -6,7 +6,7 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use wasmer_api::{types::Secret as BackendSecret, WasmerClient}; +use wasmer_backend_api::{types::Secret as BackendSecret, WasmerClient}; use crate::commands::app::util::{get_app_config_from_dir, prompt_app_ident, AppIdent}; @@ -30,20 +30,20 @@ pub(super) async fn get_secret_by_name( app_id: &str, secret_name: &str, ) -> anyhow::Result> { - wasmer_api::query::get_app_secret_by_name(client, app_id, secret_name).await + wasmer_backend_api::query::get_app_secret_by_name(client, app_id, secret_name).await } pub(crate) async fn get_secrets( client: &WasmerClient, app_id: &str, -) -> anyhow::Result> { - wasmer_api::query::get_all_app_secrets(client, app_id).await +) -> anyhow::Result> { + wasmer_backend_api::query::get_all_app_secrets(client, app_id).await } pub(crate) async fn get_secret_value( client: &WasmerClient, - secret: &wasmer_api::types::Secret, + secret: &wasmer_backend_api::types::Secret, ) -> anyhow::Result { - wasmer_api::query::get_app_secret_value_by_id(client, secret.id.clone().into_inner()) + wasmer_backend_api::query::get_app_secret_value_by_id(client, secret.id.clone().into_inner()) .await? .ok_or_else(|| { anyhow::anyhow!( @@ -68,7 +68,7 @@ pub(crate) async fn reveal_secrets( client: &WasmerClient, app_id: &str, ) -> anyhow::Result> { - let secrets = wasmer_api::query::get_all_app_secrets(client, app_id).await?; + let secrets = wasmer_backend_api::query::get_all_app_secrets(client, app_id).await?; let mut ret = vec![]; for secret in secrets { let name = secret.name.clone(); diff --git a/lib/cli/src/commands/app/secrets/utils/render.rs b/lib/cli/src/commands/app/secrets/utils/render.rs index 0b679e10b52..103796a4545 100644 --- a/lib/cli/src/commands/app/secrets/utils/render.rs +++ b/lib/cli/src/commands/app/secrets/utils/render.rs @@ -3,7 +3,7 @@ use crate::utils::render::CliRender; use colored::Colorize; use comfy_table::{Cell, Table}; use time::OffsetDateTime; -use wasmer_api::types::{DateTime, Secret as BackendSecret}; +use wasmer_backend_api::types::{DateTime, Secret as BackendSecret}; impl CliRender for Secret { fn render_item_table(&self) -> String { diff --git a/lib/cli/src/commands/app/util.rs b/lib/cli/src/commands/app/util.rs index 72987a2a214..288d9ef9d18 100644 --- a/lib/cli/src/commands/app/util.rs +++ b/lib/cli/src/commands/app/util.rs @@ -3,7 +3,7 @@ use std::{path::Path, str::FromStr}; use anyhow::{bail, Context}; use colored::Colorize; use dialoguer::{theme::ColorfulTheme, Confirm}; -use wasmer_api::{ +use wasmer_backend_api::{ global_id::{GlobalId, NodeKind}, types::DeployApp, WasmerClient, @@ -32,12 +32,14 @@ impl AppIdent { /// Resolve an app identifier through the API. pub async fn resolve(&self, client: &WasmerClient) -> Result { match self { - AppIdent::AppId(app_id) => wasmer_api::query::get_app_by_id(client, app_id.clone()) - .await - .with_context(|| format!("Could not find app with id '{}'", app_id)), + AppIdent::AppId(app_id) => { + wasmer_backend_api::query::get_app_by_id(client, app_id.clone()) + .await + .with_context(|| format!("Could not find app with id '{}'", app_id)) + } AppIdent::AppVersionId(id) => { let (app, _version) = - wasmer_api::query::get_app_version_by_id_with_app(client, id.clone()) + wasmer_backend_api::query::get_app_version_by_id_with_app(client, id.clone()) .await .with_context(|| format!("Could not query for app version id '{}'", id))?; Ok(app) @@ -46,16 +48,16 @@ impl AppIdent { // The API only allows to query by owner + name, // so default to the current user as the owner. // To to so the username must first be retrieved. - let user = wasmer_api::query::current_user(client) + let user = wasmer_backend_api::query::current_user(client) .await? .context("not logged in")?; - wasmer_api::query::get_app(client, user.username, name.clone()) + wasmer_backend_api::query::get_app(client, user.username, name.clone()) .await? .with_context(|| format!("Could not find app with name '{name}'")) } AppIdent::NamespacedName(owner, name) => { - wasmer_api::query::get_app(client, owner.clone(), name.clone()) + wasmer_backend_api::query::get_app(client, owner.clone(), name.clone()) .await? .with_context(|| format!("Could not find app '{owner}/{name}'")) } diff --git a/lib/cli/src/commands/app/version/activate.rs b/lib/cli/src/commands/app/version/activate.rs index 5379a8f7ddd..f4afea5f67b 100644 --- a/lib/cli/src/commands/app/version/activate.rs +++ b/lib/cli/src/commands/app/version/activate.rs @@ -23,7 +23,7 @@ impl AsyncCliCommand for CmdAppVersionActivate { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let app = wasmer_api::query::app_version_activate(&client, self.version).await?; + let app = wasmer_backend_api::query::app_version_activate(&client, self.version).await?; let Some(version) = &app.active_version else { anyhow::bail!("Failed to activate version: backend did not update version!"); diff --git a/lib/cli/src/commands/app/version/get.rs b/lib/cli/src/commands/app/version/get.rs index aa199644c10..66494724e9a 100644 --- a/lib/cli/src/commands/app/version/get.rs +++ b/lib/cli/src/commands/app/version/get.rs @@ -33,7 +33,7 @@ impl AsyncCliCommand for CmdAppVersionGet { let client = self.env.client()?; let (_ident, app) = self.ident.load_app(&client).await?; - let version = wasmer_api::query::get_app_version( + let version = wasmer_backend_api::query::get_app_version( &client, app.owner.global_name, app.name, diff --git a/lib/cli/src/commands/app/version/list.rs b/lib/cli/src/commands/app/version/list.rs index 895a096c7d8..491a79540f6 100644 --- a/lib/cli/src/commands/app/version/list.rs +++ b/lib/cli/src/commands/app/version/list.rs @@ -1,4 +1,4 @@ -use wasmer_api::types::{DeployAppVersionsSortBy, GetDeployAppVersionsVars}; +use wasmer_backend_api::types::{DeployAppVersionsSortBy, GetDeployAppVersionsVars}; use crate::{ commands::{app::util::AppIdentOpts, AsyncCliCommand}, @@ -77,7 +77,8 @@ impl AsyncCliCommand for CmdAppVersionList { let (_ident, app) = self.ident.load_app(&client).await?; let versions = if self.all { - wasmer_api::query::all_app_versions(&client, app.owner.global_name, app.name).await? + wasmer_backend_api::query::all_app_versions(&client, app.owner.global_name, app.name) + .await? } else { let vars = GetDeployAppVersionsVars { owner: app.owner.global_name, @@ -91,7 +92,7 @@ impl AsyncCliCommand for CmdAppVersionList { }; let versions = - wasmer_api::query::get_deploy_app_versions(&client, vars.clone()).await?; + wasmer_backend_api::query::get_deploy_app_versions(&client, vars.clone()).await?; versions .edges diff --git a/lib/cli/src/commands/app/volumes/credentials/mod.rs b/lib/cli/src/commands/app/volumes/credentials/mod.rs index db0f8906b23..38d70515f59 100644 --- a/lib/cli/src/commands/app/volumes/credentials/mod.rs +++ b/lib/cli/src/commands/app/volumes/credentials/mod.rs @@ -30,7 +30,8 @@ impl AsyncCliCommand for CmdAppVolumesCredentials { let (_ident, app) = self.ident.load_app(&client).await?; let creds = - wasmer_api::query::get_app_s3_credentials(&client, app.id.clone().into_inner()).await?; + wasmer_backend_api::query::get_app_s3_credentials(&client, app.id.clone().into_inner()) + .await?; match self.fmt.format { CredsItemFormat::Rclone => { diff --git a/lib/cli/src/commands/app/volumes/credentials/rotate_secrets.rs b/lib/cli/src/commands/app/volumes/credentials/rotate_secrets.rs index 41cf77eb134..e2d041c64f2 100644 --- a/lib/cli/src/commands/app/volumes/credentials/rotate_secrets.rs +++ b/lib/cli/src/commands/app/volumes/credentials/rotate_secrets.rs @@ -28,7 +28,7 @@ impl AsyncCliCommand for CmdAppVolumesRotateSecrets { let client = self.env.client()?; let (_ident, app) = self.ident.load_app(&client).await?; - wasmer_api::query::rotate_s3_secrets(&client, app.id).await?; + wasmer_backend_api::query::rotate_s3_secrets(&client, app.id).await?; // Don't print it here and leave it implied, so users can append the output // of `wasmer app volumes credentials` without worrying about this message. diff --git a/lib/cli/src/commands/app/volumes/list.rs b/lib/cli/src/commands/app/volumes/list.rs index b3601209e0b..6258b729e40 100644 --- a/lib/cli/src/commands/app/volumes/list.rs +++ b/lib/cli/src/commands/app/volumes/list.rs @@ -25,7 +25,8 @@ impl AsyncCliCommand for CmdAppVolumesList { let (_ident, app) = self.ident.load_app(&client).await?; let volumes = - wasmer_api::query::get_app_volumes(&client, &app.owner.global_name, &app.name).await?; + wasmer_backend_api::query::get_app_volumes(&client, &app.owner.global_name, &app.name) + .await?; if volumes.is_empty() { eprintln!("App {} has no volumes!", app.name); diff --git a/lib/cli/src/commands/auth/login/mod.rs b/lib/cli/src/commands/auth/login/mod.rs index a8795c132d8..6d1b93137ba 100644 --- a/lib/cli/src/commands/auth/login/mod.rs +++ b/lib/cli/src/commands/auth/login/mod.rs @@ -10,7 +10,7 @@ use crate::{ }; use futures_util::{stream::FuturesUnordered, StreamExt}; use std::{path::PathBuf, time::Duration}; -use wasmer_api::{types::Nonce, WasmerClient}; +use wasmer_backend_api::{types::Nonce, WasmerClient}; #[derive(Debug, Clone)] enum AuthorizationState { @@ -103,7 +103,7 @@ impl Login { }; let Nonce { auth_url, .. } = - wasmer_api::query::create_nonce(client, "wasmer-cli".to_string(), server_url) + wasmer_backend_api::query::create_nonce(client, "wasmer-cli".to_string(), server_url) .await? .ok_or_else(|| { anyhow::anyhow!("The backend did not return any nonce to auth the login!") @@ -166,29 +166,30 @@ impl Login { async fn do_login(&self, env: &WasmerEnv) -> anyhow::Result { let client = env.client_unauthennticated()?; - let should_login = if let Some(user) = wasmer_api::query::current_user(&client).await? { - #[cfg(not(test))] - { - println!( - "You are already logged in as {} in registry {}.", - user.username.bold(), - env.registry_public_url()?.host_str().unwrap().bold() - ); - let theme = dialoguer::theme::ColorfulTheme::default(); - let dialog = dialoguer::Confirm::with_theme(&theme).with_prompt("Login again?"); - - dialog.interact()? - } - #[cfg(test)] - { - // prevent unused binding warning - _ = user; + let should_login = + if let Some(user) = wasmer_backend_api::query::current_user(&client).await? { + #[cfg(not(test))] + { + println!( + "You are already logged in as {} in registry {}.", + user.username.bold(), + env.registry_public_url()?.host_str().unwrap().bold() + ); + let theme = dialoguer::theme::ColorfulTheme::default(); + let dialog = dialoguer::Confirm::with_theme(&theme).with_prompt("Login again?"); + + dialog.interact()? + } + #[cfg(test)] + { + // prevent unused binding warning + _ = user; - false - } - } else { - true - }; + false + } + } else { + true + }; if !should_login { Ok(AuthorizationState::Cancelled) @@ -228,7 +229,7 @@ impl Login { // This will automatically read the config again, picking up the new edits. let client = env.client()?; - wasmer_api::query::current_user(&client) + wasmer_backend_api::query::current_user(&client) .await? .map(|v| v.username) .ok_or_else(|| anyhow::anyhow!("Not logged in!")) diff --git a/lib/cli/src/commands/auth/logout.rs b/lib/cli/src/commands/auth/logout.rs index 5e6b9f76d72..fac5cb20e4c 100644 --- a/lib/cli/src/commands/auth/logout.rs +++ b/lib/cli/src/commands/auth/logout.rs @@ -39,7 +39,7 @@ impl AsyncCliCommand for Logout { .client() .map_err(|_| anyhow::anyhow!("Not logged into registry {host_str}"))?; - let user = wasmer_api::query::current_user(&client) + let user = wasmer_backend_api::query::current_user(&client) .await .map_err(|e| anyhow::anyhow!("Not logged into registry {host_str}: {e}"))? .ok_or_else(|| anyhow::anyhow!("Not logged into registry {host_str}"))?; @@ -92,7 +92,7 @@ impl AsyncCliCommand for Logout { }; if should_revoke { - wasmer_api::query::revoke_token(&client, token).await?; + wasmer_backend_api::query::revoke_token(&client, token).await?; println!( "Token for user {} in registry {host_str} correctly revoked", user.username.bold() diff --git a/lib/cli/src/commands/auth/whoami.rs b/lib/cli/src/commands/auth/whoami.rs index d7c10e0f046..25b1423a1f5 100644 --- a/lib/cli/src/commands/auth/whoami.rs +++ b/lib/cli/src/commands/auth/whoami.rs @@ -20,7 +20,7 @@ impl AsyncCliCommand for Whoami { async fn run_async(self) -> Result { let client = self.env.client_unauthennticated()?; let host_str = self.env.registry_public_url()?.host_str().unwrap().bold(); - let user = wasmer_api::query::current_user(&client) + let user = wasmer_backend_api::query::current_user(&client) .await? .ok_or_else(|| anyhow::anyhow!("Not logged in registry {host_str}"))?; println!( diff --git a/lib/cli/src/commands/config.rs b/lib/cli/src/commands/config.rs index 0c8e0e05ebe..38aba98eaa3 100644 --- a/lib/cli/src/commands/config.rs +++ b/lib/cli/src/commands/config.rs @@ -273,7 +273,9 @@ impl GetOrSet { config.registry.set_current_registry(&s.url).await; let current_registry = config.registry.get_current_registry(); if let Ok(client) = env.client() { - if let Some(u) = wasmer_api::query::current_user(&client).await? { + if let Some(u) = + wasmer_backend_api::query::current_user(&client).await? + { println!( "Successfully logged into registry {current_registry:?} as user {u:?}" ); diff --git a/lib/cli/src/commands/domain/get.rs b/lib/cli/src/commands/domain/get.rs index ace53e8d328..1fd6deaab51 100644 --- a/lib/cli/src/commands/domain/get.rs +++ b/lib/cli/src/commands/domain/get.rs @@ -19,7 +19,8 @@ impl AsyncCliCommand for CmdDomainGet { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - if let Some(domain) = wasmer_api::query::get_domain_with_records(&client, self.name).await? + if let Some(domain) = + wasmer_backend_api::query::get_domain_with_records(&client, self.name).await? { println!("{}", self.fmt.format.render(&domain)); } else { diff --git a/lib/cli/src/commands/domain/list.rs b/lib/cli/src/commands/domain/list.rs index d2858bbd7de..89fd218854b 100644 --- a/lib/cli/src/commands/domain/list.rs +++ b/lib/cli/src/commands/domain/list.rs @@ -1,4 +1,4 @@ -use wasmer_api::types::GetAllDomainsVariables; +use wasmer_backend_api::types::GetAllDomainsVariables; use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts}; @@ -21,7 +21,7 @@ impl AsyncCliCommand for CmdDomainList { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let domains = wasmer_api::query::get_all_domains( + let domains = wasmer_backend_api::query::get_all_domains( &client, GetAllDomainsVariables { first: None, diff --git a/lib/cli/src/commands/domain/register.rs b/lib/cli/src/commands/domain/register.rs index 97c954ca72c..0cc04d5d6a8 100644 --- a/lib/cli/src/commands/domain/register.rs +++ b/lib/cli/src/commands/domain/register.rs @@ -27,7 +27,7 @@ impl AsyncCliCommand for CmdDomainRegister { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let domain = wasmer_api::query::register_domain( + let domain = wasmer_backend_api::query::register_domain( &client, self.name, self.namespace, diff --git a/lib/cli/src/commands/domain/zonefile.rs b/lib/cli/src/commands/domain/zonefile.rs index 830c9f820df..219fb950d86 100644 --- a/lib/cli/src/commands/domain/zonefile.rs +++ b/lib/cli/src/commands/domain/zonefile.rs @@ -39,7 +39,7 @@ impl AsyncCliCommand for CmdZoneFileGet { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; if let Some(domain) = - wasmer_api::query::get_domain_zone_file(&client, self.domain_name).await? + wasmer_backend_api::query::get_domain_zone_file(&client, self.domain_name).await? { let zone_file_contents = domain.zone_file; if let Some(zone_file_path) = self.zone_file_path { @@ -62,7 +62,7 @@ impl AsyncCliCommand for CmdZoneFileSync { async fn run_async(self) -> Result<(), anyhow::Error> { let data = std::fs::read(&self.zone_file_path).context("Unable to read file")?; let zone_file_contents = String::from_utf8(data).context("Not a valid UTF-8 sequence")?; - let domain = wasmer_api::query::upsert_domain_from_zone_file( + let domain = wasmer_backend_api::query::upsert_domain_from_zone_file( &self.env.client()?, zone_file_contents, !self.no_delete_missing_records, diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs index 7ef93e7a49b..645a2207904 100644 --- a/lib/cli/src/commands/init.rs +++ b/lib/cli/src/commands/init.rs @@ -396,7 +396,7 @@ async fn construct_manifest( Some(n) => Some(n), None => { if let Ok(client) = env.client() { - if let Ok(Some(u)) = wasmer_api::query::current_user(&client).await { + if let Ok(Some(u)) = wasmer_backend_api::query::current_user(&client).await { Some(u.username) } else { None diff --git a/lib/cli/src/commands/namespace/create.rs b/lib/cli/src/commands/namespace/create.rs index 4770eaaf381..dbe528233ef 100644 --- a/lib/cli/src/commands/namespace/create.rs +++ b/lib/cli/src/commands/namespace/create.rs @@ -24,11 +24,11 @@ impl AsyncCliCommand for CmdNamespaceCreate { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let vars = wasmer_api::types::CreateNamespaceVars { + let vars = wasmer_backend_api::types::CreateNamespaceVars { name: self.name.clone(), description: self.description.clone(), }; - let namespace = wasmer_api::query::create_namespace(&client, vars).await?; + let namespace = wasmer_backend_api::query::create_namespace(&client, vars).await?; println!("{}", self.fmt.get().render(&namespace)); diff --git a/lib/cli/src/commands/namespace/get.rs b/lib/cli/src/commands/namespace/get.rs index 9ca3a0cfcc7..48406d3bb2f 100644 --- a/lib/cli/src/commands/namespace/get.rs +++ b/lib/cli/src/commands/namespace/get.rs @@ -22,7 +22,7 @@ impl AsyncCliCommand for CmdNamespaceGet { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let namespace = wasmer_api::query::get_namespace(&client, self.name) + let namespace = wasmer_backend_api::query::get_namespace(&client, self.name) .await? .context("namespace not found")?; diff --git a/lib/cli/src/commands/namespace/list.rs b/lib/cli/src/commands/namespace/list.rs index a5e61fb368b..333ce037e17 100644 --- a/lib/cli/src/commands/namespace/list.rs +++ b/lib/cli/src/commands/namespace/list.rs @@ -16,7 +16,7 @@ impl AsyncCliCommand for CmdNamespaceList { async fn run_async(self) -> Result<(), anyhow::Error> { let client = self.env.client()?; - let namespaces = wasmer_api::query::user_namespaces(&client).await?; + let namespaces = wasmer_backend_api::query::user_namespaces(&client).await?; println!("{}", self.fmt.format.render(&namespaces)); diff --git a/lib/cli/src/commands/package/common/mod.rs b/lib/cli/src/commands/package/common/mod.rs index 9572655a9b7..dc7eb2112c6 100644 --- a/lib/cli/src/commands/package/common/mod.rs +++ b/lib/cli/src/commands/package/common/mod.rs @@ -11,7 +11,7 @@ use std::{ collections::BTreeMap, path::{Path, PathBuf}, }; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use wasmer_config::package::{Manifest, NamedPackageIdent, PackageHash}; use wasmer_package::package::Package; @@ -51,7 +51,7 @@ pub(super) async fn upload( let session_uri = { let default_timeout_secs = Some(60 * 30); - let q = wasmer_api::query::get_signed_url_for_package_upload( + let q = wasmer_backend_api::query::get_signed_url_for_package_upload( client, default_timeout_secs, Some(hash_str), diff --git a/lib/cli/src/commands/package/common/wait.rs b/lib/cli/src/commands/package/common/wait.rs index 67b54e3deea..0aef557cfae 100644 --- a/lib/cli/src/commands/package/common/wait.rs +++ b/lib/cli/src/commands/package/common/wait.rs @@ -1,5 +1,5 @@ use futures::StreamExt; -use wasmer_api::{types::PackageVersionState, WasmerClient}; +use wasmer_backend_api::{types::PackageVersionState, WasmerClient}; /// Different conditions that can be "awaited" when publishing a package. #[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)] @@ -79,7 +79,7 @@ impl From for WaitPackageState { pub async fn wait_package( client: &WasmerClient, to_wait: PublishWait, - package_version_id: wasmer_api::types::Id, + package_version_id: wasmer_backend_api::types::Id, timeout: humantime::Duration, ) -> anyhow::Result<()> { if let PublishWait::None = to_wait { @@ -89,7 +89,8 @@ pub async fn wait_package( let package_version_id = package_version_id.into_inner(); let mut stream = - wasmer_api::subscription::package_version_ready(client, &package_version_id).await?; + wasmer_backend_api::subscription::package_version_ready(client, &package_version_id) + .await?; let mut state: WaitPackageState = to_wait.into(); diff --git a/lib/cli/src/commands/package/download.rs b/lib/cli/src/commands/package/download.rs index 8c81d9b6cca..26206b84a82 100644 --- a/lib/cli/src/commands/package/download.rs +++ b/lib/cli/src/commands/package/download.rs @@ -109,7 +109,7 @@ impl PackageDownload { let rt = tokio::runtime::Runtime::new()?; let package = rt - .block_on(wasmer_api::query::get_package_version( + .block_on(wasmer_backend_api::query::get_package_version( &client, full_name.clone(), version.clone(), @@ -147,7 +147,7 @@ impl PackageDownload { let client = self.env.client_unauthennticated()?; let rt = tokio::runtime::Runtime::new()?; - let pkg = rt.block_on(wasmer_api::query::get_package_release(&client, &hash.to_string()))? + let pkg = rt.block_on(wasmer_backend_api::query::get_package_release(&client, &hash.to_string()))? .with_context(|| format!("Package with {hash} does not exist in the registry, or is not accessible"))?; let ident = hash.to_string(); diff --git a/lib/cli/src/commands/package/publish.rs b/lib/cli/src/commands/package/publish.rs index 4b3fbdaebe0..df34b4751d1 100644 --- a/lib/cli/src/commands/package/publish.rs +++ b/lib/cli/src/commands/package/publish.rs @@ -12,7 +12,7 @@ use crate::{ use colored::Colorize; use is_terminal::IsTerminal; use std::path::{Path, PathBuf}; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use wasmer_config::package::{Manifest, PackageIdent}; /// Publish (push and tag) a package to the registry. diff --git a/lib/cli/src/commands/package/push.rs b/lib/cli/src/commands/package/push.rs index 0c42ce10e27..af4318af597 100644 --- a/lib/cli/src/commands/package/push.rs +++ b/lib/cli/src/commands/package/push.rs @@ -7,7 +7,7 @@ use anyhow::Context; use colored::Colorize; use is_terminal::IsTerminal; use std::path::{Path, PathBuf}; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use wasmer_config::package::{Manifest, PackageHash}; use wasmer_package::package::Package; @@ -78,7 +78,7 @@ impl PackagePush { anyhow::bail!("No package namespace specified: use --namespace XXX"); } - let user = wasmer_api::query::current_user_with_namespaces(client, None).await?; + let user = wasmer_backend_api::query::current_user_with_namespaces(client, None).await?; let owner = crate::utils::prompts::prompt_for_namespace( "Choose a namespace to push the package to", None, @@ -112,7 +112,7 @@ impl PackagePush { } async fn should_push(&self, client: &WasmerClient, hash: &PackageHash) -> anyhow::Result { - let res = wasmer_api::query::get_package_release(client, &hash.to_string()).await; + let res = wasmer_backend_api::query::get_package_release(client, &hash.to_string()).await; tracing::info!("{:?}", res); res.map(|p| p.is_none()) } @@ -140,7 +140,7 @@ impl PackagePush { spinner_ok!(pb, "Package correctly uploaded"); let pb = make_spinner!(self.quiet, "Waiting for package to become available..."); - match wasmer_api::query::push_package_release( + match wasmer_backend_api::query::push_package_release( client, name.as_deref(), namespace, diff --git a/lib/cli/src/commands/package/tag.rs b/lib/cli/src/commands/package/tag.rs index d9361349566..d0a5babf52e 100644 --- a/lib/cli/src/commands/package/tag.rs +++ b/lib/cli/src/commands/package/tag.rs @@ -13,7 +13,7 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use wasmer_config::package::{ Manifest, NamedPackageId, NamedPackageIdent, PackageBuilder, PackageHash, PackageIdent, }; @@ -154,7 +154,7 @@ impl PackageTag { client: &WasmerClient, id: &NamedPackageId, manifest: Option<&Manifest>, - package_release_id: &wasmer_api::types::Id, + package_release_id: &wasmer_backend_api::types::Id, ) -> anyhow::Result<()> { tracing::info!( "Tagging package with registry id {:?} and specifier {:?}", @@ -200,7 +200,7 @@ impl PackageTag { None }; - let r = wasmer_api::query::tag_package_release( + let r = wasmer_backend_api::query::tag_package_release( client, maybe_description.as_deref(), maybe_homepage.as_deref(), @@ -241,7 +241,7 @@ impl PackageTag { client: &WasmerClient, hash: &PackageHash, check_package_exists: bool, - ) -> anyhow::Result { + ) -> anyhow::Result { let pb = make_spinner!( self.quiet || check_package_exists, "Checking if the package exists.." @@ -249,7 +249,9 @@ impl PackageTag { tracing::debug!("Searching for package with hash: {hash}"); - let pkg = match wasmer_api::query::get_package_release(client, &hash.to_string()).await? { + let pkg = match wasmer_backend_api::query::get_package_release(client, &hash.to_string()) + .await? + { Some(p) => p, None => { spinner_err!(pb, "The package is not in the registry!"); @@ -366,7 +368,7 @@ impl PackageTag { anyhow::bail!("No package namespace specified: use --namespace "); } - let user = wasmer_api::query::current_user_with_namespaces(client, None).await?; + let user = wasmer_backend_api::query::current_user_with_namespaces(client, None).await?; crate::utils::prompts::prompt_for_namespace("Choose a namespace", None, Some(&user)) } @@ -403,7 +405,7 @@ impl PackageTag { format!("Checking if a version of {full_pkg_name} already exists..") ); - if let Some(registry_version) = wasmer_api::query::get_package_version( + if let Some(registry_version) = wasmer_backend_api::query::get_package_version( client, full_pkg_name.to_string(), String::from("latest"), @@ -425,7 +427,7 @@ impl PackageTag { // Must necessarily bump if there's a package with the chosen version with a different hash. let must_bump = { - let maybe_pkg = wasmer_api::query::get_package_version( + let maybe_pkg = wasmer_backend_api::query::get_package_version( client, full_pkg_name.to_string(), user_version.to_string(), @@ -590,7 +592,7 @@ impl PackageTag { return Ok(false); } - let pkg = wasmer_api::query::get_package_version( + let pkg = wasmer_backend_api::query::get_package_version( client, id.full_name.clone(), id.version.to_string(), diff --git a/lib/cli/src/commands/ssh.rs b/lib/cli/src/commands/ssh.rs index 046838d1fb2..e5725986b7e 100644 --- a/lib/cli/src/commands/ssh.rs +++ b/lib/cli/src/commands/ssh.rs @@ -1,7 +1,7 @@ //! Edge SSH command. use anyhow::Context; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use super::AsyncCliCommand; use crate::{config::WasmerEnv, edge_config::EdgeConfig}; @@ -122,7 +122,10 @@ async fn acquire_ssh_token( /// Create a new token for SSH access through the backend API. async fn create_ssh_token(client: &WasmerClient) -> Result { - wasmer_api::query::generate_deploy_config_token_raw(client, wasmer_api::query::TokenKind::SSH) - .await - .context("Could not create token for ssh access") + wasmer_backend_api::query::generate_deploy_config_token_raw( + client, + wasmer_backend_api::query::TokenKind::SSH, + ) + .await + .context("Could not create token for ssh access") } diff --git a/lib/cli/src/config/env.rs b/lib/cli/src/config/env.rs index a328f66d40c..016b1765c86 100644 --- a/lib/cli/src/config/env.rs +++ b/lib/cli/src/config/env.rs @@ -3,7 +3,7 @@ use anyhow::{Context, Error}; use lazy_static::lazy_static; use std::path::{Path, PathBuf}; use url::Url; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; lazy_static! { pub static ref DEFAULT_WASMER_CLI_USER_AGENT: String = @@ -141,7 +141,7 @@ impl WasmerEnv { let proxy = self.proxy()?; - let client = wasmer_api::WasmerClient::new_with_proxy( + let client = wasmer_backend_api::WasmerClient::new_with_proxy( registry_url, &DEFAULT_WASMER_CLI_USER_AGENT, proxy, diff --git a/lib/cli/src/config/mod.rs b/lib/cli/src/config/mod.rs index 3dd54e40c59..7069c0fd3ec 100644 --- a/lib/cli/src/config/mod.rs +++ b/lib/cli/src/config/mod.rs @@ -4,7 +4,7 @@ pub use env::*; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use url::Url; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; pub static GLOBAL_CONFIG_FILE_NAME: &str = "wasmer.toml"; pub static DEFAULT_PROD_REGISTRY: &str = "https://registry.wasmer.io/graphql"; @@ -123,7 +123,9 @@ fn endpoint_from_domain_name(domain_name: &str) -> String { async fn test_if_registry_present(registry: &str) -> anyhow::Result<()> { let client = WasmerClient::new(url::Url::parse(registry)?, &DEFAULT_WASMER_CLI_USER_AGENT)?; - wasmer_api::query::current_user(&client).await.map(|_| ()) + wasmer_backend_api::query::current_user(&client) + .await + .map(|_| ()) } #[derive(PartialEq, Eq, Copy, Clone)] diff --git a/lib/cli/src/types.rs b/lib/cli/src/types.rs index 507ac788284..cf15a837406 100644 --- a/lib/cli/src/types.rs +++ b/lib/cli/src/types.rs @@ -1,5 +1,5 @@ use comfy_table::Table; -use wasmer_api::types::{ +use wasmer_backend_api::types::{ DeployApp, DeployAppVersion, Deployment, DnsDomain, DnsDomainWithRecords, Namespace, }; @@ -163,7 +163,7 @@ impl CliRender for DeployAppVersion { } } -impl CliRender for wasmer_api::types::AppVersionVolume { +impl CliRender for wasmer_backend_api::types::AppVersionVolume { fn render_item_table(&self) -> String { let mut table = Table::new(); table.add_rows([ @@ -189,7 +189,7 @@ impl CliRender for wasmer_api::types::AppVersionVolume { } } -fn format_disk_size_opt(value: Option) -> String { +fn format_disk_size_opt(value: Option) -> String { let value = value.and_then(|x| { let y: Option = x.0.try_into().ok(); y @@ -259,7 +259,7 @@ impl CliRender for Deployment { } } -impl CliRender for wasmer_api::types::NakedDeployment { +impl CliRender for wasmer_backend_api::types::NakedDeployment { fn render_item_table(&self) -> String { let mut table = Table::new(); table.add_rows([ @@ -295,7 +295,7 @@ impl CliRender for wasmer_api::types::NakedDeployment { } } -impl CliRender for wasmer_api::types::AutobuildRepository { +impl CliRender for wasmer_backend_api::types::AutobuildRepository { fn render_item_table(&self) -> String { let mut table = Table::new(); table.add_rows([ diff --git a/lib/cli/src/utils/package_wizard/mod.rs b/lib/cli/src/utils/package_wizard/mod.rs index 08383cf4584..d13fee9b43d 100644 --- a/lib/cli/src/utils/package_wizard/mod.rs +++ b/lib/cli/src/utils/package_wizard/mod.rs @@ -2,7 +2,7 @@ // // use anyhow::Context; // use dialoguer::{theme::ColorfulTheme, Select}; -// use wasmer_api::{types::UserWithNamespaces, WasmerClient}; +// use wasmer_backend_api::{types::UserWithNamespaces, WasmerClient}; // // use super::prompts::PackageCheckMode; // @@ -77,7 +77,7 @@ // } // // pub struct PackageWizardOutput { -// pub api: Option, +// pub api: Option, // pub local_path: Option, // pub local_manifest: Option, // } diff --git a/lib/cli/src/utils/prompts.rs b/lib/cli/src/utils/prompts.rs index c5ab5da3020..7846477cfe1 100644 --- a/lib/cli/src/utils/prompts.rs +++ b/lib/cli/src/utils/prompts.rs @@ -1,7 +1,7 @@ use anyhow::Context; use colored::Colorize; use dialoguer::{theme::ColorfulTheme, Select}; -use wasmer_api::WasmerClient; +use wasmer_backend_api::WasmerClient; use wasmer_config::package::NamedPackageIdent; pub fn prompt_for_ident(message: &str, default: Option<&str>) -> Result { @@ -90,7 +90,13 @@ pub async fn prompt_for_package( default: Option<&str>, check: Option, client: Option<&WasmerClient>, -) -> Result<(NamedPackageIdent, Option), anyhow::Error> { +) -> Result< + ( + NamedPackageIdent, + Option, + ), + anyhow::Error, +> { loop { let ident = prompt_for_package_ident(message, default)?; @@ -98,12 +104,16 @@ pub async fn prompt_for_package( let api = client.expect("Check mode specified, but no API provided"); let pkg = if let Some(v) = ident.version_opt() { - wasmer_api::query::get_package_version(api, ident.full_name(), v.to_string()) - .await - .context("could not query backend for package")? - .map(|p| p.package) + wasmer_backend_api::query::get_package_version( + api, + ident.full_name(), + v.to_string(), + ) + .await + .context("could not query backend for package")? + .map(|p| p.package) } else { - wasmer_api::query::get_package(api, ident.to_string()) + wasmer_backend_api::query::get_package(api, ident.to_string()) .await .context("could not query backend for package")? }; @@ -144,7 +154,7 @@ pub async fn prompt_for_package( pub fn prompt_for_namespace( message: &str, default: Option<&str>, - user: Option<&wasmer_api::types::UserWithNamespaces>, + user: Option<&wasmer_backend_api::types::UserWithNamespaces>, ) -> Result { if let Some(user) = user { let namespaces = user @@ -205,7 +215,8 @@ pub async fn prompt_new_app_name( "WARN".bold().yellow() ) } else if let Some(api) = &api { - let app = wasmer_api::query::get_app(api, namespace.to_string(), ident.clone()).await?; + let app = wasmer_backend_api::query::get_app(api, namespace.to_string(), ident.clone()) + .await?; eprint!("Checking name availability... "); if app.is_some() { eprintln!( @@ -237,7 +248,7 @@ pub async fn prompt_new_app_alias( let ident = prompt_for_ident(message, default)?; if let Some(api) = &api { - let app = wasmer_api::query::get_app_by_alias(api, ident.clone()).await?; + let app = wasmer_backend_api::query::get_app_by_alias(api, ident.clone()).await?; eprintln!("Checking name availability..."); if app.is_some() { eprintln!( From 14d9a98f808a784e305bd41598a35b655200a282 Mon Sep 17 00:00:00 2001 From: Edoardo Marangoni Date: Tue, 29 Oct 2024 13:59:14 +0100 Subject: [PATCH 2/2] feat: Rename `wasmer-api` in `argus` --- Cargo.lock | 54 +++++++++---------- tests/wasmer-argus/Cargo.toml | 4 +- tests/wasmer-argus/src/argus/config.rs | 2 +- tests/wasmer-argus/src/argus/mod.rs | 2 +- tests/wasmer-argus/src/argus/packages.rs | 2 +- .../src/argus/tester/cli_tester.rs | 2 +- .../src/argus/tester/lib_tester.rs | 2 +- tests/wasmer-argus/src/argus/tester/mod.rs | 2 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13ec136d362..bdb04fd75b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6270,56 +6270,56 @@ dependencies = [ ] [[package]] -name = "wasmer-api" -version = "0.1.0" +name = "wasmer-argus" +version = "5.0.0-rc.1" dependencies = [ "anyhow", - "async-tungstenite", - "base64", + "async-trait", + "clap", "cynic", + "derive_more", "futures", - "getrandom", - "graphql-ws-client", - "harsh", - "merge-streams", - "pin-project-lite", + "indicatif", + "log", "reqwest", "serde", "serde_json", - "serde_path_to_error", - "time 0.3.36", + "shared-buffer", "tokio", - "tokio-tungstenite 0.24.0", "tracing", + "tracing-subscriber", "url", - "uuid", - "wasmer-config", - "wasmer-package", + "wasmer", + "wasmer-backend-api", "webc", ] [[package]] -name = "wasmer-argus" -version = "5.0.0-rc.1" +name = "wasmer-backend-api" +version = "0.1.0" dependencies = [ "anyhow", - "async-trait", - "clap", + "async-tungstenite", + "base64", "cynic", - "derive_more", "futures", - "indicatif", - "log", + "getrandom", + "graphql-ws-client", + "harsh", + "merge-streams", + "pin-project-lite", "reqwest", "serde", "serde_json", - "shared-buffer", + "serde_path_to_error", + "time 0.3.36", "tokio", + "tokio-tungstenite 0.24.0", "tracing", - "tracing-subscriber", "url", - "wasmer", - "wasmer-api", + "uuid", + "wasmer-config", + "wasmer-package", "webc", ] @@ -6486,7 +6486,7 @@ dependencies = [ "walkdir", "wasm-coredump-builder", "wasmer", - "wasmer-api", + "wasmer-backend-api", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-llvm", diff --git a/tests/wasmer-argus/Cargo.toml b/tests/wasmer-argus/Cargo.toml index 92150278856..6aa3db60828 100644 --- a/tests/wasmer-argus/Cargo.toml +++ b/tests/wasmer-argus/Cargo.toml @@ -19,7 +19,7 @@ cynic = "3.4.3" url = "2.5.0" futures = "0.3.30" tracing = "0.1.40" -tokio = { workspace = true, features = ["rt-multi-thread", "sync", "time", "fs"] } +tokio = { workspace = true, features = ["rt", "macros", "rt-multi-thread", "sync", "time", "fs"] } clap = {version = "4.4.11", features = ["derive", "string"]} tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } serde = { version = "1.0.197", features = ["derive"] } @@ -28,7 +28,7 @@ wasmer = { version = "5.0.0-rc.1", path = "../../lib/api", features = ["engine", derive_more = "0.99.17" webc.workspace = true async-trait = "0.1.77" -wasmer-api = { path = "../../lib/backend-api" } +wasmer-backend-api = { path = "../../lib/backend-api" } shared-buffer.workspace = true diff --git a/tests/wasmer-argus/src/argus/config.rs b/tests/wasmer-argus/src/argus/config.rs index 92c7bbdca4a..723e8b65ad9 100644 --- a/tests/wasmer-argus/src/argus/config.rs +++ b/tests/wasmer-argus/src/argus/config.rs @@ -57,7 +57,7 @@ pub struct ArgusConfig { #[arg(long)] pub cli_path: Option, - /// Whether or not this run should use the linked [`wasmer-api`] library instead of the CLI. + /// Whether or not this run should use the linked [`wasmer-backend-api`] library instead of the CLI. #[cfg(feature = "wasmer_lib")] #[arg(long, conflicts_with = "cli_path")] pub use_lib: bool, diff --git a/tests/wasmer-argus/src/argus/mod.rs b/tests/wasmer-argus/src/argus/mod.rs index 63260730592..dac35a4cb7d 100644 --- a/tests/wasmer-argus/src/argus/mod.rs +++ b/tests/wasmer-argus/src/argus/mod.rs @@ -16,7 +16,7 @@ use tokio::{ }; use tracing::*; use url::Url; -use wasmer_api::{types::PackageVersionWithPackage, WasmerClient}; +use wasmer_backend_api::{types::PackageVersionWithPackage, WasmerClient}; #[derive(Debug, Clone)] pub struct Argus { diff --git a/tests/wasmer-argus/src/argus/packages.rs b/tests/wasmer-argus/src/argus/packages.rs index d55dc03a0ff..6fd8a35a82e 100644 --- a/tests/wasmer-argus/src/argus/packages.rs +++ b/tests/wasmer-argus/src/argus/packages.rs @@ -11,7 +11,7 @@ use tokio::{ }; use tracing::*; use url::Url; -use wasmer_api::{ +use wasmer_backend_api::{ query::get_package_versions_stream, types::{AllPackageVersionsVars, PackageVersionSortBy, PackageVersionWithPackage}, }; diff --git a/tests/wasmer-argus/src/argus/tester/cli_tester.rs b/tests/wasmer-argus/src/argus/tester/cli_tester.rs index e84f0cd1274..5e621be6884 100644 --- a/tests/wasmer-argus/src/argus/tester/cli_tester.rs +++ b/tests/wasmer-argus/src/argus/tester/cli_tester.rs @@ -3,7 +3,7 @@ use indicatif::ProgressBar; use std::{fs::File, io::BufReader, path::Path, process::Command, sync::Arc}; use tokio::time::{self, Instant}; use tracing::*; -use wasmer_api::types::PackageVersionWithPackage; +use wasmer_backend_api::types::PackageVersionWithPackage; use webc::{v2::read::OwnedReader, v3::read::OwnedReader as OwnedReaderV3, Container, Version}; use super::{TestReport, Tester}; diff --git a/tests/wasmer-argus/src/argus/tester/lib_tester.rs b/tests/wasmer-argus/src/argus/tester/lib_tester.rs index 8d27bd290e9..d44b6929804 100644 --- a/tests/wasmer-argus/src/argus/tester/lib_tester.rs +++ b/tests/wasmer-argus/src/argus/tester/lib_tester.rs @@ -5,7 +5,7 @@ use std::{fs::File, io::BufReader, sync::Arc}; use tokio::time; use tracing::*; use wasmer::{sys::Features, Engine, NativeEngineExt, Target}; -use wasmer_api::types::PackageVersionWithPackage; +use wasmer_backend_api::types::PackageVersionWithPackage; use webc::{v2::read::OwnedReader, v3::read::OwnedReader as OwnedReaderV3, Container, Version}; pub struct LibRunner<'a> { diff --git a/tests/wasmer-argus/src/argus/tester/mod.rs b/tests/wasmer-argus/src/argus/tester/mod.rs index ea75446d068..8b8887f148f 100644 --- a/tests/wasmer-argus/src/argus/tester/mod.rs +++ b/tests/wasmer-argus/src/argus/tester/mod.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; use std::{sync::Arc, time::Duration}; -use wasmer_api::types::PackageVersionWithPackage; +use wasmer_backend_api::types::PackageVersionWithPackage; use super::ArgusConfig;