use std::future::IntoFuture;
use std::time::Duration;
use serde_json::Value;
use crate::client::{BoxFuture, Client, decode};
use crate::error::{ApiError, Error, Result};
use crate::types::{self, EgressPolicy};
use crate::vm::{Vm, WaitUntil};
use crate::wire::{self, Line};
impl Client {
pub fn doc(&self) -> Doc<'_> {
Doc {
c: self,
queries: Vec::new(),
}
}
pub fn new_vm(&self) -> NewVm<'_> {
NewVm {
c: self,
comment: None,
cpu: None,
disk: None,
egress: None,
env: Vec::new(),
image: None,
integrations: None,
memory: None,
name: None,
no_pool: None,
pool: None,
prompt: None,
registry_auth: None,
setup_script: None,
standalone: None,
tags: None,
email: false,
wait_until: WaitUntil::Ssh,
timeout: None,
keep_on_failure: false,
}
}
pub fn whoami(&self) -> Whoami<'_> {
Whoami {
c: self,
}
}
pub fn set_region(&self, region_code: impl Into<String>) -> SetRegion<'_> {
SetRegion {
c: self,
region_code: region_code.into(),
}
}
pub fn browser(&self) -> Browser<'_> {
Browser {
c: self,
qr: None,
}
}
pub fn domain(&self) -> Domain<'_> {
Domain {
c: self,
}
}
pub fn ssh_key(&self) -> SshKey<'_> {
SshKey {
c: self,
}
}
pub fn integrations(&self) -> Integrations<'_> {
Integrations {
c: self,
}
}
pub fn team(&self) -> Team<'_> {
Team {
c: self,
}
}
pub fn pool(&self) -> Pool<'_> {
Pool {
c: self,
}
}
pub fn billing(&self) -> Billing<'_> {
Billing {
c: self,
}
}
pub fn invite(&self) -> Invite<'_> {
Invite {
c: self,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Doc<'a> {
c: &'a Client,
queries: Vec<String>,
}
impl<'a> Doc<'a> {
pub fn queries(mut self, queries: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.queries.extend(queries.into_iter().map(Into::into));
self
}
}
impl<'a> IntoFuture for Doc<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("doc");
line.args("slug or query", self.queries, false);
let line = line.finish()?;
self.c.t.call("doc", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct NewVm<'a> {
c: &'a Client,
comment: Option<String>,
cpu: Option<i64>,
disk: Option<String>,
egress: Option<EgressPolicy>,
env: Vec<(String, String)>,
image: Option<String>,
integrations: Option<Vec<String>>,
memory: Option<String>,
name: Option<String>,
no_pool: Option<bool>,
pool: Option<String>,
prompt: Option<String>,
registry_auth: Option<String>,
setup_script: Option<String>,
standalone: Option<bool>,
tags: Option<Vec<String>>,
email: bool,
wait_until: WaitUntil,
timeout: Option<Duration>,
keep_on_failure: bool,
}
impl<'a> NewVm<'a> {
pub fn comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
pub fn cpu(mut self, cpu: i64) -> Self {
self.cpu = Some(cpu);
self
}
pub fn disk(mut self, disk: impl std::fmt::Display) -> Self {
self.disk = Some(disk.to_string());
self
}
pub fn egress(mut self, egress: EgressPolicy) -> Self {
self.egress = Some(egress);
self
}
pub fn env(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
self.env.push((key.into(), value.into()));
self
}
pub fn image(mut self, image: impl Into<String>) -> Self {
self.image = Some(image.into());
self
}
pub fn integrations(mut self, integrations: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.integrations.get_or_insert_with(Vec::new).extend(integrations.into_iter().map(Into::into));
self
}
pub fn memory(mut self, memory: impl std::fmt::Display) -> Self {
self.memory = Some(memory.to_string());
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn no_pool(mut self, no_pool: bool) -> Self {
self.no_pool = Some(no_pool);
self
}
pub fn pool(mut self, pool: impl Into<String>) -> Self {
self.pool = Some(pool.into());
self
}
pub fn prompt(mut self, prompt: impl Into<String>) -> Self {
self.prompt = Some(prompt.into());
self
}
pub fn registry_auth(mut self, registry_auth: impl Into<String>) -> Self {
self.registry_auth = Some(registry_auth.into());
self
}
pub fn setup_script(mut self, setup_script: impl Into<String>) -> Self {
self.setup_script = Some(setup_script.into());
self
}
pub fn standalone(mut self, standalone: bool) -> Self {
self.standalone = Some(standalone);
self
}
pub fn tags(mut self, tags: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.tags.get_or_insert_with(Vec::new).extend(tags.into_iter().map(Into::into));
self
}
pub fn email(mut self, email: bool) -> Self {
self.email = email;
self
}
pub fn wait_until(mut self, until: WaitUntil) -> Self {
self.wait_until = until;
self
}
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
pub fn keep_on_failure(mut self, keep: bool) -> Self {
self.keep_on_failure = keep;
self
}
}
impl<'a> IntoFuture for NewVm<'a> {
type Output = Result<Vm>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
self.wait_until.timeout(self.timeout)?;
let mut line = Line::new("new");
line.string("comment", self.comment);
line.number("cpu", self.cpu);
line.string("disk", self.disk);
line.string("egress", self.egress.map(|p| p.as_str().to_string()));
line.repeated("env", wire::env_flags(self.env)?);
line.string("image", self.image);
line.repeated("integration", self.integrations);
line.string("memory", self.memory);
line.string("name", self.name);
line.bool("no-pool", self.no_pool);
line.string("pool", self.pool);
line.string("prompt", self.prompt);
line.string("registry-auth", self.registry_auth);
line.string("setup-script", self.setup_script.map(|s| s.replace('\\', "\\\\")));
line.bool("standalone", self.standalone);
line.repeated("tag", self.tags);
line.bool("no-email", (!self.email).then_some(true));
let line = line.finish()?;
let info = self.c.t.create("new", line).await?;
Vm::new(self.c.t.clone(), info)
.created(self.wait_until, self.timeout, self.keep_on_failure)
.await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Whoami<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for Whoami<'a> {
type Output = Result<types::WhoamiResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("whoami").finish()?;
self.c.t.call_json("whoami", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SetRegion<'a> {
c: &'a Client,
region_code: String,
}
impl<'a> IntoFuture for SetRegion<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("set-region");
line.arg(self.region_code);
let line = line.finish()?;
self.c.t.call("set-region", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Browser<'a> {
c: &'a Client,
qr: Option<bool>,
}
impl<'a> Browser<'a> {
pub fn qr(mut self, qr: bool) -> Self {
self.qr = Some(qr);
self
}
}
impl<'a> IntoFuture for Browser<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("browser");
line.bool("qr", self.qr);
let line = line.finish()?;
self.c.t.call("browser", &line).await
})
}
}
pub struct Domain<'a> {
c: &'a Client,
}
impl<'a> Domain<'a> {
pub fn ls(&self) -> DomainLs<'a> {
DomainLs {
c: self.c,
args: Vec::new(),
all: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct DomainLs<'a> {
c: &'a Client,
args: Vec<String>,
all: Option<bool>,
}
impl<'a> DomainLs<'a> {
pub fn args(mut self, args: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.args.extend(args.into_iter().map(Into::into));
self
}
pub fn all(mut self, all: bool) -> Self {
self.all = Some(all);
self
}
}
impl<'a> IntoFuture for DomainLs<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("domain ls");
line.bool("a", self.all);
line.args("args", self.args, false);
let line = line.finish()?;
self.c.t.call("domain ls", &line).await
})
}
}
pub struct SshKey<'a> {
c: &'a Client,
}
impl<'a> SshKey<'a> {
pub fn list(&self) -> SshKeyList<'a> {
SshKeyList {
c: self.c,
}
}
pub fn add(&self, public_key: impl Into<String>) -> SshKeyAdd<'a> {
SshKeyAdd {
c: self.c,
public_key: public_key.into(),
ips: None,
ssh_user: None,
tag: None,
vms: None,
}
}
pub fn remove(&self, key: impl Into<String>) -> SshKeyRemove<'a> {
SshKeyRemove {
c: self.c,
key: key.into(),
}
}
pub fn rename(&self, old_name: impl Into<String>, new_name: impl Into<String>) -> SshKeyRename<'a> {
SshKeyRename {
c: self.c,
old_name: old_name.into(),
new_name: new_name.into(),
}
}
pub fn generate_api_key(&self) -> SshKeyGenerateApiKey<'a> {
SshKeyGenerateApiKey {
c: self.c,
cmds: None,
exp: None,
ips: None,
label: None,
tag: None,
vm: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SshKeyList<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for SshKeyList<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("ssh-key list").finish()?;
self.c.t.call("ssh-key list", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SshKeyAdd<'a> {
c: &'a Client,
public_key: String,
ips: Option<Vec<String>>,
ssh_user: Option<String>,
tag: Option<String>,
vms: Option<Vec<String>>,
}
impl<'a> SshKeyAdd<'a> {
pub fn ips(mut self, ips: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.ips.get_or_insert_with(Vec::new).extend(ips.into_iter().map(Into::into));
self
}
pub fn ssh_user(mut self, ssh_user: impl Into<String>) -> Self {
self.ssh_user = Some(ssh_user.into());
self
}
pub fn tag(mut self, tag: impl Into<String>) -> Self {
self.tag = Some(tag.into());
self
}
pub fn vms(mut self, vms: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.vms.get_or_insert_with(Vec::new).extend(vms.into_iter().map(Into::into));
self
}
}
impl<'a> IntoFuture for SshKeyAdd<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("ssh-key add");
line.list("ips", self.ips);
line.string("ssh-user", self.ssh_user);
line.string("tag", self.tag);
line.nonempty("vm", self.vms);
line.arg(self.public_key);
let line = line.finish()?;
self.c.t.call("ssh-key add", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SshKeyRemove<'a> {
c: &'a Client,
key: String,
}
impl<'a> IntoFuture for SshKeyRemove<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("ssh-key remove");
line.arg(self.key);
let line = line.finish()?;
self.c.t.call("ssh-key remove", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SshKeyRename<'a> {
c: &'a Client,
old_name: String,
new_name: String,
}
impl<'a> IntoFuture for SshKeyRename<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("ssh-key rename");
line.arg(self.old_name);
line.arg(self.new_name);
let line = line.finish()?;
self.c.t.call("ssh-key rename", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SshKeyGenerateApiKey<'a> {
c: &'a Client,
cmds: Option<Vec<String>>,
exp: Option<String>,
ips: Option<Vec<String>>,
label: Option<String>,
tag: Option<String>,
vm: Option<String>,
}
impl<'a> SshKeyGenerateApiKey<'a> {
pub fn cmds(mut self, cmds: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.cmds.get_or_insert_with(Vec::new).extend(cmds.into_iter().map(Into::into));
self
}
pub fn exp(mut self, exp: impl Into<String>) -> Self {
self.exp = Some(exp.into());
self
}
pub fn ips(mut self, ips: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.ips.get_or_insert_with(Vec::new).extend(ips.into_iter().map(Into::into));
self
}
pub fn label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn tag(mut self, tag: impl Into<String>) -> Self {
self.tag = Some(tag.into());
self
}
pub fn vm(mut self, vm: impl Into<String>) -> Self {
self.vm = Some(vm.into());
self
}
}
impl<'a> IntoFuture for SshKeyGenerateApiKey<'a> {
type Output = Result<types::GenerateAPIKeyResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("ssh-key generate-api-key");
line.list("cmds", self.cmds);
line.string("exp", self.exp);
line.list("ips", self.ips);
line.string("label", self.label);
line.string("tag", self.tag);
line.string("vm", self.vm);
let line = line.finish()?;
self.c.t.call_json("ssh-key generate-api-key", &line).await
})
}
}
pub struct Integrations<'a> {
c: &'a Client,
}
impl<'a> Integrations<'a> {
pub fn list(&self) -> IntegrationsList<'a> {
IntegrationsList {
c: self.c,
available: None,
usage: None,
}
}
pub fn show(&self, name: impl Into<String>) -> IntegrationsShow<'a> {
IntegrationsShow {
c: self.c,
name: name.into(),
team: None,
}
}
pub fn add(&self, kind: impl Into<String>) -> IntegrationsAdd<'a> {
IntegrationsAdd {
c: self.c,
kind: kind.into(),
act_as_user: None,
attach: None,
bearer: None,
comment: None,
default: None,
endpoint: None,
external_connection: None,
fields: None,
for_duration: None,
headers: None,
host_keys: None,
name: None,
no_auth: None,
peer: None,
readonly: None,
repository: None,
step_up: None,
step_up_require_passkey: None,
strip_prefix: None,
target: None,
team: None,
}
}
pub fn remove(&self, name: impl Into<String>) -> IntegrationsRemove<'a> {
IntegrationsRemove {
c: self.c,
name: name.into(),
team: None,
}
}
pub fn test(&self, name: impl Into<String>) -> IntegrationsTest<'a> {
IntegrationsTest {
c: self.c,
name: name.into(),
team: None,
}
}
pub fn edit(&self, name: impl Into<String>) -> IntegrationsEdit<'a> {
IntegrationsEdit {
c: self.c,
name: name.into(),
args: Vec::new(),
act_as_user: None,
bearer: None,
clear_header: None,
comment: None,
endpoint: None,
external_connection: None,
fields: None,
headers: None,
host_keys: None,
no_auth: None,
readonly: None,
repository: None,
step_up: None,
step_up_require_passkey: None,
strip_prefix: None,
target: None,
team: None,
webhook_url: None,
}
}
pub fn attach(&self, name: impl Into<String>, spec: impl Into<String>) -> IntegrationsAttach<'a> {
IntegrationsAttach {
c: self.c,
name: name.into(),
spec: spec.into(),
for_duration: None,
team: None,
until: None,
}
}
pub fn detach(&self, name: impl Into<String>, spec: impl Into<String>) -> IntegrationsDetach<'a> {
IntegrationsDetach {
c: self.c,
name: name.into(),
spec: spec.into(),
team: None,
}
}
pub fn rename(&self, name: impl Into<String>, new_name: impl Into<String>) -> IntegrationsRename<'a> {
IntegrationsRename {
c: self.c,
name: name.into(),
new_name: new_name.into(),
team: None,
}
}
pub fn catalog(&self) -> IntegrationsCatalog<'a> {
IntegrationsCatalog {
c: self.c,
query: None,
}
}
pub fn setup(&self) -> IntegrationsSetup<'a> {
IntegrationsSetup {
c: self.c,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsList<'a> {
c: &'a Client,
available: Option<bool>,
usage: Option<bool>,
}
impl<'a> IntegrationsList<'a> {
pub fn available(mut self, available: bool) -> Self {
self.available = Some(available);
self
}
pub fn usage(mut self, usage: bool) -> Self {
self.usage = Some(usage);
self
}
}
impl<'a> IntoFuture for IntegrationsList<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations list");
line.bool("available", self.available);
line.bool("usage", self.usage);
let line = line.finish()?;
self.c.t.call("integrations list", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsShow<'a> {
c: &'a Client,
name: String,
team: Option<bool>,
}
impl<'a> IntegrationsShow<'a> {
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsShow<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations show");
line.bool("team", self.team);
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("integrations show", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsAdd<'a> {
c: &'a Client,
kind: String,
act_as_user: Option<bool>,
attach: Option<Vec<String>>,
bearer: Option<String>,
comment: Option<String>,
default: Option<bool>,
endpoint: Option<String>,
external_connection: Option<String>,
fields: Option<Vec<String>>,
for_duration: Option<String>,
headers: Option<Vec<String>>,
host_keys: Option<Vec<String>>,
name: Option<String>,
no_auth: Option<bool>,
peer: Option<bool>,
readonly: Option<bool>,
repository: Option<String>,
step_up: Option<bool>,
step_up_require_passkey: Option<bool>,
strip_prefix: Option<String>,
target: Option<String>,
team: Option<bool>,
}
impl<'a> IntegrationsAdd<'a> {
pub fn act_as_user(mut self, act_as_user: bool) -> Self {
self.act_as_user = Some(act_as_user);
self
}
pub fn attach(mut self, attach: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.attach.get_or_insert_with(Vec::new).extend(attach.into_iter().map(Into::into));
self
}
pub fn bearer(mut self, bearer: impl Into<String>) -> Self {
self.bearer = Some(bearer.into());
self
}
pub fn comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
pub fn default(mut self, default: bool) -> Self {
self.default = Some(default);
self
}
pub fn endpoint(mut self, endpoint: impl Into<String>) -> Self {
self.endpoint = Some(endpoint.into());
self
}
pub fn external_connection(mut self, external_connection: impl Into<String>) -> Self {
self.external_connection = Some(external_connection.into());
self
}
pub fn fields(mut self, fields: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.fields.get_or_insert_with(Vec::new).extend(fields.into_iter().map(Into::into));
self
}
pub fn for_duration(mut self, for_duration: impl Into<String>) -> Self {
self.for_duration = Some(for_duration.into());
self
}
pub fn headers(mut self, headers: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.headers.get_or_insert_with(Vec::new).extend(headers.into_iter().map(Into::into));
self
}
pub fn host_keys(mut self, host_keys: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.host_keys.get_or_insert_with(Vec::new).extend(host_keys.into_iter().map(Into::into));
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn no_auth(mut self, no_auth: bool) -> Self {
self.no_auth = Some(no_auth);
self
}
pub fn peer(mut self, peer: bool) -> Self {
self.peer = Some(peer);
self
}
pub fn readonly(mut self, readonly: bool) -> Self {
self.readonly = Some(readonly);
self
}
pub fn repository(mut self, repository: impl Into<String>) -> Self {
self.repository = Some(repository.into());
self
}
pub fn step_up(mut self, step_up: bool) -> Self {
self.step_up = Some(step_up);
self
}
pub fn step_up_require_passkey(mut self, step_up_require_passkey: bool) -> Self {
self.step_up_require_passkey = Some(step_up_require_passkey);
self
}
pub fn strip_prefix(mut self, strip_prefix: impl Into<String>) -> Self {
self.strip_prefix = Some(strip_prefix.into());
self
}
pub fn target(mut self, target: impl Into<String>) -> Self {
self.target = Some(target.into());
self
}
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsAdd<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations add");
line.bool("act-as-user", self.act_as_user);
line.repeated("attach", self.attach);
line.string("bearer", self.bearer);
line.string("comment", self.comment);
line.bool("default", self.default);
line.string("endpoint", self.endpoint);
line.string("external-connection", self.external_connection);
line.list("fields", self.fields);
line.string("for", self.for_duration);
line.repeated("header", self.headers);
line.repeated("host-key", self.host_keys);
line.string("name", self.name);
line.bool("no-auth", self.no_auth);
line.bool("peer", self.peer);
line.bool("readonly", self.readonly);
line.string("repository", self.repository);
line.bool("step-up", self.step_up);
line.bool("step-up-require-passkey", self.step_up_require_passkey);
line.string("strip-prefix", self.strip_prefix);
line.string("target", self.target);
line.bool("team", self.team);
line.arg(self.kind);
let line = line.finish()?;
self.c.t.call("integrations add", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsRemove<'a> {
c: &'a Client,
name: String,
team: Option<bool>,
}
impl<'a> IntegrationsRemove<'a> {
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsRemove<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations remove");
line.bool("team", self.team);
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("integrations remove", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsTest<'a> {
c: &'a Client,
name: String,
team: Option<bool>,
}
impl<'a> IntegrationsTest<'a> {
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsTest<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations test");
line.bool("team", self.team);
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("integrations test", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsEdit<'a> {
c: &'a Client,
name: String,
args: Vec<String>,
act_as_user: Option<bool>,
bearer: Option<String>,
clear_header: Option<bool>,
comment: Option<String>,
endpoint: Option<String>,
external_connection: Option<String>,
fields: Option<Vec<String>>,
headers: Option<Vec<String>>,
host_keys: Option<Vec<String>>,
no_auth: Option<bool>,
readonly: Option<bool>,
repository: Option<String>,
step_up: Option<bool>,
step_up_require_passkey: Option<bool>,
strip_prefix: Option<String>,
target: Option<String>,
team: Option<bool>,
webhook_url: Option<String>,
}
impl<'a> IntegrationsEdit<'a> {
pub fn args(mut self, args: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.args.extend(args.into_iter().map(Into::into));
self
}
pub fn act_as_user(mut self, act_as_user: bool) -> Self {
self.act_as_user = Some(act_as_user);
self
}
pub fn bearer(mut self, bearer: impl Into<String>) -> Self {
self.bearer = Some(bearer.into());
self
}
pub fn clear_header(mut self, clear_header: bool) -> Self {
self.clear_header = Some(clear_header);
self
}
pub fn comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
pub fn endpoint(mut self, endpoint: impl Into<String>) -> Self {
self.endpoint = Some(endpoint.into());
self
}
pub fn external_connection(mut self, external_connection: impl Into<String>) -> Self {
self.external_connection = Some(external_connection.into());
self
}
pub fn fields(mut self, fields: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.fields.get_or_insert_with(Vec::new).extend(fields.into_iter().map(Into::into));
self
}
pub fn headers(mut self, headers: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.headers.get_or_insert_with(Vec::new).extend(headers.into_iter().map(Into::into));
self
}
pub fn host_keys(mut self, host_keys: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.host_keys.get_or_insert_with(Vec::new).extend(host_keys.into_iter().map(Into::into));
self
}
pub fn no_auth(mut self, no_auth: bool) -> Self {
self.no_auth = Some(no_auth);
self
}
pub fn readonly(mut self, readonly: bool) -> Self {
self.readonly = Some(readonly);
self
}
pub fn repository(mut self, repository: impl Into<String>) -> Self {
self.repository = Some(repository.into());
self
}
pub fn step_up(mut self, step_up: bool) -> Self {
self.step_up = Some(step_up);
self
}
pub fn step_up_require_passkey(mut self, step_up_require_passkey: bool) -> Self {
self.step_up_require_passkey = Some(step_up_require_passkey);
self
}
pub fn strip_prefix(mut self, strip_prefix: impl Into<String>) -> Self {
self.strip_prefix = Some(strip_prefix.into());
self
}
pub fn target(mut self, target: impl Into<String>) -> Self {
self.target = Some(target.into());
self
}
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
pub fn webhook_url(mut self, webhook_url: impl Into<String>) -> Self {
self.webhook_url = Some(webhook_url.into());
self
}
}
impl<'a> IntoFuture for IntegrationsEdit<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations edit");
line.bool("act-as-user", self.act_as_user);
line.string("bearer", self.bearer);
line.bool("clear-header", self.clear_header);
line.string("comment", self.comment);
line.string("endpoint", self.endpoint);
line.string("external-connection", self.external_connection);
line.list("fields", self.fields);
line.repeated("header", self.headers);
line.repeated("host-key", self.host_keys);
line.bool("no-auth", self.no_auth);
line.bool("readonly", self.readonly);
line.string("repository", self.repository);
line.bool("step-up", self.step_up);
line.bool("step-up-require-passkey", self.step_up_require_passkey);
line.string("strip-prefix", self.strip_prefix);
line.string("target", self.target);
line.bool("team", self.team);
line.string("webhook-url", self.webhook_url);
line.arg(self.name);
line.args("args", self.args, false);
let line = line.finish()?;
self.c.t.call("integrations edit", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsAttach<'a> {
c: &'a Client,
name: String,
spec: String,
for_duration: Option<String>,
team: Option<bool>,
until: Option<String>,
}
impl<'a> IntegrationsAttach<'a> {
pub fn for_duration(mut self, for_duration: impl Into<String>) -> Self {
self.for_duration = Some(for_duration.into());
self
}
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
pub fn until(mut self, until: impl Into<String>) -> Self {
self.until = Some(until.into());
self
}
}
impl<'a> IntoFuture for IntegrationsAttach<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations attach");
line.string("for", self.for_duration);
line.bool("team", self.team);
line.string("until", self.until);
line.arg(self.name);
line.arg(self.spec);
let line = line.finish()?;
self.c.t.call("integrations attach", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsDetach<'a> {
c: &'a Client,
name: String,
spec: String,
team: Option<bool>,
}
impl<'a> IntegrationsDetach<'a> {
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsDetach<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations detach");
line.bool("team", self.team);
line.arg(self.name);
line.arg(self.spec);
let line = line.finish()?;
self.c.t.call("integrations detach", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsRename<'a> {
c: &'a Client,
name: String,
new_name: String,
team: Option<bool>,
}
impl<'a> IntegrationsRename<'a> {
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsRename<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations rename");
line.bool("team", self.team);
line.arg(self.name);
line.arg(self.new_name);
let line = line.finish()?;
self.c.t.call("integrations rename", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsCatalog<'a> {
c: &'a Client,
query: Option<String>,
}
impl<'a> IntegrationsCatalog<'a> {
pub fn query(mut self, query: impl Into<String>) -> Self {
self.query = Some(query.into());
self
}
}
impl<'a> IntoFuture for IntegrationsCatalog<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations catalog");
line.opt_arg(self.query);
let line = line.finish()?;
self.c.t.call("integrations catalog", &line).await
})
}
}
pub struct IntegrationsSetup<'a> {
c: &'a Client,
}
impl<'a> IntegrationsSetup<'a> {
pub fn github(&self) -> IntegrationsSetupGithub<'a> {
IntegrationsSetupGithub {
c: self.c,
delete: None,
list: None,
repos: None,
verify: None,
}
}
pub fn chatgpt(&self) -> IntegrationsSetupChatgpt<'a> {
IntegrationsSetupChatgpt {
c: self.c,
delete: None,
list: None,
name: None,
verify: None,
}
}
pub fn execonnect(&self) -> IntegrationsSetupExeconnect<'a> {
IntegrationsSetupExeconnect {
c: self.c,
delete: None,
list: None,
name: None,
team: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsSetupGithub<'a> {
c: &'a Client,
delete: Option<bool>,
list: Option<bool>,
repos: Option<bool>,
verify: Option<bool>,
}
impl<'a> IntegrationsSetupGithub<'a> {
pub fn delete(mut self, delete: bool) -> Self {
self.delete = Some(delete);
self
}
pub fn list(mut self, list: bool) -> Self {
self.list = Some(list);
self
}
pub fn repos(mut self, repos: bool) -> Self {
self.repos = Some(repos);
self
}
pub fn verify(mut self, verify: bool) -> Self {
self.verify = Some(verify);
self
}
}
impl<'a> IntoFuture for IntegrationsSetupGithub<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations setup github");
line.bool("delete", self.delete);
line.bool("list", self.list);
line.bool("repos", self.repos);
line.bool("verify", self.verify);
let line = line.finish()?;
self.c.t.call("integrations setup github", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsSetupChatgpt<'a> {
c: &'a Client,
delete: Option<bool>,
list: Option<bool>,
name: Option<String>,
verify: Option<bool>,
}
impl<'a> IntegrationsSetupChatgpt<'a> {
pub fn delete(mut self, delete: bool) -> Self {
self.delete = Some(delete);
self
}
pub fn list(mut self, list: bool) -> Self {
self.list = Some(list);
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn verify(mut self, verify: bool) -> Self {
self.verify = Some(verify);
self
}
}
impl<'a> IntoFuture for IntegrationsSetupChatgpt<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations setup chatgpt");
line.bool("delete", self.delete);
line.bool("list", self.list);
line.string("name", self.name);
line.bool("verify", self.verify);
let line = line.finish()?;
self.c.t.call("integrations setup chatgpt", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct IntegrationsSetupExeconnect<'a> {
c: &'a Client,
delete: Option<bool>,
list: Option<bool>,
name: Option<String>,
team: Option<bool>,
}
impl<'a> IntegrationsSetupExeconnect<'a> {
pub fn delete(mut self, delete: bool) -> Self {
self.delete = Some(delete);
self
}
pub fn list(mut self, list: bool) -> Self {
self.list = Some(list);
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn team(mut self, team: bool) -> Self {
self.team = Some(team);
self
}
}
impl<'a> IntoFuture for IntegrationsSetupExeconnect<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("integrations setup execonnect");
line.bool("delete", self.delete);
line.bool("list", self.list);
line.string("name", self.name);
line.bool("team", self.team);
let line = line.finish()?;
self.c.t.call("integrations setup execonnect", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Team<'a> {
c: &'a Client,
}
impl<'a> Team<'a> {
pub fn disable(&self) -> TeamDisable<'a> {
TeamDisable {
c: self.c,
yes: None,
}
}
pub fn members(&self) -> TeamMembers<'a> {
TeamMembers {
c: self.c,
}
}
pub fn usage(&self) -> TeamUsage<'a> {
TeamUsage {
c: self.c,
}
}
pub fn add(&self, email: impl Into<String>) -> TeamAdd<'a> {
TeamAdd {
c: self.c,
email: email.into(),
role: None,
}
}
pub fn remove(&self, email: impl Into<String>) -> TeamRemove<'a> {
TeamRemove {
c: self.c,
email: email.into(),
transfer_vms_to: None,
}
}
pub fn role(&self, email: impl Into<String>, role: impl Into<String>) -> TeamRole<'a> {
TeamRole {
c: self.c,
email: email.into(),
role: role.into(),
}
}
pub fn rename(&self, name: impl Into<String>) -> TeamRename<'a> {
TeamRename {
c: self.c,
name: name.into(),
}
}
pub fn transfer(&self, vm_name: impl Into<String>, target_email: impl Into<String>) -> TeamTransfer<'a> {
TeamTransfer {
c: self.c,
vm_name: vm_name.into(),
target_email: target_email.into(),
}
}
pub fn billing(&self) -> TeamBilling<'a> {
TeamBilling {
c: self.c,
}
}
pub fn auth(&self) -> TeamAuth<'a> {
TeamAuth {
c: self.c,
}
}
pub fn settings(&self) -> TeamSettings<'a> {
TeamSettings {
c: self.c,
}
}
pub fn vm(&self) -> TeamVm<'a> {
TeamVm {
c: self.c,
}
}
}
impl<'a> IntoFuture for Team<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team").finish()?;
self.c.t.call("team", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamDisable<'a> {
c: &'a Client,
yes: Option<bool>,
}
impl<'a> TeamDisable<'a> {
pub fn yes(mut self, yes: bool) -> Self {
self.yes = Some(yes);
self
}
}
impl<'a> IntoFuture for TeamDisable<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team disable");
line.bool("yes", self.yes);
let line = line.finish()?;
self.c.t.call("team disable", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamMembers<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for TeamMembers<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team members").finish()?;
self.c.t.call("team members", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamUsage<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for TeamUsage<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team usage").finish()?;
self.c.t.call("team usage", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamAdd<'a> {
c: &'a Client,
email: String,
role: Option<String>,
}
impl<'a> TeamAdd<'a> {
pub fn role(mut self, role: impl Into<String>) -> Self {
self.role = Some(role.into());
self
}
}
impl<'a> IntoFuture for TeamAdd<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team add");
line.arg(self.email);
line.opt_arg(self.role);
let line = line.finish()?;
self.c.t.call("team add", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamRemove<'a> {
c: &'a Client,
email: String,
transfer_vms_to: Option<String>,
}
impl<'a> TeamRemove<'a> {
pub fn transfer_vms_to(mut self, transfer_vms_to: impl Into<String>) -> Self {
self.transfer_vms_to = Some(transfer_vms_to.into());
self
}
}
impl<'a> IntoFuture for TeamRemove<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team remove");
line.string("transfer-vms-to", self.transfer_vms_to);
line.arg(self.email);
let line = line.finish()?;
self.c.t.call("team remove", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamRole<'a> {
c: &'a Client,
email: String,
role: String,
}
impl<'a> IntoFuture for TeamRole<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team role");
line.arg(self.email);
line.arg(self.role);
let line = line.finish()?;
self.c.t.call("team role", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamRename<'a> {
c: &'a Client,
name: String,
}
impl<'a> IntoFuture for TeamRename<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team rename");
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("team rename", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamTransfer<'a> {
c: &'a Client,
vm_name: String,
target_email: String,
}
impl<'a> IntoFuture for TeamTransfer<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team transfer");
line.arg(self.vm_name);
line.arg(self.target_email);
let line = line.finish()?;
self.c.t.call("team transfer", &line).await
})
}
}
pub struct TeamBilling<'a> {
c: &'a Client,
}
impl<'a> TeamBilling<'a> {
pub fn plan(&self) -> TeamBillingPlan<'a> {
TeamBillingPlan {
c: self.c,
all: None,
}
}
pub fn update(&self) -> TeamBillingUpdate<'a> {
TeamBillingUpdate {
c: self.c,
address_city: None,
address_country: None,
address_line1: None,
address_line2: None,
address_postal_code: None,
address_state: None,
business_name: None,
email: None,
name: None,
phone: None,
tax_id_type: None,
tax_id_value: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamBillingPlan<'a> {
c: &'a Client,
all: Option<bool>,
}
impl<'a> TeamBillingPlan<'a> {
pub fn all(mut self, all: bool) -> Self {
self.all = Some(all);
self
}
}
impl<'a> IntoFuture for TeamBillingPlan<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team billing plan");
line.bool("all", self.all);
let line = line.finish()?;
self.c.t.call("team billing plan", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamBillingUpdate<'a> {
c: &'a Client,
address_city: Option<String>,
address_country: Option<String>,
address_line1: Option<String>,
address_line2: Option<String>,
address_postal_code: Option<String>,
address_state: Option<String>,
business_name: Option<String>,
email: Option<String>,
name: Option<String>,
phone: Option<String>,
tax_id_type: Option<String>,
tax_id_value: Option<String>,
}
impl<'a> TeamBillingUpdate<'a> {
pub fn address_city(mut self, address_city: impl Into<String>) -> Self {
self.address_city = Some(address_city.into());
self
}
pub fn address_country(mut self, address_country: impl Into<String>) -> Self {
self.address_country = Some(address_country.into());
self
}
pub fn address_line1(mut self, address_line1: impl Into<String>) -> Self {
self.address_line1 = Some(address_line1.into());
self
}
pub fn address_line2(mut self, address_line2: impl Into<String>) -> Self {
self.address_line2 = Some(address_line2.into());
self
}
pub fn address_postal_code(mut self, address_postal_code: impl Into<String>) -> Self {
self.address_postal_code = Some(address_postal_code.into());
self
}
pub fn address_state(mut self, address_state: impl Into<String>) -> Self {
self.address_state = Some(address_state.into());
self
}
pub fn business_name(mut self, business_name: impl Into<String>) -> Self {
self.business_name = Some(business_name.into());
self
}
pub fn email(mut self, email: impl Into<String>) -> Self {
self.email = Some(email.into());
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn phone(mut self, phone: impl Into<String>) -> Self {
self.phone = Some(phone.into());
self
}
pub fn tax_id_type(mut self, tax_id_type: impl Into<String>) -> Self {
self.tax_id_type = Some(tax_id_type.into());
self
}
pub fn tax_id_value(mut self, tax_id_value: impl Into<String>) -> Self {
self.tax_id_value = Some(tax_id_value.into());
self
}
}
impl<'a> IntoFuture for TeamBillingUpdate<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team billing update");
line.string("address-city", self.address_city);
line.string("address-country", self.address_country);
line.string("address-line1", self.address_line1);
line.string("address-line2", self.address_line2);
line.string("address-postal-code", self.address_postal_code);
line.string("address-state", self.address_state);
line.string("business-name", self.business_name);
line.string("email", self.email);
line.string("name", self.name);
line.string("phone", self.phone);
line.string("tax-id-type", self.tax_id_type);
line.string("tax-id-value", self.tax_id_value);
let line = line.finish()?;
self.c.t.call("team billing update", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamAuth<'a> {
c: &'a Client,
}
impl<'a> TeamAuth<'a> {
pub fn require_oidc(&self, mode: impl Into<String>) -> TeamAuthRequireOidc<'a> {
TeamAuthRequireOidc {
c: self.c,
mode: mode.into(),
}
}
pub fn set(&self, provider: impl Into<String>) -> TeamAuthSet<'a> {
TeamAuthSet {
c: self.c,
provider: provider.into(),
client_id: None,
client_secret: None,
display_name: None,
issuer_url: None,
}
}
}
impl<'a> IntoFuture for TeamAuth<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team auth").finish()?;
self.c.t.call("team auth", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamAuthRequireOidc<'a> {
c: &'a Client,
mode: String,
}
impl<'a> IntoFuture for TeamAuthRequireOidc<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team auth require-oidc");
line.arg(self.mode);
let line = line.finish()?;
self.c.t.call("team auth require-oidc", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamAuthSet<'a> {
c: &'a Client,
provider: String,
client_id: Option<String>,
client_secret: Option<String>,
display_name: Option<String>,
issuer_url: Option<String>,
}
impl<'a> TeamAuthSet<'a> {
pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
self.client_id = Some(client_id.into());
self
}
pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
self.client_secret = Some(client_secret.into());
self
}
pub fn display_name(mut self, display_name: impl Into<String>) -> Self {
self.display_name = Some(display_name.into());
self
}
pub fn issuer_url(mut self, issuer_url: impl Into<String>) -> Self {
self.issuer_url = Some(issuer_url.into());
self
}
}
impl<'a> IntoFuture for TeamAuthSet<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team auth set");
line.string("client-id", self.client_id);
line.string("client-secret", self.client_secret);
line.string("display-name", self.display_name);
line.string("issuer-url", self.issuer_url);
line.arg(self.provider);
let line = line.finish()?;
self.c.t.call("team auth set", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettings<'a> {
c: &'a Client,
}
impl<'a> TeamSettings<'a> {
pub fn standalone(&self, who: impl Into<String>) -> TeamSettingsStandalone<'a> {
TeamSettingsStandalone {
c: self.c,
who: who.into(),
}
}
pub fn llm_gateway(&self, enabled: bool) -> TeamSettingsLlmGateway<'a> {
TeamSettingsLlmGateway {
c: self.c,
enabled,
}
}
pub fn core_sharing(&self, enabled: bool) -> TeamSettingsCoreSharing<'a> {
TeamSettingsCoreSharing {
c: self.c,
enabled,
}
}
pub fn vm_sharing(&self, who: impl Into<String>) -> TeamSettingsVmSharing<'a> {
TeamSettingsVmSharing {
c: self.c,
who: who.into(),
}
}
pub fn public_sharing(&self, enabled: bool) -> TeamSettingsPublicSharing<'a> {
TeamSettingsPublicSharing {
c: self.c,
enabled,
}
}
pub fn session_length(&self, length: impl Into<String>) -> TeamSettingsSessionLength<'a> {
TeamSettingsSessionLength {
c: self.c,
length: length.into(),
}
}
pub fn auto_join(&self, enabled: bool) -> TeamSettingsAutoJoin<'a> {
TeamSettingsAutoJoin {
c: self.c,
enabled,
}
}
pub fn vm_placement(&self) -> TeamSettingsVmPlacement<'a> {
TeamSettingsVmPlacement {
c: self.c,
}
}
}
impl<'a> IntoFuture for TeamSettings<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team settings").finish()?;
self.c.t.call("team settings", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsStandalone<'a> {
c: &'a Client,
who: String,
}
impl<'a> IntoFuture for TeamSettingsStandalone<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings standalone");
line.arg(self.who);
let line = line.finish()?;
self.c.t.call("team settings standalone", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsLlmGateway<'a> {
c: &'a Client,
enabled: bool,
}
impl<'a> IntoFuture for TeamSettingsLlmGateway<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings llm-gateway");
line.arg(wire::on_off(self.enabled));
let line = line.finish()?;
self.c.t.call("team settings llm-gateway", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsCoreSharing<'a> {
c: &'a Client,
enabled: bool,
}
impl<'a> IntoFuture for TeamSettingsCoreSharing<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings core-sharing");
line.arg(wire::on_off(self.enabled));
let line = line.finish()?;
self.c.t.call("team settings core-sharing", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsVmSharing<'a> {
c: &'a Client,
who: String,
}
impl<'a> IntoFuture for TeamSettingsVmSharing<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings vm-sharing");
line.arg(self.who);
let line = line.finish()?;
self.c.t.call("team settings vm-sharing", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsPublicSharing<'a> {
c: &'a Client,
enabled: bool,
}
impl<'a> IntoFuture for TeamSettingsPublicSharing<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings public-sharing");
line.arg(wire::on_off(self.enabled));
let line = line.finish()?;
self.c.t.call("team settings public-sharing", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsSessionLength<'a> {
c: &'a Client,
length: String,
}
impl<'a> IntoFuture for TeamSettingsSessionLength<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings session-length");
line.arg(self.length);
let line = line.finish()?;
self.c.t.call("team settings session-length", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsAutoJoin<'a> {
c: &'a Client,
enabled: bool,
}
impl<'a> IntoFuture for TeamSettingsAutoJoin<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings auto-join");
line.arg(wire::on_off(self.enabled));
let line = line.finish()?;
self.c.t.call("team settings auto-join", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsVmPlacement<'a> {
c: &'a Client,
}
impl<'a> TeamSettingsVmPlacement<'a> {
pub fn default(&self) -> TeamSettingsVmPlacementDefault<'a> {
TeamSettingsVmPlacementDefault {
c: self.c,
}
}
pub fn pool(&self, name: impl Into<String>) -> TeamSettingsVmPlacementPool<'a> {
TeamSettingsVmPlacementPool {
c: self.c,
name: name.into(),
}
}
pub fn member_pool(&self) -> TeamSettingsVmPlacementMemberPool<'a> {
TeamSettingsVmPlacementMemberPool {
c: self.c,
cpus: None,
max_vms: None,
}
}
pub fn poolless(&self) -> TeamSettingsVmPlacementPoolless<'a> {
TeamSettingsVmPlacementPoolless {
c: self.c,
}
}
}
impl<'a> IntoFuture for TeamSettingsVmPlacement<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team settings vm-placement").finish()?;
self.c.t.call("team settings vm-placement", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsVmPlacementDefault<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for TeamSettingsVmPlacementDefault<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team settings vm-placement default").finish()?;
self.c.t.call("team settings vm-placement default", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsVmPlacementPool<'a> {
c: &'a Client,
name: String,
}
impl<'a> IntoFuture for TeamSettingsVmPlacementPool<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings vm-placement pool");
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("team settings vm-placement pool", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsVmPlacementMemberPool<'a> {
c: &'a Client,
cpus: Option<i64>,
max_vms: Option<i64>,
}
impl<'a> TeamSettingsVmPlacementMemberPool<'a> {
pub fn cpus(mut self, cpus: i64) -> Self {
self.cpus = Some(cpus);
self
}
pub fn max_vms(mut self, max_vms: i64) -> Self {
self.max_vms = Some(max_vms);
self
}
}
impl<'a> IntoFuture for TeamSettingsVmPlacementMemberPool<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team settings vm-placement member-pool");
line.number("cpus", self.cpus);
line.number("max-vms", self.max_vms);
let line = line.finish()?;
self.c.t.call("team settings vm-placement member-pool", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamSettingsVmPlacementPoolless<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for TeamSettingsVmPlacementPoolless<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("team settings vm-placement poolless").finish()?;
self.c.t.call("team settings vm-placement poolless", &line).await
})
}
}
pub struct TeamVm<'a> {
c: &'a Client,
}
impl<'a> TeamVm<'a> {
pub fn ls(&self) -> TeamVmLs<'a> {
TeamVmLs {
c: self.c,
value: None,
group: None,
long: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct TeamVmLs<'a> {
c: &'a Client,
value: Option<String>,
group: Option<String>,
long: Option<bool>,
}
impl<'a> TeamVmLs<'a> {
pub fn value(mut self, value: impl Into<String>) -> Self {
self.value = Some(value.into());
self
}
pub fn group(mut self, group: impl Into<String>) -> Self {
self.group = Some(group.into());
self
}
pub fn long(mut self, long: bool) -> Self {
self.long = Some(long);
self
}
}
impl<'a> IntoFuture for TeamVmLs<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("team vm ls");
line.string("group", self.group);
line.bool("l", self.long);
line.opt_arg(self.value);
let line = line.finish()?;
self.c.t.call("team vm ls", &line).await
})
}
}
pub struct Pool<'a> {
c: &'a Client,
}
impl<'a> Pool<'a> {
pub fn create(&self, name: impl Into<String>) -> PoolNew<'a> {
PoolNew {
c: self.c,
name: name.into(),
cpus: None,
max_vms: None,
region: None,
}
}
pub fn list(&self) -> PoolList<'a> {
PoolList {
c: self.c,
pool_name: None,
fields: None,
format: None,
range: None,
usage: None,
}
}
pub fn adopt(&self) -> PoolAdopt<'a> {
PoolAdopt {
c: self.c,
pool: None,
vm: None,
}
}
pub fn detach(&self) -> PoolDetach<'a> {
PoolDetach {
c: self.c,
poolless: None,
vm: None,
}
}
pub fn resize(&self) -> PoolResize<'a> {
PoolResize {
c: self.c,
args: Vec::new(),
cpus: None,
force: None,
max_vms: None,
}
}
pub fn rename(&self, old_name: impl Into<String>, new_name: impl Into<String>) -> PoolRename<'a> {
PoolRename {
c: self.c,
old_name: old_name.into(),
new_name: new_name.into(),
}
}
pub fn delete(&self, name: impl Into<String>) -> PoolDelete<'a> {
PoolDelete {
c: self.c,
name: name.into(),
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolNew<'a> {
c: &'a Client,
name: String,
cpus: Option<i64>,
max_vms: Option<i64>,
region: Option<String>,
}
impl<'a> PoolNew<'a> {
pub fn cpus(mut self, cpus: i64) -> Self {
self.cpus = Some(cpus);
self
}
pub fn max_vms(mut self, max_vms: i64) -> Self {
self.max_vms = Some(max_vms);
self
}
pub fn region(mut self, region: impl Into<String>) -> Self {
self.region = Some(region.into());
self
}
}
impl<'a> IntoFuture for PoolNew<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool new");
line.number("cpus", self.cpus);
line.number("max-vms", self.max_vms);
line.string("region", self.region);
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("pool new", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolList<'a> {
c: &'a Client,
pool_name: Option<String>,
fields: Option<Vec<String>>,
format: Option<String>,
range: Option<String>,
usage: Option<bool>,
}
impl<'a> PoolList<'a> {
pub fn pool_name(mut self, pool_name: impl Into<String>) -> Self {
self.pool_name = Some(pool_name.into());
self
}
pub fn fields(mut self, fields: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.fields.get_or_insert_with(Vec::new).extend(fields.into_iter().map(Into::into));
self
}
pub fn format(mut self, format: impl Into<String>) -> Self {
self.format = Some(format.into());
self
}
pub fn range(mut self, range: impl Into<String>) -> Self {
self.range = Some(range.into());
self
}
pub fn usage(mut self, usage: bool) -> Self {
self.usage = Some(usage);
self
}
}
impl<'a> IntoFuture for PoolList<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool list");
line.list("fields", self.fields);
line.string("format", self.format);
line.string("range", self.range);
line.bool("usage", self.usage);
line.opt_arg(self.pool_name);
let line = line.finish()?;
self.c.t.call("pool list", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolAdopt<'a> {
c: &'a Client,
pool: Option<String>,
vm: Option<String>,
}
impl<'a> PoolAdopt<'a> {
pub fn pool(mut self, pool: impl Into<String>) -> Self {
self.pool = Some(pool.into());
self
}
pub fn vm(mut self, vm: impl Into<String>) -> Self {
self.vm = Some(vm.into());
self
}
}
impl<'a> IntoFuture for PoolAdopt<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool adopt");
line.string("pool", self.pool);
line.string("vm", self.vm);
let line = line.finish()?;
self.c.t.call("pool adopt", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolDetach<'a> {
c: &'a Client,
poolless: Option<bool>,
vm: Option<String>,
}
impl<'a> PoolDetach<'a> {
pub fn poolless(mut self, poolless: bool) -> Self {
self.poolless = Some(poolless);
self
}
pub fn vm(mut self, vm: impl Into<String>) -> Self {
self.vm = Some(vm.into());
self
}
}
impl<'a> IntoFuture for PoolDetach<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool detach");
line.bool("poolless", self.poolless);
line.string("vm", self.vm);
let line = line.finish()?;
self.c.t.call("pool detach", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolResize<'a> {
c: &'a Client,
args: Vec<String>,
cpus: Option<i64>,
force: Option<bool>,
max_vms: Option<String>,
}
impl<'a> PoolResize<'a> {
pub fn args(mut self, args: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.args.extend(args.into_iter().map(Into::into));
self
}
pub fn cpus(mut self, cpus: i64) -> Self {
self.cpus = Some(cpus);
self
}
pub fn force(mut self, force: bool) -> Self {
self.force = Some(force);
self
}
pub fn max_vms(mut self, max_vms: impl Into<String>) -> Self {
self.max_vms = Some(max_vms.into());
self
}
}
impl<'a> IntoFuture for PoolResize<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool resize");
line.number("cpus", self.cpus);
line.bool("force", self.force);
line.string("max-vms", self.max_vms);
line.args("args", self.args, false);
let line = line.finish()?;
self.c.t.call("pool resize", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolRename<'a> {
c: &'a Client,
old_name: String,
new_name: String,
}
impl<'a> IntoFuture for PoolRename<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool rename");
line.arg(self.old_name);
line.arg(self.new_name);
let line = line.finish()?;
self.c.t.call("pool rename", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct PoolDelete<'a> {
c: &'a Client,
name: String,
}
impl<'a> IntoFuture for PoolDelete<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pool delete");
line.arg(self.name);
let line = line.finish()?;
self.c.t.call("pool delete", &line).await
})
}
}
pub struct Billing<'a> {
c: &'a Client,
}
impl<'a> Billing<'a> {
pub fn plan(&self) -> BillingPlan<'a> {
BillingPlan {
c: self.c,
all: None,
}
}
pub fn usage(&self) -> BillingUsage<'a> {
BillingUsage {
c: self.c,
group: None,
history: None,
range: None,
}
}
pub fn rewards(&self) -> BillingRewards<'a> {
BillingRewards {
c: self.c,
}
}
pub fn capacity(&self) -> BillingCapacity<'a> {
BillingCapacity {
c: self.c,
cpu: None,
yes: None,
}
}
pub fn manage(&self) -> BillingManage<'a> {
BillingManage {
c: self.c,
}
}
pub fn activate(&self) -> BillingActivate<'a> {
BillingActivate {
c: self.c,
}
}
pub fn update(&self) -> BillingUpdate<'a> {
BillingUpdate {
c: self.c,
address_city: None,
address_country: None,
address_line1: None,
address_line2: None,
address_postal_code: None,
address_state: None,
business_name: None,
email: None,
name: None,
phone: None,
tax_id_type: None,
tax_id_value: None,
}
}
pub fn receipts(&self) -> BillingReceipts<'a> {
BillingReceipts {
c: self.c,
from: None,
to: None,
}
}
pub fn statement(&self) -> BillingStatement<'a> {
BillingStatement {
c: self.c,
from: None,
to: None,
}
}
pub fn credits(&self) -> BillingCredits<'a> {
BillingCredits {
c: self.c,
}
}
pub fn payment(&self) -> BillingPayment<'a> {
BillingPayment {
c: self.c,
}
}
pub fn invoices(&self) -> BillingInvoices<'a> {
BillingInvoices {
c: self.c,
}
}
pub fn provider(&self) -> BillingProvider<'a> {
BillingProvider {
c: self.c,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingPlan<'a> {
c: &'a Client,
all: Option<bool>,
}
impl<'a> BillingPlan<'a> {
pub fn all(mut self, all: bool) -> Self {
self.all = Some(all);
self
}
}
impl<'a> IntoFuture for BillingPlan<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing plan");
line.bool("all", self.all);
let line = line.finish()?;
self.c.t.call("billing plan", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingUsage<'a> {
c: &'a Client,
group: Option<String>,
history: Option<bool>,
range: Option<String>,
}
impl<'a> BillingUsage<'a> {
pub fn group(mut self, group: impl Into<String>) -> Self {
self.group = Some(group.into());
self
}
pub fn history(mut self, history: bool) -> Self {
self.history = Some(history);
self
}
pub fn range(mut self, range: impl Into<String>) -> Self {
self.range = Some(range.into());
self
}
}
impl<'a> IntoFuture for BillingUsage<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing usage");
line.string("group", self.group);
line.bool("history", self.history);
line.string("range", self.range);
let line = line.finish()?;
self.c.t.call("billing usage", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingRewards<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for BillingRewards<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing rewards").finish()?;
self.c.t.call("billing rewards", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingCapacity<'a> {
c: &'a Client,
cpu: Option<i64>,
yes: Option<bool>,
}
impl<'a> BillingCapacity<'a> {
pub fn cpu(mut self, cpu: i64) -> Self {
self.cpu = Some(cpu);
self
}
pub fn yes(mut self, yes: bool) -> Self {
self.yes = Some(yes);
self
}
}
impl<'a> IntoFuture for BillingCapacity<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing capacity");
line.number("cpu", self.cpu);
line.bool("yes", self.yes);
let line = line.finish()?;
self.c.t.call("billing capacity", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingManage<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for BillingManage<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing manage").finish()?;
self.c.t.call("billing manage", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingActivate<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for BillingActivate<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing activate").finish()?;
self.c.t.call("billing activate", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingUpdate<'a> {
c: &'a Client,
address_city: Option<String>,
address_country: Option<String>,
address_line1: Option<String>,
address_line2: Option<String>,
address_postal_code: Option<String>,
address_state: Option<String>,
business_name: Option<String>,
email: Option<String>,
name: Option<String>,
phone: Option<String>,
tax_id_type: Option<String>,
tax_id_value: Option<String>,
}
impl<'a> BillingUpdate<'a> {
pub fn address_city(mut self, address_city: impl Into<String>) -> Self {
self.address_city = Some(address_city.into());
self
}
pub fn address_country(mut self, address_country: impl Into<String>) -> Self {
self.address_country = Some(address_country.into());
self
}
pub fn address_line1(mut self, address_line1: impl Into<String>) -> Self {
self.address_line1 = Some(address_line1.into());
self
}
pub fn address_line2(mut self, address_line2: impl Into<String>) -> Self {
self.address_line2 = Some(address_line2.into());
self
}
pub fn address_postal_code(mut self, address_postal_code: impl Into<String>) -> Self {
self.address_postal_code = Some(address_postal_code.into());
self
}
pub fn address_state(mut self, address_state: impl Into<String>) -> Self {
self.address_state = Some(address_state.into());
self
}
pub fn business_name(mut self, business_name: impl Into<String>) -> Self {
self.business_name = Some(business_name.into());
self
}
pub fn email(mut self, email: impl Into<String>) -> Self {
self.email = Some(email.into());
self
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn phone(mut self, phone: impl Into<String>) -> Self {
self.phone = Some(phone.into());
self
}
pub fn tax_id_type(mut self, tax_id_type: impl Into<String>) -> Self {
self.tax_id_type = Some(tax_id_type.into());
self
}
pub fn tax_id_value(mut self, tax_id_value: impl Into<String>) -> Self {
self.tax_id_value = Some(tax_id_value.into());
self
}
}
impl<'a> IntoFuture for BillingUpdate<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing update");
line.string("address-city", self.address_city);
line.string("address-country", self.address_country);
line.string("address-line1", self.address_line1);
line.string("address-line2", self.address_line2);
line.string("address-postal-code", self.address_postal_code);
line.string("address-state", self.address_state);
line.string("business-name", self.business_name);
line.string("email", self.email);
line.string("name", self.name);
line.string("phone", self.phone);
line.string("tax-id-type", self.tax_id_type);
line.string("tax-id-value", self.tax_id_value);
let line = line.finish()?;
self.c.t.call("billing update", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingReceipts<'a> {
c: &'a Client,
from: Option<String>,
to: Option<String>,
}
impl<'a> BillingReceipts<'a> {
pub fn from(mut self, from: impl Into<String>) -> Self {
self.from = Some(from.into());
self
}
pub fn to(mut self, to: impl Into<String>) -> Self {
self.to = Some(to.into());
self
}
}
impl<'a> IntoFuture for BillingReceipts<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing receipts");
line.string("from", self.from);
line.string("to", self.to);
let line = line.finish()?;
self.c.t.call("billing receipts", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingStatement<'a> {
c: &'a Client,
from: Option<String>,
to: Option<String>,
}
impl<'a> BillingStatement<'a> {
pub fn from(mut self, from: impl Into<String>) -> Self {
self.from = Some(from.into());
self
}
pub fn to(mut self, to: impl Into<String>) -> Self {
self.to = Some(to.into());
self
}
}
impl<'a> IntoFuture for BillingStatement<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing statement");
line.string("from", self.from);
line.string("to", self.to);
let line = line.finish()?;
self.c.t.call("billing statement", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingCredits<'a> {
c: &'a Client,
}
impl<'a> BillingCredits<'a> {
pub fn usage(&self) -> BillingCreditsUsage<'a> {
BillingCreditsUsage {
c: self.c,
detail: None,
group: None,
month: None,
}
}
pub fn transactions(&self) -> BillingCreditsTransactions<'a> {
BillingCreditsTransactions {
c: self.c,
limit: None,
}
}
pub fn buy(&self, dollars: impl Into<String>) -> BillingCreditsBuy<'a> {
BillingCreditsBuy {
c: self.c,
dollars: dollars.into(),
idempotency_key: None,
yes: None,
}
}
}
impl<'a> IntoFuture for BillingCredits<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing credits").finish()?;
self.c.t.call("billing credits", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingCreditsUsage<'a> {
c: &'a Client,
detail: Option<bool>,
group: Option<String>,
month: Option<String>,
}
impl<'a> BillingCreditsUsage<'a> {
pub fn detail(mut self, detail: bool) -> Self {
self.detail = Some(detail);
self
}
pub fn group(mut self, group: impl Into<String>) -> Self {
self.group = Some(group.into());
self
}
pub fn month(mut self, month: impl Into<String>) -> Self {
self.month = Some(month.into());
self
}
}
impl<'a> IntoFuture for BillingCreditsUsage<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing credits usage");
line.bool("detail", self.detail);
line.string("group", self.group);
line.string("month", self.month);
let line = line.finish()?;
self.c.t.call("billing credits usage", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingCreditsTransactions<'a> {
c: &'a Client,
limit: Option<String>,
}
impl<'a> BillingCreditsTransactions<'a> {
pub fn limit(mut self, limit: impl Into<String>) -> Self {
self.limit = Some(limit.into());
self
}
}
impl<'a> IntoFuture for BillingCreditsTransactions<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing credits transactions");
line.string("limit", self.limit);
let line = line.finish()?;
self.c.t.call("billing credits transactions", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingCreditsBuy<'a> {
c: &'a Client,
dollars: String,
idempotency_key: Option<String>,
yes: Option<bool>,
}
impl<'a> BillingCreditsBuy<'a> {
pub fn idempotency_key(mut self, idempotency_key: impl Into<String>) -> Self {
self.idempotency_key = Some(idempotency_key.into());
self
}
pub fn yes(mut self, yes: bool) -> Self {
self.yes = Some(yes);
self
}
}
impl<'a> IntoFuture for BillingCreditsBuy<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing credits buy");
line.string("idempotency-key", self.idempotency_key);
line.bool("yes", self.yes);
line.arg(self.dollars);
let line = line.finish()?;
self.c.t.call("billing credits buy", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingPayment<'a> {
c: &'a Client,
}
impl<'a> BillingPayment<'a> {
pub fn list(&self) -> BillingPaymentList<'a> {
BillingPaymentList {
c: self.c,
}
}
pub fn remove(&self, reference: impl Into<String>) -> BillingPaymentRemove<'a> {
BillingPaymentRemove {
c: self.c,
reference: reference.into(),
}
}
pub fn default(&self, reference: impl Into<String>) -> BillingPaymentDefault<'a> {
BillingPaymentDefault {
c: self.c,
reference: reference.into(),
}
}
}
impl<'a> IntoFuture for BillingPayment<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing payment").finish()?;
self.c.t.call("billing payment", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingPaymentList<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for BillingPaymentList<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing payment list").finish()?;
self.c.t.call("billing payment list", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingPaymentRemove<'a> {
c: &'a Client,
reference: String,
}
impl<'a> IntoFuture for BillingPaymentRemove<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing payment remove");
line.arg(self.reference);
let line = line.finish()?;
self.c.t.call("billing payment remove", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingPaymentDefault<'a> {
c: &'a Client,
reference: String,
}
impl<'a> IntoFuture for BillingPaymentDefault<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing payment default");
line.arg(self.reference);
let line = line.finish()?;
self.c.t.call("billing payment default", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingInvoices<'a> {
c: &'a Client,
}
impl<'a> BillingInvoices<'a> {
pub fn list(&self) -> BillingInvoicesList<'a> {
BillingInvoicesList {
c: self.c,
account: None,
}
}
pub fn show(&self, id: impl Into<String>) -> BillingInvoicesShow<'a> {
BillingInvoicesShow {
c: self.c,
id: id.into(),
vms: None,
}
}
}
impl<'a> IntoFuture for BillingInvoices<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("billing invoices").finish()?;
self.c.t.call("billing invoices", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingInvoicesList<'a> {
c: &'a Client,
account: Option<String>,
}
impl<'a> BillingInvoicesList<'a> {
pub fn account(mut self, account: impl Into<String>) -> Self {
self.account = Some(account.into());
self
}
}
impl<'a> IntoFuture for BillingInvoicesList<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing invoices list");
line.string("account", self.account);
let line = line.finish()?;
self.c.t.call("billing invoices list", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingInvoicesShow<'a> {
c: &'a Client,
id: String,
vms: Option<bool>,
}
impl<'a> BillingInvoicesShow<'a> {
pub fn vms(mut self, vms: bool) -> Self {
self.vms = Some(vms);
self
}
}
impl<'a> IntoFuture for BillingInvoicesShow<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing invoices show");
line.bool("vms", self.vms);
line.arg(self.id);
let line = line.finish()?;
self.c.t.call("billing invoices show", &line).await
})
}
}
pub struct BillingProvider<'a> {
c: &'a Client,
}
impl<'a> BillingProvider<'a> {
pub fn link(&self, provider: impl Into<String>) -> BillingProviderLink<'a> {
BillingProviderLink {
c: self.c,
provider: provider.into(),
size: None,
team_name: None,
token: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct BillingProviderLink<'a> {
c: &'a Client,
provider: String,
size: Option<String>,
team_name: Option<String>,
token: Option<String>,
}
impl<'a> BillingProviderLink<'a> {
pub fn size(mut self, size: impl Into<String>) -> Self {
self.size = Some(size.into());
self
}
pub fn team_name(mut self, team_name: impl Into<String>) -> Self {
self.team_name = Some(team_name.into());
self
}
pub fn token(mut self, token: impl Into<String>) -> Self {
self.token = Some(token.into());
self
}
}
impl<'a> IntoFuture for BillingProviderLink<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("billing provider link");
line.string("size", self.size);
line.string("team-name", self.team_name);
line.string("token", self.token);
line.arg(self.provider);
let line = line.finish()?;
self.c.t.call("billing provider link", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Invite<'a> {
c: &'a Client,
}
impl<'a> Invite<'a> {
pub fn show(&self) -> InviteShow<'a> {
InviteShow {
c: self.c,
}
}
pub fn link(&self) -> InviteLink<'a> {
InviteLink {
c: self.c,
}
}
pub fn rewards(&self) -> InviteRewards<'a> {
InviteRewards {
c: self.c,
}
}
pub fn set_reward(&self, reward: impl Into<String>) -> InviteSetReward<'a> {
InviteSetReward {
c: self.c,
reward: reward.into(),
}
}
pub fn activity(&self) -> InviteActivity<'a> {
InviteActivity {
c: self.c,
}
}
pub fn request(&self) -> InviteRequest<'a> {
InviteRequest {
c: self.c,
}
}
pub fn manage(&self) -> InviteManage<'a> {
InviteManage {
c: self.c,
}
}
}
impl<'a> IntoFuture for Invite<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite").finish()?;
self.c.t.call("invite", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteShow<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for InviteShow<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite show").finish()?;
self.c.t.call("invite show", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteLink<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for InviteLink<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite link").finish()?;
self.c.t.call("invite link", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteRewards<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for InviteRewards<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite rewards").finish()?;
self.c.t.call("invite rewards", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteSetReward<'a> {
c: &'a Client,
reward: String,
}
impl<'a> IntoFuture for InviteSetReward<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("invite set-reward");
line.arg(self.reward);
let line = line.finish()?;
self.c.t.call("invite set-reward", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteActivity<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for InviteActivity<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite activity").finish()?;
self.c.t.call("invite activity", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteRequest<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for InviteRequest<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite request").finish()?;
self.c.t.call("invite request", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct InviteManage<'a> {
c: &'a Client,
}
impl<'a> IntoFuture for InviteManage<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let line = Line::new("invite manage").finish()?;
self.c.t.call("invite manage", &line).await
})
}
}
impl Vm {
pub fn delete(&self) -> Delete<'_> {
Delete {
vm: self,
}
}
pub fn restart(&mut self) -> Restart<'_> {
Restart {
vm: self,
flush: true,
wait_until: WaitUntil::Ssh,
timeout: None,
}
}
pub fn pause(&mut self) -> Pause<'_> {
Pause {
vm: self,
flush: true,
}
}
pub fn resume(&mut self) -> Resume<'_> {
Resume {
vm: self,
wait_until: WaitUntil::Ssh,
timeout: None,
}
}
pub fn rename(&mut self, new_name: impl Into<String>) -> Rename<'_> {
Rename {
vm: self,
new_name: new_name.into(),
}
}
pub fn tag(&mut self, tag_names: impl IntoIterator<Item = impl Into<String>>) -> Tag<'_> {
Tag {
vm: self,
tag_names: tag_names.into_iter().map(Into::into).collect(),
}
}
pub fn untag(&mut self, tag_names: impl IntoIterator<Item = impl Into<String>>) -> Untag<'_> {
Untag {
vm: self,
tag_names: tag_names.into_iter().map(Into::into).collect(),
}
}
pub fn copy(&self) -> CopyVm<'_> {
CopyVm {
vm: self,
name: None,
copy_tags: None,
cpu: None,
disk: None,
egress: None,
memory: None,
pool: None,
standalone: None,
flush: true,
wait_until: WaitUntil::Ssh,
timeout: None,
keep_on_failure: false,
}
}
pub fn resize(&mut self) -> Resize<'_> {
Resize {
vm: self,
cpu: None,
disk: None,
memory: None,
restart: false,
}
}
pub fn set_egress(&mut self, policy: EgressPolicy) -> SetEgress<'_> {
SetEgress {
vm: self,
policy,
}
}
pub fn set_comment(&mut self, text: impl Into<String>) -> SetComment<'_> {
SetComment {
vm: self,
text: text.into(),
}
}
pub fn grant_support_root(&self, enabled: bool) -> GrantSupportRoot<'_> {
GrantSupportRoot {
vm: self,
enabled,
}
}
pub fn stats(&self) -> Stats<'_> {
Stats {
vm: self,
range: None,
}
}
pub fn domain(&self) -> VmDomain<'_> {
VmDomain {
vm: self,
}
}
pub fn share(&self) -> VmShare<'_> {
VmShare {
vm: self,
}
}
pub fn shelley(&self) -> VmShelley<'_> {
VmShelley {
vm: self,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Delete<'a> {
vm: &'a Vm,
}
impl<'a> IntoFuture for Delete<'a> {
type Output = Result<()>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("rm");
line.arg(self.vm.name());
let line = line.finish()?;
let (_, body, docs) = self.vm.t.documents("rm", &line).await?;
let summary = wire::rm_result(docs)?;
if !summary.failed.is_empty() || summary.deleted.len() != 1 {
let missing = summary.not_found.is_some_and(|n| !n.is_empty());
return Err(ApiError::new("rm", if missing { 404 } else { 422 }, body).into());
}
Ok(())
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Restart<'a> {
vm: &'a mut Vm,
flush: bool,
wait_until: WaitUntil,
timeout: Option<Duration>,
}
impl<'a> Restart<'a> {
pub fn flush(mut self, flush: bool) -> Self {
self.flush = flush;
self
}
pub fn wait_until(mut self, until: WaitUntil) -> Self {
self.wait_until = until;
self
}
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
}
impl<'a> IntoFuture for Restart<'a> {
type Output = Result<types::RestartResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
self.wait_until.timeout(self.timeout)?;
let mut line = Line::new("restart");
line.arg(self.vm.name());
let line = line.finish()?;
if self.flush {
self.vm.flush().await;
}
let result: types::RestartResponse = self.vm.t.call_json("restart", &line).await?;
self.vm.ready(self.wait_until, self.timeout).await?;
Ok(result)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Pause<'a> {
vm: &'a mut Vm,
flush: bool,
}
impl<'a> Pause<'a> {
pub fn flush(mut self, flush: bool) -> Self {
self.flush = flush;
self
}
}
impl<'a> IntoFuture for Pause<'a> {
type Output = Result<types::PauseResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("pause");
line.arg(self.vm.name());
let line = line.finish()?;
if self.flush {
self.vm.flush().await;
}
let value = self.vm.t.call("pause", &line).await?;
self.vm.absorb(&value);
decode("pause", value)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Resume<'a> {
vm: &'a mut Vm,
wait_until: WaitUntil,
timeout: Option<Duration>,
}
impl<'a> Resume<'a> {
pub fn wait_until(mut self, until: WaitUntil) -> Self {
self.wait_until = until;
self
}
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
}
impl<'a> IntoFuture for Resume<'a> {
type Output = Result<types::ResumeResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
self.wait_until.timeout(self.timeout)?;
let mut line = Line::new("resume");
line.arg(self.vm.name());
let line = line.finish()?;
let value = self.vm.t.call("resume", &line).await?;
self.vm.absorb(&value);
let result: types::ResumeResponse = decode("resume", value)?;
self.vm.ready(self.wait_until, self.timeout).await?;
Ok(result)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Rename<'a> {
vm: &'a mut Vm,
new_name: String,
}
impl<'a> IntoFuture for Rename<'a> {
type Output = Result<types::RenameResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let new_name = self.new_name.clone();
let mut line = Line::new("rename");
line.arg(self.vm.name());
line.arg(self.new_name);
let line = line.finish()?;
let value = self.vm.t.call("rename", &line).await?;
let renamed = |key: &str, want: &str| value.get(key).and_then(Value::as_str) == Some(want);
if !renamed("old_name", self.vm.name()) || !renamed("new_name", &new_name) {
return Err(Error::protocol("rename"));
}
self.vm.renamed(&value)?;
decode("rename", value)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Tag<'a> {
vm: &'a mut Vm,
tag_names: Vec<String>,
}
impl<'a> IntoFuture for Tag<'a> {
type Output = Result<types::TagResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("tag");
line.arg(self.vm.name());
line.args("tag name", self.tag_names, true);
let line = line.finish()?;
let value = self.vm.t.call("tag", &line).await?;
self.vm.absorb(&value);
decode("tag", value)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Untag<'a> {
vm: &'a mut Vm,
tag_names: Vec<String>,
}
impl<'a> IntoFuture for Untag<'a> {
type Output = Result<types::TagResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("tag");
line.bool("d", Some(true));
line.arg(self.vm.name());
line.args("tag name", self.tag_names, true);
let line = line.finish()?;
let value = self.vm.t.call("tag", &line).await?;
self.vm.absorb(&value);
decode("tag", value)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct CopyVm<'a> {
vm: &'a Vm,
name: Option<String>,
copy_tags: Option<bool>,
cpu: Option<i64>,
disk: Option<String>,
egress: Option<EgressPolicy>,
memory: Option<String>,
pool: Option<String>,
standalone: Option<bool>,
flush: bool,
wait_until: WaitUntil,
timeout: Option<Duration>,
keep_on_failure: bool,
}
impl<'a> CopyVm<'a> {
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn copy_tags(mut self, copy_tags: bool) -> Self {
self.copy_tags = Some(copy_tags);
self
}
pub fn cpu(mut self, cpu: i64) -> Self {
self.cpu = Some(cpu);
self
}
pub fn disk(mut self, disk: impl std::fmt::Display) -> Self {
self.disk = Some(disk.to_string());
self
}
pub fn egress(mut self, egress: EgressPolicy) -> Self {
self.egress = Some(egress);
self
}
pub fn memory(mut self, memory: impl std::fmt::Display) -> Self {
self.memory = Some(memory.to_string());
self
}
pub fn pool(mut self, pool: impl Into<String>) -> Self {
self.pool = Some(pool.into());
self
}
pub fn standalone(mut self, standalone: bool) -> Self {
self.standalone = Some(standalone);
self
}
pub fn flush(mut self, flush: bool) -> Self {
self.flush = flush;
self
}
pub fn wait_until(mut self, until: WaitUntil) -> Self {
self.wait_until = until;
self
}
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
pub fn keep_on_failure(mut self, keep: bool) -> Self {
self.keep_on_failure = keep;
self
}
}
impl<'a> IntoFuture for CopyVm<'a> {
type Output = Result<Vm>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
self.wait_until.timeout(self.timeout)?;
let mut line = Line::new("cp");
line.bool("copy-tags", self.copy_tags);
line.number("cpu", self.cpu);
line.string("disk", self.disk);
line.string("egress", self.egress.map(|p| p.as_str().to_string()));
line.string("memory", self.memory);
line.string("pool", self.pool);
line.bool("standalone", self.standalone);
line.arg(self.vm.name());
line.opt_arg(self.name);
let line = line.finish()?;
if self.flush {
self.vm.flush().await;
}
let info = self.vm.t.create("cp", line).await?;
Vm::new(self.vm.t.clone(), info)
.created(self.wait_until, self.timeout, self.keep_on_failure)
.await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Resize<'a> {
vm: &'a mut Vm,
cpu: Option<i64>,
disk: Option<String>,
memory: Option<String>,
restart: bool,
}
impl<'a> Resize<'a> {
pub fn cpu(mut self, cpu: i64) -> Self {
self.cpu = Some(cpu);
self
}
pub fn disk(mut self, disk: impl std::fmt::Display) -> Self {
self.disk = Some(disk.to_string());
self
}
pub fn memory(mut self, memory: impl std::fmt::Display) -> Self {
self.memory = Some(memory.to_string());
self
}
pub fn restart(mut self, restart: bool) -> Self {
self.restart = restart;
self
}
}
impl<'a> IntoFuture for Resize<'a> {
type Output = Result<types::ResizeResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("resize");
line.number("cpu", self.cpu);
line.string("disk", self.disk);
line.string("memory", self.memory);
line.arg(self.vm.name());
let line = line.finish()?;
let result: types::ResizeResponse = self.vm.t.call_json("resize", &line).await?;
if self.restart {
self.vm.restart().await?;
}
Ok(result)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SetEgress<'a> {
vm: &'a mut Vm,
policy: EgressPolicy,
}
impl<'a> IntoFuture for SetEgress<'a> {
type Output = Result<types::EgressResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("egress");
line.arg(self.vm.name());
line.arg(self.policy.as_str());
let line = line.finish()?;
let value = self.vm.t.call("egress", &line).await?;
self.vm.absorb(&value);
decode("egress", value)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SetComment<'a> {
vm: &'a mut Vm,
text: String,
}
impl<'a> IntoFuture for SetComment<'a> {
type Output = Result<types::CommentResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("comment");
line.arg(self.vm.name());
line.arg(self.text);
let line = line.finish()?;
let value = self.vm.t.call("comment", &line).await?;
self.vm.absorb(&value);
decode("comment", value)
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct GrantSupportRoot<'a> {
vm: &'a Vm,
enabled: bool,
}
impl<'a> IntoFuture for GrantSupportRoot<'a> {
type Output = Result<Value>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("grant-support-root");
line.arg(self.vm.name());
line.arg(wire::on_off(self.enabled));
let line = line.finish()?;
self.vm.t.call("grant-support-root", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct Stats<'a> {
vm: &'a Vm,
range: Option<String>,
}
impl<'a> Stats<'a> {
pub fn range(mut self, range: impl Into<String>) -> Self {
self.range = Some(range.into());
self
}
}
impl<'a> IntoFuture for Stats<'a> {
type Output = Result<types::StatResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("stat");
line.string("range", self.range);
line.arg(self.vm.name());
let line = line.finish()?;
self.vm.t.call_json("stat", &line).await
})
}
}
pub struct VmDomain<'a> {
vm: &'a Vm,
}
impl<'a> VmDomain<'a> {
pub fn add(&self, domain: impl Into<String>) -> DomainAdd<'a> {
DomainAdd {
vm: self.vm,
domain: domain.into(),
wildcard: None,
}
}
pub fn remove(&self, domain: impl Into<String>) -> DomainRm<'a> {
DomainRm {
vm: self.vm,
domain: domain.into(),
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct DomainAdd<'a> {
vm: &'a Vm,
domain: String,
wildcard: Option<bool>,
}
impl<'a> DomainAdd<'a> {
pub fn wildcard(mut self, wildcard: bool) -> Self {
self.wildcard = Some(wildcard);
self
}
}
impl<'a> IntoFuture for DomainAdd<'a> {
type Output = Result<types::DomainAddResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("domain add");
line.bool("wildcard", self.wildcard);
line.arg(self.vm.name());
line.arg(self.domain);
let line = line.finish()?;
self.vm.t.call_json("domain add", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct DomainRm<'a> {
vm: &'a Vm,
domain: String,
}
impl<'a> IntoFuture for DomainRm<'a> {
type Output = Result<types::DomainRmResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("domain rm");
line.arg(self.vm.name());
line.arg(self.domain);
let line = line.finish()?;
self.vm.t.call_json("domain rm", &line).await
})
}
}
pub struct VmShare<'a> {
vm: &'a Vm,
}
impl<'a> VmShare<'a> {
pub fn show(&self) -> ShareShow<'a> {
ShareShow {
vm: self.vm,
qr: None,
}
}
pub fn port(&self) -> SharePort<'a> {
SharePort {
vm: self.vm,
port: None,
}
}
pub fn set_public(&self) -> ShareSetPublic<'a> {
ShareSetPublic {
vm: self.vm,
}
}
pub fn set_private(&self) -> ShareSetPrivate<'a> {
ShareSetPrivate {
vm: self.vm,
}
}
pub fn add(&self, email: impl Into<String>) -> ShareAdd<'a> {
ShareAdd {
vm: self.vm,
email: email.into(),
message: None,
qr: None,
root: None,
}
}
pub fn remove(&self, email: impl Into<String>) -> ShareRemove<'a> {
ShareRemove {
vm: self.vm,
email: email.into(),
root: None,
}
}
pub fn add_link(&self) -> ShareAddLink<'a> {
ShareAddLink {
vm: self.vm,
qr: None,
}
}
pub fn remove_link(&self, token: impl Into<String>) -> ShareRemoveLink<'a> {
ShareRemoveLink {
vm: self.vm,
token: token.into(),
}
}
pub fn receive_email(&self) -> ShareReceiveEmail<'a> {
ShareReceiveEmail {
vm: self.vm,
enabled: None,
reply_policy: None,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareShow<'a> {
vm: &'a Vm,
qr: Option<bool>,
}
impl<'a> ShareShow<'a> {
pub fn qr(mut self, qr: bool) -> Self {
self.qr = Some(qr);
self
}
}
impl<'a> IntoFuture for ShareShow<'a> {
type Output = Result<types::ShareShowResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share show");
line.bool("qr", self.qr);
line.arg(self.vm.name());
let line = line.finish()?;
self.vm.t.call_json("share show", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct SharePort<'a> {
vm: &'a Vm,
port: Option<String>,
}
impl<'a> SharePort<'a> {
pub fn port(mut self, port: impl std::fmt::Display) -> Self {
self.port = Some(port.to_string());
self
}
}
impl<'a> IntoFuture for SharePort<'a> {
type Output = Result<types::SharePortResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share port");
line.arg(self.vm.name());
line.opt_arg(self.port);
let line = line.finish()?;
self.vm.t.call_json("share port", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareSetPublic<'a> {
vm: &'a Vm,
}
impl<'a> IntoFuture for ShareSetPublic<'a> {
type Output = Result<types::ShareRouteUpdate>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share set-public");
line.arg(self.vm.name());
let line = line.finish()?;
self.vm.t.call_json("share set-public", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareSetPrivate<'a> {
vm: &'a Vm,
}
impl<'a> IntoFuture for ShareSetPrivate<'a> {
type Output = Result<types::ShareRouteUpdate>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share set-private");
line.arg(self.vm.name());
let line = line.finish()?;
self.vm.t.call_json("share set-private", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareAdd<'a> {
vm: &'a Vm,
email: String,
message: Option<String>,
qr: Option<bool>,
root: Option<bool>,
}
impl<'a> ShareAdd<'a> {
pub fn message(mut self, message: impl Into<String>) -> Self {
self.message = Some(message.into());
self
}
pub fn qr(mut self, qr: bool) -> Self {
self.qr = Some(qr);
self
}
pub fn root(mut self, root: bool) -> Self {
self.root = Some(root);
self
}
}
impl<'a> IntoFuture for ShareAdd<'a> {
type Output = Result<types::ShareAddResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share add");
line.string("message", self.message);
line.bool("qr", self.qr);
line.bool("root", self.root);
line.arg(self.vm.name());
line.arg(self.email);
let line = line.finish()?;
self.vm.t.call_json("share add", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareRemove<'a> {
vm: &'a Vm,
email: String,
root: Option<bool>,
}
impl<'a> ShareRemove<'a> {
pub fn root(mut self, root: bool) -> Self {
self.root = Some(root);
self
}
}
impl<'a> IntoFuture for ShareRemove<'a> {
type Output = Result<types::ShareRemoveResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share remove");
line.bool("root", self.root);
line.arg(self.vm.name());
line.arg(self.email);
let line = line.finish()?;
self.vm.t.call_json("share remove", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareAddLink<'a> {
vm: &'a Vm,
qr: Option<bool>,
}
impl<'a> ShareAddLink<'a> {
pub fn qr(mut self, qr: bool) -> Self {
self.qr = Some(qr);
self
}
}
impl<'a> IntoFuture for ShareAddLink<'a> {
type Output = Result<types::ShareLinkCreated>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share add-link");
line.bool("qr", self.qr);
line.arg(self.vm.name());
let line = line.finish()?;
self.vm.t.call_json("share add-link", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareRemoveLink<'a> {
vm: &'a Vm,
token: String,
}
impl<'a> IntoFuture for ShareRemoveLink<'a> {
type Output = Result<types::ShareMessage>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share remove-link");
line.arg(self.vm.name());
line.arg(self.token);
let line = line.finish()?;
self.vm.t.call_json("share remove-link", &line).await
})
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShareReceiveEmail<'a> {
vm: &'a Vm,
enabled: Option<bool>,
reply_policy: Option<String>,
}
impl<'a> ShareReceiveEmail<'a> {
pub fn enabled(mut self, enabled: bool) -> Self {
self.enabled = Some(enabled);
self
}
pub fn reply_policy(mut self, reply_policy: impl Into<String>) -> Self {
self.reply_policy = Some(reply_policy.into());
self
}
}
impl<'a> IntoFuture for ShareReceiveEmail<'a> {
type Output = Result<types::ShareReceiveEmailResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("share receive-email");
line.string("reply-policy", self.reply_policy);
line.arg(self.vm.name());
line.opt_arg(self.enabled.map(wire::on_off));
let line = line.finish()?;
self.vm.t.call_json("share receive-email", &line).await
})
}
}
pub struct VmShelley<'a> {
vm: &'a Vm,
}
impl<'a> VmShelley<'a> {
pub fn install(&self) -> ShelleyInstall<'a> {
ShelleyInstall {
vm: self.vm,
}
}
}
#[must_use = "a request does nothing until it is awaited"]
pub struct ShelleyInstall<'a> {
vm: &'a Vm,
}
impl<'a> IntoFuture for ShelleyInstall<'a> {
type Output = Result<types::ShelleyInstallResponse>;
type IntoFuture = BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let mut line = Line::new("shelley install");
line.arg(self.vm.name());
let line = line.finish()?;
self.vm.t.call_json("shelley install", &line).await
})
}
}