Crate oxide

source ·
Expand description

§The Oxide Rust SDK

Generated bindings for the Oxide API.

§Installation

The oxide crate is available on crates.io. You’ll probably want to use tokio as well. Add them to your Cargo.toml file or use cargo add:

$ cargo add oxide
$ cargo add tokio

§Authentication

To connect to the Oxide API, the SDK needs a host URL and a token. There are two ways to specify these:

  • Environment variables: You can set the OXIDE_HOST and OXIDE_TOKEN environment variables.
  • Configuration file: When you run oxide auth login in the CLI, a $HOME/.config/oxide/hosts.toml file is generated. This file contains sensitive information like your token and user ID.

The SDK will first look for the environment variables, and if they are not defined, it will look for the config file.

§Example

Create a new oxide::Client like this:

use futures::StreamExt;
use oxide::{config::Config, context::Context, prelude::*};

#[tokio::main]
async fn main() {
    // Get a client from the on-disk configuration.
    let context = Context::new(Config::default()).expect("unabled to create context");
    let client: &Client = context.client().expect("unable to get client");

    // Start using the client!

    // For example we can look at the projects in our silo:
    let mut projects = client.project_list().stream();
    loop {
        match projects.next().await {
            // No more items.
            None => break,
            // Print the name of a project.
            Some(Ok(project)) => println!("project {}", *project.name),
            // Something went wrong
            Some(Err(err)) => println!("error {}", err),
        }
    }
}

Modules§

  • Types for composing operation parameters.
  • Items consumers will typically use such as the Client and extension traits.
  • Types used as operation parameters and responses.

Structs§

  • Untyped byte stream used for both success and error responses.
  • Client for Oxide Region API
  • Typed value returned by generated client methods.

Enums§

  • Error produced by generated client methods.
  • Errors for interfaces related to configuration and authentication

Traits§

  • Virtual disks are used to store instance-local data which includes the operating system.
  • Floating IPs allow a project to allocate well-known IPs to instances.
  • TODO operations that will not ship to customers
  • Images are read-only virtual disks that may be used to boot virtual machines.
  • Virtual machine instances are the basic unit of computation. These operations are used for provisioning, controlling, and destroying instances.
  • Authentication endpoints
  • Silo-scoped metrics
  • System-wide IAM policy
  • Projects are a grouping of associated resources such as instances and disks within a silo for purposes of billing and access control.
  • Roles are a component of Identity and Access Management (IAM) that allow a user or agent account access to additional permissions.
  • Information pertaining to the current session.
  • Silos represent a logical partition of users and resources.
  • Snapshots of virtual disks at a particular point in time.
  • These operations pertain to hardware inventory and management. Racks are the unit of expansion of an Oxide deployment. Racks are in turn composed of sleds, switches, power supplies, and a cabled backplane.
  • Metrics provide insight into the operation of the Oxide deployment. These include telemetry on hardware and software components that can be used to understand the current state as well as to diagnose issues.
  • This provides rack-level network configuration.
  • Silos represent a logical partition of users and resources.
  • Endpoints related to system health
  • Virtual Private Clouds (VPCs) provide isolated network environments for managing and deploying services.