#vm #xen #api-client #api-bindings #tokio #client #xcp-ng


Unofficial crate for accessing Xen Orchestra through its API

8 releases

0.1.1 Nov 6, 2021
0.1.0 Nov 4, 2021
0.0.6 Oct 31, 2021
0.0.4 Sep 25, 2021
0.0.2 Jun 24, 2021

#1001 in Asynchronous

31 downloads per month


837 lines


crates.io docs.rs dependency status

Unofficial Rust crate for accessing Xen Orchestra through its API

Under development

The library is still in early development, please do not use in production. The API is nowhere near complete and only covers a very small fraction of XO's api. Lots of things might get changed and/or added in breaking ways at any time.

Async Runtime

This library uses the tokio v1 runtime


Example of listing all VMs with the tag Test

use std::collections::BTreeMap;
use xo_api_client::{credentials::EmailAndPassword, Client, Vm, VmId};

// We dont care about any of the data under the "other" attribute
// in this example
struct OtherInfo {}

impl xo_api_client::api::vm::OtherInfo for OtherInfo {}

async fn main() {
    let url = "ws://localhost:8080/api/";
    let email = String::from("admin@admin.net");
    let password = String::from("admin");

    let con = Client::connect(url)
        .expect("Failed to connect to server");

        .sign_in(EmailAndPassword { email, password })
        .expect("Failed to sign in");

    let all_vms: BTreeMap<VmId, Vm<OtherInfo>> =
        con.get_vms(None, None).await.expect("Failed to list VMs");

    let test_vms = all_vms
        .filter(|(_id, vm)| vm.tags.iter().any(|tag| tag == "Test"));

    println!("All VMs with the tag 'Test':");
    for (id, vm) in test_vms {
        println!("ID: {:?}, Name: {}", id, vm.name_label);


xo-api-client is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, and LICENSE-MIT for details.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in xo-api-client by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~465K SLoC