feat: Rename wasmer-api to wasmer-backend-api

This commit is contained in:
Edoardo Marangoni
2024-10-29 13:48:14 +01:00
parent 7a75251846
commit cc969fc56a
52 changed files with 188 additions and 157 deletions

View File

@ -1,9 +1,9 @@
[package] [package]
name = "wasmer-api" name = "wasmer-backend-api"
version = "0.1.0" version = "0.1.0"
description = "Client library for the Wasmer GraphQL API" description = "Client library for the Wasmer GraphQL API"
readme = "README.md" readme = "README.md"
documentation = "https://docs.rs/wasmer-api" documentation = "https://docs.rs/wasmer-backend-api"
authors.workspace = true authors.workspace = true
edition.workspace = true edition.workspace = true

View File

@ -1,4 +1,4 @@
# wasmer-api # wasmer-backend-api
GraphQL API client for the [Wasmer](https://wasmer.io) backend. GraphQL API client for the [Wasmer](https://wasmer.io) backend.

View File

@ -144,7 +144,7 @@ virtual-mio = { version = "0.5.0", path = "../virtual-io" }
# Wasmer-owned dependencies. # Wasmer-owned dependencies.
webc = { workspace = true } 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" lazy_static = "1.4.0"
# Used by the mount command # Used by the mount command

View File

@ -3,7 +3,7 @@ use crate::config::WasmerEnv;
use anyhow::{Context, Error}; use anyhow::{Context, Error};
use clap::Parser; use clap::Parser;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use wasmer_api::{ use wasmer_backend_api::{
types::{Bindings, ProgrammingLanguage}, types::{Bindings, ProgrammingLanguage},
WasmerClient, WasmerClient,
}; };
@ -102,7 +102,7 @@ async fn lookup_bindings_for_package(
pkg: &NamedPackageIdent, pkg: &NamedPackageIdent,
language: &ProgrammingLanguage, language: &ProgrammingLanguage,
) -> Result<Bindings, Error> { ) -> Result<Bindings, Error> {
let all_bindings = wasmer_api::query::list_bindings( let all_bindings = wasmer_backend_api::query::list_bindings(
client, client,
&pkg.name, &pkg.name,
pkg.version_opt().map(|v| v.to_string()).as_deref(), pkg.version_opt().map(|v| v.to_string()).as_deref(),

View File

@ -14,7 +14,7 @@ use colored::Colorize;
use dialoguer::{theme::ColorfulTheme, Confirm, Select}; use dialoguer::{theme::ColorfulTheme, Confirm, Select};
use futures::stream::TryStreamExt; use futures::stream::TryStreamExt;
use is_terminal::IsTerminal; use is_terminal::IsTerminal;
use wasmer_api::{ use wasmer_backend_api::{
types::{AppTemplate, TemplateLanguage}, types::{AppTemplate, TemplateLanguage},
WasmerClient, WasmerClient,
}; };
@ -190,7 +190,7 @@ impl CmdAppCreate {
} }
let user = if let Some(client) = client { 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 { } else {
None None
}; };
@ -359,10 +359,10 @@ impl CmdAppCreate {
// Fetch the first page. // Fetch the first page.
// If first item matches, then no need to re-fetch. // 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, client,
10, 10,
Some(wasmer_api::types::AppTemplatesSortBy::Newest), Some(wasmer_backend_api::types::AppTemplatesSortBy::Newest),
language.to_string(), language.to_string(),
); );
@ -446,7 +446,7 @@ impl CmdAppCreate {
// Either no cache present, or cache has exceeded max age. // Either no cache present, or cache has exceeded max age.
// Fetch the first page. // Fetch the first page.
// If first item matches, then no need to re-fetch. // 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, client, None,
)); ));
@ -489,7 +489,8 @@ impl CmdAppCreate {
if let Ok(url) = url::Url::parse(template) { if let Ok(url) = url::Url::parse(template) {
url url
} else if let Some(template) = } 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)? url::Url::parse(&template.repo_url)?
} else { } else {

View File

@ -53,7 +53,7 @@ impl AsyncCliCommand for CmdAppDelete {
app.name, app.name,
app.id.inner(), 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); eprintln!("App '{}/{}' was deleted!", app.owner.global_name, app.name);

View File

@ -11,7 +11,7 @@ use dialoguer::Confirm;
use is_terminal::IsTerminal; use is_terminal::IsTerminal;
use std::io::Write; use std::io::Write;
use std::{path::PathBuf, str::FromStr, time::Duration}; use std::{path::PathBuf, str::FromStr, time::Duration};
use wasmer_api::{ use wasmer_backend_api::{
types::{DeployApp, DeployAppVersion}, types::{DeployApp, DeployAppVersion},
WasmerClient, WasmerClient,
}; };
@ -185,7 +185,7 @@ impl CmdAppDeploy {
anyhow::bail!("No owner specified: use --owner XXX"); 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( let owner = crate::utils::prompts::prompt_for_namespace(
"Who should own this app?", "Who should own this app?",
None, None,
@ -274,7 +274,7 @@ impl AsyncCliCommand for CmdAppDeploy {
// We want to allow the user to specify the app name interactively. // 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 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()) { 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 .await
.ok() .ok()
} else { } else {
@ -285,12 +285,13 @@ impl AsyncCliCommand for CmdAppDeploy {
.get_owner(&client, &mut app_yaml, maybe_edge_app.as_ref()) .get_owner(&client, &mut app_yaml, maybe_edge_app.as_ref())
.await?; .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()); eprintln!("It seems you don't have access to {}", owner.bold());
if self.non_interactive { 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())); anyhow::bail!("Please, change the owner before deploying or check your current user with `{} whoami`.", std::env::args().next().unwrap_or("wasmer".into()));
} else { } 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( owner = crate::utils::prompts::prompt_for_namespace(
"Who should own this app?", "Who should own this app?",
None, None,
@ -624,9 +625,9 @@ pub async fn deploy_app(
// TODO: respect allow_create flag // TODO: respect allow_create flag
let version = wasmer_api::query::publish_deploy_app( let version = wasmer_backend_api::query::publish_deploy_app(
client, client,
wasmer_api::types::PublishDeployAppVars { wasmer_backend_api::types::PublishDeployAppVars {
config: raw_config, config: raw_config,
name: app.name.clone().into(), name: app.name.clone().into(),
owner: opts.owner.map(|o| o.into()), owner: opts.owner.map(|o| o.into()),
@ -665,7 +666,7 @@ pub async fn wait_app(
.inner() .inner()
.to_string(); .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 .await
.context("could not fetch app from backend")?; .context("could not fetch app from backend")?;

View File

@ -21,7 +21,7 @@ impl AsyncCliCommand for CmdAppDeploymentGet {
async fn run_async(mut self) -> Result<(), anyhow::Error> { async fn run_async(mut self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; 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)); println!("{}", self.fmt.get().render(&item));
Ok(()) Ok(())

View File

@ -30,14 +30,14 @@ impl AsyncCliCommand for CmdAppDeploymentList {
let client = self.env.client()?; let client = self.env.client()?;
let (_ident, app) = self.ident.load_app(&client).await?; let (_ident, app) = self.ident.load_app(&client).await?;
let vars = wasmer_api::types::GetAppDeploymentsVariables { let vars = wasmer_backend_api::types::GetAppDeploymentsVariables {
after: None, after: None,
first: self.limit.map(|x| x as i32), first: self.limit.map(|x| x as i32),
name: app.name.clone(), name: app.name.clone(),
offset: self.offset.map(|x| x as i32), offset: self.offset.map(|x| x as i32),
owner: app.owner.global_name, 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() { if items.is_empty() {
eprintln!("App {} has no deployments!", app.name); eprintln!("App {} has no deployments!", app.name);

View File

@ -26,7 +26,7 @@ impl AsyncCliCommand for CmdAppDeploymentLogs {
async fn run_async(mut self) -> Result<(), anyhow::Error> { async fn run_async(mut self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; 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 let url = item
.log_url .log_url

View File

@ -1,6 +1,6 @@
//! Get information about an edge app. //! Get information about an edge app.
use wasmer_api::types::DeployApp; use wasmer_backend_api::types::DeployApp;
use super::util::AppIdentOpts; use super::util::AppIdentOpts;

View File

@ -3,7 +3,7 @@
use std::pin::Pin; use std::pin::Pin;
use futures::{Stream, StreamExt}; 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}; use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts};
@ -65,11 +65,11 @@ impl AsyncCliCommand for CmdAppList {
let apps_stream: Pin< let apps_stream: Pin<
Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>, Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>,
> = if let Some(ns) = self.namespace.clone() { > = 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 { } 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 { } 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); let mut apps_stream = std::pin::pin!(apps_stream);

View File

@ -5,7 +5,7 @@ use colored::Colorize;
use comfy_table::{Cell, Table}; use comfy_table::{Cell, Table};
use futures::StreamExt; use futures::StreamExt;
use time::{format_description::well_known::Rfc3339, OffsetDateTime}; 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}; 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. // Code duplication to avoid a dependency to `OR` streams.
if let Some(instance_id) = &self.instance_id { 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, &client,
app.name.clone(), app.name.clone(),
app.owner.global_name.to_string(), 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 { } 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, &client,
app.name.clone(), app.name.clone(),
app.owner.global_name.to_string(), app.owner.global_name.to_string(),
@ -197,7 +197,7 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs {
} }
} }
} else { } else {
let logs_stream = wasmer_api::query::get_app_logs_paginated( let logs_stream = wasmer_backend_api::query::get_app_logs_paginated(
&client, &client,
app.name.clone(), app.name.clone(),
app.owner.global_name.to_string(), app.owner.global_name.to_string(),

View File

@ -46,8 +46,8 @@ impl AsyncCliCommand for CmdAppPurgeCache {
version_id.inner() version_id.inner()
); );
let vars = wasmer_api::types::PurgeCacheForAppVersionVars { id: version_id }; let vars = wasmer_backend_api::types::PurgeCacheForAppVersionVars { id: version_id };
wasmer_api::query::purge_cache_for_app_version(&client, vars).await?; wasmer_backend_api::query::purge_cache_for_app_version(&client, vars).await?;
println!("🚽 swirl! All caches have been purged!"); println!("🚽 swirl! All caches have been purged!");

View File

@ -26,7 +26,7 @@ impl AsyncCliCommand for CmdAppRegionsList {
async fn run_async(self) -> Result<Self::Output, anyhow::Error> { async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
let client = self.env.client()?; 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())); println!("{}", self.fmt.format.render(regions.as_slice()));

View File

@ -1,6 +1,6 @@
use crate::utils::render::CliRender; use crate::utils::render::CliRender;
use comfy_table::{Cell, Table}; use comfy_table::{Cell, Table};
use wasmer_api::types::AppRegion; use wasmer_backend_api::types::AppRegion;
impl CliRender for AppRegion { impl CliRender for AppRegion {
fn render_item_table(&self) -> String { fn render_item_table(&self) -> String {

View File

@ -11,7 +11,7 @@ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
/// Create a new app secret. /// Create a new app secret.
#[derive(clap::Parser, Debug)] #[derive(clap::Parser, Debug)]
@ -95,7 +95,7 @@ impl CmdAppSecretsCreate {
) -> anyhow::Result<Vec<Secret>> { ) -> anyhow::Result<Vec<Secret>> {
let names = secrets.iter().map(|s| &s.name); let names = secrets.iter().map(|s| &s.name);
let app_secrets = 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::<String>::from_iter(app_secrets.iter().map(|s| s.name.clone())); let mut sset = HashSet::<String>::from_iter(app_secrets.iter().map(|s| s.name.clone()));
let mut ret = HashMap::new(); let mut ret = HashMap::new();
@ -142,7 +142,7 @@ impl CmdAppSecretsCreate {
app_id: &str, app_id: &str,
secrets: Vec<Secret>, secrets: Vec<Secret>,
) -> Result<(), anyhow::Error> { ) -> Result<(), anyhow::Error> {
let res = wasmer_api::query::upsert_app_secrets( let res = wasmer_backend_api::query::upsert_app_secrets(
client, client,
app_id, app_id,
secrets.iter().map(|s| (s.name.as_str(), s.value.as_str())), secrets.iter().map(|s| (s.name.as_str(), s.value.as_str())),
@ -173,7 +173,7 @@ impl CmdAppSecretsCreate {
}; };
if should_redeploy { 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()); eprintln!("{} Deployment complete", "𖥔".yellow().bold());
} else { } else {
eprintln!( eprintln!(

View File

@ -6,7 +6,7 @@ use colored::Colorize;
use dialoguer::theme::ColorfulTheme; use dialoguer::theme::ColorfulTheme;
use is_terminal::IsTerminal; use is_terminal::IsTerminal;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use super::utils::{self, get_secrets}; 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 { match res {
Some(res) if !res.success => { Some(res) if !res.success => {

View File

@ -11,7 +11,7 @@ use std::{
collections::HashSet, collections::HashSet,
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
/// Update an existing app secret. /// Update an existing app secret.
#[derive(clap::Parser, Debug)] #[derive(clap::Parser, Debug)]
@ -100,7 +100,7 @@ impl CmdAppSecretsUpdate {
) -> anyhow::Result<Vec<Secret>> { ) -> anyhow::Result<Vec<Secret>> {
let names = secrets.iter().map(|s| &s.name); let names = secrets.iter().map(|s| &s.name);
let app_secrets = 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 sset = HashSet::<&str>::from_iter(app_secrets.iter().map(|s| s.name.as_str()));
let mut ret = vec![]; let mut ret = vec![];
@ -136,7 +136,7 @@ impl CmdAppSecretsUpdate {
app_id: &str, app_id: &str,
secrets: Vec<Secret>, secrets: Vec<Secret>,
) -> Result<(), anyhow::Error> { ) -> Result<(), anyhow::Error> {
let res = wasmer_api::query::upsert_app_secrets( let res = wasmer_backend_api::query::upsert_app_secrets(
client, client,
app_id, app_id,
secrets.iter().map(|s| (s.name.as_str(), s.value.as_str())), secrets.iter().map(|s| (s.name.as_str(), s.value.as_str())),
@ -167,7 +167,7 @@ impl CmdAppSecretsUpdate {
}; };
if should_redeploy { 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()); eprintln!("{} Deployment complete", "𖥔".yellow().bold());
} else { } else {
eprintln!( eprintln!(

View File

@ -6,7 +6,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
str::FromStr, 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}; 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, app_id: &str,
secret_name: &str, secret_name: &str,
) -> anyhow::Result<Option<BackendSecret>> { ) -> anyhow::Result<Option<BackendSecret>> {
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( pub(crate) async fn get_secrets(
client: &WasmerClient, client: &WasmerClient,
app_id: &str, app_id: &str,
) -> anyhow::Result<Vec<wasmer_api::types::Secret>> { ) -> anyhow::Result<Vec<wasmer_backend_api::types::Secret>> {
wasmer_api::query::get_all_app_secrets(client, app_id).await wasmer_backend_api::query::get_all_app_secrets(client, app_id).await
} }
pub(crate) async fn get_secret_value( pub(crate) async fn get_secret_value(
client: &WasmerClient, client: &WasmerClient,
secret: &wasmer_api::types::Secret, secret: &wasmer_backend_api::types::Secret,
) -> anyhow::Result<String> { ) -> anyhow::Result<String> {
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? .await?
.ok_or_else(|| { .ok_or_else(|| {
anyhow::anyhow!( anyhow::anyhow!(
@ -68,7 +68,7 @@ pub(crate) async fn reveal_secrets(
client: &WasmerClient, client: &WasmerClient,
app_id: &str, app_id: &str,
) -> anyhow::Result<Vec<Secret>> { ) -> anyhow::Result<Vec<Secret>> {
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![]; let mut ret = vec![];
for secret in secrets { for secret in secrets {
let name = secret.name.clone(); let name = secret.name.clone();

View File

@ -3,7 +3,7 @@ use crate::utils::render::CliRender;
use colored::Colorize; use colored::Colorize;
use comfy_table::{Cell, Table}; use comfy_table::{Cell, Table};
use time::OffsetDateTime; use time::OffsetDateTime;
use wasmer_api::types::{DateTime, Secret as BackendSecret}; use wasmer_backend_api::types::{DateTime, Secret as BackendSecret};
impl CliRender for Secret { impl CliRender for Secret {
fn render_item_table(&self) -> String { fn render_item_table(&self) -> String {

View File

@ -3,7 +3,7 @@ use std::{path::Path, str::FromStr};
use anyhow::{bail, Context}; use anyhow::{bail, Context};
use colored::Colorize; use colored::Colorize;
use dialoguer::{theme::ColorfulTheme, Confirm}; use dialoguer::{theme::ColorfulTheme, Confirm};
use wasmer_api::{ use wasmer_backend_api::{
global_id::{GlobalId, NodeKind}, global_id::{GlobalId, NodeKind},
types::DeployApp, types::DeployApp,
WasmerClient, WasmerClient,
@ -32,12 +32,14 @@ impl AppIdent {
/// Resolve an app identifier through the API. /// Resolve an app identifier through the API.
pub async fn resolve(&self, client: &WasmerClient) -> Result<DeployApp, anyhow::Error> { pub async fn resolve(&self, client: &WasmerClient) -> Result<DeployApp, anyhow::Error> {
match self { match self {
AppIdent::AppId(app_id) => wasmer_api::query::get_app_by_id(client, app_id.clone()) AppIdent::AppId(app_id) => {
.await wasmer_backend_api::query::get_app_by_id(client, app_id.clone())
.with_context(|| format!("Could not find app with id '{}'", app_id)), .await
.with_context(|| format!("Could not find app with id '{}'", app_id))
}
AppIdent::AppVersionId(id) => { AppIdent::AppVersionId(id) => {
let (app, _version) = 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 .await
.with_context(|| format!("Could not query for app version id '{}'", id))?; .with_context(|| format!("Could not query for app version id '{}'", id))?;
Ok(app) Ok(app)
@ -46,16 +48,16 @@ impl AppIdent {
// The API only allows to query by owner + name, // The API only allows to query by owner + name,
// so default to the current user as the owner. // so default to the current user as the owner.
// To to so the username must first be retrieved. // 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? .await?
.context("not logged in")?; .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? .await?
.with_context(|| format!("Could not find app with name '{name}'")) .with_context(|| format!("Could not find app with name '{name}'"))
} }
AppIdent::NamespacedName(owner, 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? .await?
.with_context(|| format!("Could not find app '{owner}/{name}'")) .with_context(|| format!("Could not find app '{owner}/{name}'"))
} }

View File

@ -23,7 +23,7 @@ impl AsyncCliCommand for CmdAppVersionActivate {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; 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 { let Some(version) = &app.active_version else {
anyhow::bail!("Failed to activate version: backend did not update version!"); anyhow::bail!("Failed to activate version: backend did not update version!");

View File

@ -33,7 +33,7 @@ impl AsyncCliCommand for CmdAppVersionGet {
let client = self.env.client()?; let client = self.env.client()?;
let (_ident, app) = self.ident.load_app(&client).await?; 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, &client,
app.owner.global_name, app.owner.global_name,
app.name, app.name,

View File

@ -1,4 +1,4 @@
use wasmer_api::types::{DeployAppVersionsSortBy, GetDeployAppVersionsVars}; use wasmer_backend_api::types::{DeployAppVersionsSortBy, GetDeployAppVersionsVars};
use crate::{ use crate::{
commands::{app::util::AppIdentOpts, AsyncCliCommand}, commands::{app::util::AppIdentOpts, AsyncCliCommand},
@ -77,7 +77,8 @@ impl AsyncCliCommand for CmdAppVersionList {
let (_ident, app) = self.ident.load_app(&client).await?; let (_ident, app) = self.ident.load_app(&client).await?;
let versions = if self.all { 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 { } else {
let vars = GetDeployAppVersionsVars { let vars = GetDeployAppVersionsVars {
owner: app.owner.global_name, owner: app.owner.global_name,
@ -91,7 +92,7 @@ impl AsyncCliCommand for CmdAppVersionList {
}; };
let versions = 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 versions
.edges .edges

View File

@ -30,7 +30,8 @@ impl AsyncCliCommand for CmdAppVolumesCredentials {
let (_ident, app) = self.ident.load_app(&client).await?; let (_ident, app) = self.ident.load_app(&client).await?;
let creds = 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 { match self.fmt.format {
CredsItemFormat::Rclone => { CredsItemFormat::Rclone => {

View File

@ -28,7 +28,7 @@ impl AsyncCliCommand for CmdAppVolumesRotateSecrets {
let client = self.env.client()?; let client = self.env.client()?;
let (_ident, app) = self.ident.load_app(&client).await?; 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 // 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. // of `wasmer app volumes credentials` without worrying about this message.

View File

@ -25,7 +25,8 @@ impl AsyncCliCommand for CmdAppVolumesList {
let (_ident, app) = self.ident.load_app(&client).await?; let (_ident, app) = self.ident.load_app(&client).await?;
let volumes = 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() { if volumes.is_empty() {
eprintln!("App {} has no volumes!", app.name); eprintln!("App {} has no volumes!", app.name);

View File

@ -10,7 +10,7 @@ use crate::{
}; };
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{stream::FuturesUnordered, StreamExt};
use std::{path::PathBuf, time::Duration}; use std::{path::PathBuf, time::Duration};
use wasmer_api::{types::Nonce, WasmerClient}; use wasmer_backend_api::{types::Nonce, WasmerClient};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
enum AuthorizationState { enum AuthorizationState {
@ -103,7 +103,7 @@ impl Login {
}; };
let Nonce { auth_url, .. } = 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? .await?
.ok_or_else(|| { .ok_or_else(|| {
anyhow::anyhow!("The backend did not return any nonce to auth the login!") 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<AuthorizationState> { async fn do_login(&self, env: &WasmerEnv) -> anyhow::Result<AuthorizationState> {
let client = env.client_unauthennticated()?; let client = env.client_unauthennticated()?;
let should_login = if let Some(user) = wasmer_api::query::current_user(&client).await? { let should_login =
#[cfg(not(test))] if let Some(user) = wasmer_backend_api::query::current_user(&client).await? {
{ #[cfg(not(test))]
println!( {
"You are already logged in as {} in registry {}.", println!(
user.username.bold(), "You are already logged in as {} in registry {}.",
env.registry_public_url()?.host_str().unwrap().bold() 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?"); let theme = dialoguer::theme::ColorfulTheme::default();
let dialog = dialoguer::Confirm::with_theme(&theme).with_prompt("Login again?");
dialog.interact()? dialog.interact()?
} }
#[cfg(test)] #[cfg(test)]
{ {
// prevent unused binding warning // prevent unused binding warning
_ = user; _ = user;
false false
} }
} else { } else {
true true
}; };
if !should_login { if !should_login {
Ok(AuthorizationState::Cancelled) Ok(AuthorizationState::Cancelled)
@ -228,7 +229,7 @@ impl Login {
// This will automatically read the config again, picking up the new edits. // This will automatically read the config again, picking up the new edits.
let client = env.client()?; let client = env.client()?;
wasmer_api::query::current_user(&client) wasmer_backend_api::query::current_user(&client)
.await? .await?
.map(|v| v.username) .map(|v| v.username)
.ok_or_else(|| anyhow::anyhow!("Not logged in!")) .ok_or_else(|| anyhow::anyhow!("Not logged in!"))

View File

@ -39,7 +39,7 @@ impl AsyncCliCommand for Logout {
.client() .client()
.map_err(|_| anyhow::anyhow!("Not logged into registry {host_str}"))?; .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 .await
.map_err(|e| anyhow::anyhow!("Not logged into registry {host_str}: {e}"))? .map_err(|e| anyhow::anyhow!("Not logged into registry {host_str}: {e}"))?
.ok_or_else(|| anyhow::anyhow!("Not logged into registry {host_str}"))?; .ok_or_else(|| anyhow::anyhow!("Not logged into registry {host_str}"))?;
@ -92,7 +92,7 @@ impl AsyncCliCommand for Logout {
}; };
if should_revoke { if should_revoke {
wasmer_api::query::revoke_token(&client, token).await?; wasmer_backend_api::query::revoke_token(&client, token).await?;
println!( println!(
"Token for user {} in registry {host_str} correctly revoked", "Token for user {} in registry {host_str} correctly revoked",
user.username.bold() user.username.bold()

View File

@ -20,7 +20,7 @@ impl AsyncCliCommand for Whoami {
async fn run_async(self) -> Result<Self::Output, anyhow::Error> { async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
let client = self.env.client_unauthennticated()?; let client = self.env.client_unauthennticated()?;
let host_str = self.env.registry_public_url()?.host_str().unwrap().bold(); 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? .await?
.ok_or_else(|| anyhow::anyhow!("Not logged in registry {host_str}"))?; .ok_or_else(|| anyhow::anyhow!("Not logged in registry {host_str}"))?;
println!( println!(

View File

@ -273,7 +273,9 @@ impl GetOrSet {
config.registry.set_current_registry(&s.url).await; config.registry.set_current_registry(&s.url).await;
let current_registry = config.registry.get_current_registry(); let current_registry = config.registry.get_current_registry();
if let Ok(client) = env.client() { 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!( println!(
"Successfully logged into registry {current_registry:?} as user {u:?}" "Successfully logged into registry {current_registry:?} as user {u:?}"
); );

View File

@ -19,7 +19,8 @@ impl AsyncCliCommand for CmdDomainGet {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; 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)); println!("{}", self.fmt.format.render(&domain));
} else { } else {

View File

@ -1,4 +1,4 @@
use wasmer_api::types::GetAllDomainsVariables; use wasmer_backend_api::types::GetAllDomainsVariables;
use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts}; use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts};
@ -21,7 +21,7 @@ impl AsyncCliCommand for CmdDomainList {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; let client = self.env.client()?;
let domains = wasmer_api::query::get_all_domains( let domains = wasmer_backend_api::query::get_all_domains(
&client, &client,
GetAllDomainsVariables { GetAllDomainsVariables {
first: None, first: None,

View File

@ -27,7 +27,7 @@ impl AsyncCliCommand for CmdDomainRegister {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; let client = self.env.client()?;
let domain = wasmer_api::query::register_domain( let domain = wasmer_backend_api::query::register_domain(
&client, &client,
self.name, self.name,
self.namespace, self.namespace,

View File

@ -39,7 +39,7 @@ impl AsyncCliCommand for CmdZoneFileGet {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; let client = self.env.client()?;
if let Some(domain) = 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; let zone_file_contents = domain.zone_file;
if let Some(zone_file_path) = self.zone_file_path { 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> { async fn run_async(self) -> Result<(), anyhow::Error> {
let data = std::fs::read(&self.zone_file_path).context("Unable to read file")?; 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 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()?, &self.env.client()?,
zone_file_contents, zone_file_contents,
!self.no_delete_missing_records, !self.no_delete_missing_records,

View File

@ -396,7 +396,7 @@ async fn construct_manifest(
Some(n) => Some(n), Some(n) => Some(n),
None => { None => {
if let Ok(client) = env.client() { 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) Some(u.username)
} else { } else {
None None

View File

@ -24,11 +24,11 @@ impl AsyncCliCommand for CmdNamespaceCreate {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; let client = self.env.client()?;
let vars = wasmer_api::types::CreateNamespaceVars { let vars = wasmer_backend_api::types::CreateNamespaceVars {
name: self.name.clone(), name: self.name.clone(),
description: self.description.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)); println!("{}", self.fmt.get().render(&namespace));

View File

@ -22,7 +22,7 @@ impl AsyncCliCommand for CmdNamespaceGet {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; 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? .await?
.context("namespace not found")?; .context("namespace not found")?;

View File

@ -16,7 +16,7 @@ impl AsyncCliCommand for CmdNamespaceList {
async fn run_async(self) -> Result<(), anyhow::Error> { async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?; 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)); println!("{}", self.fmt.format.render(&namespaces));

View File

@ -11,7 +11,7 @@ use std::{
collections::BTreeMap, collections::BTreeMap,
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use wasmer_config::package::{Manifest, NamedPackageIdent, PackageHash}; use wasmer_config::package::{Manifest, NamedPackageIdent, PackageHash};
use wasmer_package::package::Package; use wasmer_package::package::Package;
@ -51,7 +51,7 @@ pub(super) async fn upload(
let session_uri = { let session_uri = {
let default_timeout_secs = Some(60 * 30); 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, client,
default_timeout_secs, default_timeout_secs,
Some(hash_str), Some(hash_str),

View File

@ -1,5 +1,5 @@
use futures::StreamExt; 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. /// Different conditions that can be "awaited" when publishing a package.
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)] #[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
@ -79,7 +79,7 @@ impl From<PublishWait> for WaitPackageState {
pub async fn wait_package( pub async fn wait_package(
client: &WasmerClient, client: &WasmerClient,
to_wait: PublishWait, to_wait: PublishWait,
package_version_id: wasmer_api::types::Id, package_version_id: wasmer_backend_api::types::Id,
timeout: humantime::Duration, timeout: humantime::Duration,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
if let PublishWait::None = to_wait { 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 package_version_id = package_version_id.into_inner();
let mut stream = 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(); let mut state: WaitPackageState = to_wait.into();

View File

@ -109,7 +109,7 @@ impl PackageDownload {
let rt = tokio::runtime::Runtime::new()?; let rt = tokio::runtime::Runtime::new()?;
let package = rt let package = rt
.block_on(wasmer_api::query::get_package_version( .block_on(wasmer_backend_api::query::get_package_version(
&client, &client,
full_name.clone(), full_name.clone(),
version.clone(), version.clone(),
@ -147,7 +147,7 @@ impl PackageDownload {
let client = self.env.client_unauthennticated()?; let client = self.env.client_unauthennticated()?;
let rt = tokio::runtime::Runtime::new()?; 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"))?; .with_context(|| format!("Package with {hash} does not exist in the registry, or is not accessible"))?;
let ident = hash.to_string(); let ident = hash.to_string();

View File

@ -12,7 +12,7 @@ use crate::{
use colored::Colorize; use colored::Colorize;
use is_terminal::IsTerminal; use is_terminal::IsTerminal;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use wasmer_config::package::{Manifest, PackageIdent}; use wasmer_config::package::{Manifest, PackageIdent};
/// Publish (push and tag) a package to the registry. /// Publish (push and tag) a package to the registry.

View File

@ -7,7 +7,7 @@ use anyhow::Context;
use colored::Colorize; use colored::Colorize;
use is_terminal::IsTerminal; use is_terminal::IsTerminal;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use wasmer_config::package::{Manifest, PackageHash}; use wasmer_config::package::{Manifest, PackageHash};
use wasmer_package::package::Package; use wasmer_package::package::Package;
@ -78,7 +78,7 @@ impl PackagePush {
anyhow::bail!("No package namespace specified: use --namespace XXX"); 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( let owner = crate::utils::prompts::prompt_for_namespace(
"Choose a namespace to push the package to", "Choose a namespace to push the package to",
None, None,
@ -112,7 +112,7 @@ impl PackagePush {
} }
async fn should_push(&self, client: &WasmerClient, hash: &PackageHash) -> anyhow::Result<bool> { async fn should_push(&self, client: &WasmerClient, hash: &PackageHash) -> anyhow::Result<bool> {
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); tracing::info!("{:?}", res);
res.map(|p| p.is_none()) res.map(|p| p.is_none())
} }
@ -140,7 +140,7 @@ impl PackagePush {
spinner_ok!(pb, "Package correctly uploaded"); spinner_ok!(pb, "Package correctly uploaded");
let pb = make_spinner!(self.quiet, "Waiting for package to become available..."); 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, client,
name.as_deref(), name.as_deref(),
namespace, namespace,

View File

@ -13,7 +13,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
str::FromStr, str::FromStr,
}; };
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use wasmer_config::package::{ use wasmer_config::package::{
Manifest, NamedPackageId, NamedPackageIdent, PackageBuilder, PackageHash, PackageIdent, Manifest, NamedPackageId, NamedPackageIdent, PackageBuilder, PackageHash, PackageIdent,
}; };
@ -154,7 +154,7 @@ impl PackageTag {
client: &WasmerClient, client: &WasmerClient,
id: &NamedPackageId, id: &NamedPackageId,
manifest: Option<&Manifest>, manifest: Option<&Manifest>,
package_release_id: &wasmer_api::types::Id, package_release_id: &wasmer_backend_api::types::Id,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
tracing::info!( tracing::info!(
"Tagging package with registry id {:?} and specifier {:?}", "Tagging package with registry id {:?} and specifier {:?}",
@ -200,7 +200,7 @@ impl PackageTag {
None None
}; };
let r = wasmer_api::query::tag_package_release( let r = wasmer_backend_api::query::tag_package_release(
client, client,
maybe_description.as_deref(), maybe_description.as_deref(),
maybe_homepage.as_deref(), maybe_homepage.as_deref(),
@ -241,7 +241,7 @@ impl PackageTag {
client: &WasmerClient, client: &WasmerClient,
hash: &PackageHash, hash: &PackageHash,
check_package_exists: bool, check_package_exists: bool,
) -> anyhow::Result<wasmer_api::types::Id> { ) -> anyhow::Result<wasmer_backend_api::types::Id> {
let pb = make_spinner!( let pb = make_spinner!(
self.quiet || check_package_exists, self.quiet || check_package_exists,
"Checking if the package exists.." "Checking if the package exists.."
@ -249,7 +249,9 @@ impl PackageTag {
tracing::debug!("Searching for package with hash: {hash}"); 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, Some(p) => p,
None => { None => {
spinner_err!(pb, "The package is not in the registry!"); spinner_err!(pb, "The package is not in the registry!");
@ -366,7 +368,7 @@ impl PackageTag {
anyhow::bail!("No package namespace specified: use --namespace <package_namespace>"); anyhow::bail!("No package namespace specified: use --namespace <package_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)) 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..") 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, client,
full_pkg_name.to_string(), full_pkg_name.to_string(),
String::from("latest"), 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. // Must necessarily bump if there's a package with the chosen version with a different hash.
let must_bump = { let must_bump = {
let maybe_pkg = wasmer_api::query::get_package_version( let maybe_pkg = wasmer_backend_api::query::get_package_version(
client, client,
full_pkg_name.to_string(), full_pkg_name.to_string(),
user_version.to_string(), user_version.to_string(),
@ -590,7 +592,7 @@ impl PackageTag {
return Ok(false); return Ok(false);
} }
let pkg = wasmer_api::query::get_package_version( let pkg = wasmer_backend_api::query::get_package_version(
client, client,
id.full_name.clone(), id.full_name.clone(),
id.version.to_string(), id.version.to_string(),

View File

@ -1,7 +1,7 @@
//! Edge SSH command. //! Edge SSH command.
use anyhow::Context; use anyhow::Context;
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use super::AsyncCliCommand; use super::AsyncCliCommand;
use crate::{config::WasmerEnv, edge_config::EdgeConfig}; 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. /// Create a new token for SSH access through the backend API.
async fn create_ssh_token(client: &WasmerClient) -> Result<RawToken, anyhow::Error> { async fn create_ssh_token(client: &WasmerClient) -> Result<RawToken, anyhow::Error> {
wasmer_api::query::generate_deploy_config_token_raw(client, wasmer_api::query::TokenKind::SSH) wasmer_backend_api::query::generate_deploy_config_token_raw(
.await client,
.context("Could not create token for ssh access") wasmer_backend_api::query::TokenKind::SSH,
)
.await
.context("Could not create token for ssh access")
} }

View File

@ -3,7 +3,7 @@ use anyhow::{Context, Error};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use url::Url; use url::Url;
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
lazy_static! { lazy_static! {
pub static ref DEFAULT_WASMER_CLI_USER_AGENT: String = pub static ref DEFAULT_WASMER_CLI_USER_AGENT: String =
@ -141,7 +141,7 @@ impl WasmerEnv {
let proxy = self.proxy()?; let proxy = self.proxy()?;
let client = wasmer_api::WasmerClient::new_with_proxy( let client = wasmer_backend_api::WasmerClient::new_with_proxy(
registry_url, registry_url,
&DEFAULT_WASMER_CLI_USER_AGENT, &DEFAULT_WASMER_CLI_USER_AGENT,
proxy, proxy,

View File

@ -4,7 +4,7 @@ pub use env::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use url::Url; use url::Url;
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
pub static GLOBAL_CONFIG_FILE_NAME: &str = "wasmer.toml"; pub static GLOBAL_CONFIG_FILE_NAME: &str = "wasmer.toml";
pub static DEFAULT_PROD_REGISTRY: &str = "https://registry.wasmer.io/graphql"; 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<()> { async fn test_if_registry_present(registry: &str) -> anyhow::Result<()> {
let client = WasmerClient::new(url::Url::parse(registry)?, &DEFAULT_WASMER_CLI_USER_AGENT)?; 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)] #[derive(PartialEq, Eq, Copy, Clone)]

View File

@ -1,5 +1,5 @@
use comfy_table::Table; use comfy_table::Table;
use wasmer_api::types::{ use wasmer_backend_api::types::{
DeployApp, DeployAppVersion, Deployment, DnsDomain, DnsDomainWithRecords, Namespace, 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 { fn render_item_table(&self) -> String {
let mut table = Table::new(); let mut table = Table::new();
table.add_rows([ table.add_rows([
@ -189,7 +189,7 @@ impl CliRender for wasmer_api::types::AppVersionVolume {
} }
} }
fn format_disk_size_opt(value: Option<wasmer_api::types::BigInt>) -> String { fn format_disk_size_opt(value: Option<wasmer_backend_api::types::BigInt>) -> String {
let value = value.and_then(|x| { let value = value.and_then(|x| {
let y: Option<u64> = x.0.try_into().ok(); let y: Option<u64> = x.0.try_into().ok();
y 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 { fn render_item_table(&self) -> String {
let mut table = Table::new(); let mut table = Table::new();
table.add_rows([ 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 { fn render_item_table(&self) -> String {
let mut table = Table::new(); let mut table = Table::new();
table.add_rows([ table.add_rows([

View File

@ -2,7 +2,7 @@
// //
// use anyhow::Context; // use anyhow::Context;
// use dialoguer::{theme::ColorfulTheme, Select}; // use dialoguer::{theme::ColorfulTheme, Select};
// use wasmer_api::{types::UserWithNamespaces, WasmerClient}; // use wasmer_backend_api::{types::UserWithNamespaces, WasmerClient};
// //
// use super::prompts::PackageCheckMode; // use super::prompts::PackageCheckMode;
// //
@ -77,7 +77,7 @@
// } // }
// //
// pub struct PackageWizardOutput { // pub struct PackageWizardOutput {
// pub api: Option<wasmer_api::types::Package>, // pub api: Option<wasmer_backend_api::types::Package>,
// pub local_path: Option<PathBuf>, // pub local_path: Option<PathBuf>,
// pub local_manifest: Option<wasmer_config::package::Manifest>, // pub local_manifest: Option<wasmer_config::package::Manifest>,
// } // }

View File

@ -1,7 +1,7 @@
use anyhow::Context; use anyhow::Context;
use colored::Colorize; use colored::Colorize;
use dialoguer::{theme::ColorfulTheme, Select}; use dialoguer::{theme::ColorfulTheme, Select};
use wasmer_api::WasmerClient; use wasmer_backend_api::WasmerClient;
use wasmer_config::package::NamedPackageIdent; use wasmer_config::package::NamedPackageIdent;
pub fn prompt_for_ident(message: &str, default: Option<&str>) -> Result<String, anyhow::Error> { pub fn prompt_for_ident(message: &str, default: Option<&str>) -> Result<String, anyhow::Error> {
@ -90,7 +90,13 @@ pub async fn prompt_for_package(
default: Option<&str>, default: Option<&str>,
check: Option<PackageCheckMode>, check: Option<PackageCheckMode>,
client: Option<&WasmerClient>, client: Option<&WasmerClient>,
) -> Result<(NamedPackageIdent, Option<wasmer_api::types::Package>), anyhow::Error> { ) -> Result<
(
NamedPackageIdent,
Option<wasmer_backend_api::types::Package>,
),
anyhow::Error,
> {
loop { loop {
let ident = prompt_for_package_ident(message, default)?; 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 api = client.expect("Check mode specified, but no API provided");
let pkg = if let Some(v) = ident.version_opt() { let pkg = if let Some(v) = ident.version_opt() {
wasmer_api::query::get_package_version(api, ident.full_name(), v.to_string()) wasmer_backend_api::query::get_package_version(
.await api,
.context("could not query backend for package")? ident.full_name(),
.map(|p| p.package) v.to_string(),
)
.await
.context("could not query backend for package")?
.map(|p| p.package)
} else { } else {
wasmer_api::query::get_package(api, ident.to_string()) wasmer_backend_api::query::get_package(api, ident.to_string())
.await .await
.context("could not query backend for package")? .context("could not query backend for package")?
}; };
@ -144,7 +154,7 @@ pub async fn prompt_for_package(
pub fn prompt_for_namespace( pub fn prompt_for_namespace(
message: &str, message: &str,
default: Option<&str>, default: Option<&str>,
user: Option<&wasmer_api::types::UserWithNamespaces>, user: Option<&wasmer_backend_api::types::UserWithNamespaces>,
) -> Result<String, anyhow::Error> { ) -> Result<String, anyhow::Error> {
if let Some(user) = user { if let Some(user) = user {
let namespaces = user let namespaces = user
@ -205,7 +215,8 @@ pub async fn prompt_new_app_name(
"WARN".bold().yellow() "WARN".bold().yellow()
) )
} else if let Some(api) = &api { } 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... "); eprint!("Checking name availability... ");
if app.is_some() { if app.is_some() {
eprintln!( eprintln!(
@ -237,7 +248,7 @@ pub async fn prompt_new_app_alias(
let ident = prompt_for_ident(message, default)?; let ident = prompt_for_ident(message, default)?;
if let Some(api) = &api { 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..."); eprintln!("Checking name availability...");
if app.is_some() { if app.is_some() {
eprintln!( eprintln!(