Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/backend-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/backend-api/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# wasmer-api
# wasmer-backend-api

GraphQL API client for the [Wasmer](https://wasmer.io) backend.

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -102,7 +102,7 @@ async fn lookup_bindings_for_package(
pkg: &NamedPackageIdent,
language: &ProgrammingLanguage,
) -> Result<Bindings, Error> {
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(),
Expand Down
13 changes: 7 additions & 6 deletions lib/cli/src/commands/app/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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(),
);

Expand Down Expand Up @@ -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,
));

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/app/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 9 additions & 8 deletions lib/cli/src/commands/app/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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")?;

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/app/deployments/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/app/deployments/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/app/deployments/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/app/get.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
8 changes: 4 additions & 4 deletions lib/cli/src/commands/app/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -65,11 +65,11 @@ impl AsyncCliCommand for CmdAppList {
let apps_stream: Pin<
Box<dyn Stream<Item = Result<Vec<DeployApp>, 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);
Expand Down
8 changes: 4 additions & 4 deletions lib/cli/src/commands/app/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/app/purge_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/app/regions/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl AsyncCliCommand for CmdAppRegionsList {

async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
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()));

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/app/regions/utils/render.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading
Loading