Add subcommand wasmer domain register to register a new domain

This commit is contained in:
Ayush Jha
2024-03-18 17:27:55 +05:45
committed by Christoph Herzog
parent f3bfaf4cd5
commit c0c4233349
5 changed files with 95 additions and 2 deletions

View File

@@ -865,6 +865,29 @@ pub async fn get_domain_with_records(
Ok(opt)
}
/// Register a new domain
pub async fn register_domain(
client: &WasmerClient,
name: String,
namespace: Option<String>,
import_records: Option<bool>,
) -> Result<types::DnsDomain, anyhow::Error> {
let vars = types::RegisterDomainVars {
name,
namespace,
import_records,
};
let opt = client
.run_graphql_strict(types::RegisterDomain::build(vars))
.await
.map_err(anyhow::Error::from)?
.register_domain
.context("Domain registration failed")?
.domain
.context("Domain registration failed, no associatede domain found.")?;
Ok(opt)
}
/// Retrieve all DNS records.
///
/// NOTE: this is a privileged operation that requires extra permissions.