hyper-client-rs
Typed Rust client for the hyper.chain.new control-plane API.
Usage
use hyper_client_rs::{
BootstrapAuthRequest, CreateVmRequest, HyperClient, HyperClientAuth, HyperClientConfig,
VmClass, WorkspaceId,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let bootstrap = HyperClient::new(HyperClientConfig {
base_url: "http://127.0.0.1:9090".to_string(),
auth: None,
});
let token = bootstrap
.auth_bootstrap(&BootstrapAuthRequest { subject: None })
.await?
.token;
let client = HyperClient::new(HyperClientConfig {
base_url: "http://127.0.0.1:9090".to_string(),
auth: Some(HyperClientAuth::Bearer(token)),
});
let op = client
.vm_create(
&CreateVmRequest {
workspace_id: WorkspaceId::new(),
vm_class: VmClass::Dev,
vcpus: 2,
memory_mib: 2048,
disk_gib: 20,
network: true,
},
Some("example-idempotency-key"),
)
.await?;
println!("operation: {} ({:?})", op.operation_id, op.status);
Ok(())
}