5 releases

0.1.4 Oct 29, 2023
0.1.3 Oct 29, 2023
0.1.2 Oct 25, 2023
0.1.1 Oct 24, 2023
0.1.0 Oct 23, 2023

#1917 in Development tools

Download history 10/week @ 2024-02-25 20/week @ 2024-03-31 83/week @ 2024-04-14

103 downloads per month

MIT license

26KB
661 lines

upcloud


lib.rs:

Client library for the https://www.upcloud.com/ API which is documented at https://developers.upcloud.com/

Example blocking

It needs to have the feature "blocking" enabled.

upcloud_rs = { version = "*", features = ["blocking"] }
use upcloud_rs::{UpcloudApi, UpcloudError};

fn main() -> Result<(), UpcloudError> {
    let api = UpcloudApi::new("username", "password");
    
    let account = api.get_account_info()?;
    println!("ACCOUNT: {:?}", account);
    
    let account_list = api.get_account_list()?;
    println!("ACCOUNT LIST: {:?}", account_list);
    
    let prices = api.get_prices()?;
    println!("PRICES: {:#?}", prices);
    
    let zones = api.get_zones()?;
    println!("ZONES: {:#?}", zones);
    Ok(())
}

Example async

upcloud_rs = { version = "*" }
use upcloud_rs::{UpcloudApi, UpcloudError};

#[async_std::main]
async fn main() -> Result<(), UpcloudError> {
    let api = UpcloudApi::new("username", "password");
    let account = api.get_account_info_async().await?;
    println!("ACCOUNT: {:?}", account);
    
    let account_list = api.get_account_list_async().await?;
    println!("ACCOUNT LIST: {:?}", account_list);
    
    let prices = api.get_prices_async().await?;
    println!("PRICES: {:#?}", prices);
    Ok(())
}

Features

  • "default" - use nativetls
  • "default-rustls" - use rusttls
  • "blocking" - enable blocking api
  • "rustls" - enable rustls for reqwest
  • "nativetls" - add support for nativetls DEFAULT
  • "gzip" - enable gzip in reqwest
  • "brotli" - enable brotli in reqwest
  • "deflate" - enable deflate in reqwest

Dependencies

~4–20MB
~299K SLoC