#hetzner #server-api #hetzner-cloud

hcloud

Unofficial Rust crate for accessing the Hetzner Cloud API

18 breaking releases

0.19.0 Feb 1, 2024
0.18.0 Dec 18, 2023
0.17.0 Oct 22, 2023
0.15.0 Jul 23, 2023
0.1.0 Jun 4, 2020

#7 in #server-api

Download history 48/week @ 2023-12-14 218/week @ 2023-12-21 73/week @ 2023-12-28 37/week @ 2024-01-04 3/week @ 2024-01-11 64/week @ 2024-01-18 131/week @ 2024-01-25 101/week @ 2024-02-01 22/week @ 2024-02-08 23/week @ 2024-02-15 57/week @ 2024-02-22 47/week @ 2024-02-29 74/week @ 2024-03-07 73/week @ 2024-03-14 54/week @ 2024-03-21 113/week @ 2024-03-28

316 downloads per month

MIT/Apache

1MB
16K SLoC

hcloud for Rust

Crates.io Documentation Build and test

Unofficial Rust crate for accessing the Hetzner Cloud API

Overview

The hcloud crate can be used for managing the endpoints provided by the Hetzner Cloud API in your Rust project.

The API client code of this crate has been auto-generated from the Unofficial OpenAPI Description for the Hetzner Cloud API using OpenAPI Generator.

Current state of development

  • supported API endpoints (complete as of February 2024): actions, certificates, datacenters, firewalls, floating_ips, images, isos, load_balancer_types, load_balancers, locations, networks, placement_groups, pricing, primary_ips, server_types, servers, ssh_keys, volumes
  • asynchronous API functions
  • pagination support
  • documentation and tests are still WIP

Selecting TLS implementation

The underlying TLS implementation for reqwest can be selected using Cargo features:

  • default-tls (enabled by default): Provides TLS support to connect over HTTPS.
  • native-tls: Enables TLS functionality provided by native-tls.
  • native-tls-vendored: Enables the vendored feature of native-tls.
  • rustls-tls: Enables TLS functionality provided by rustls.

(Refer to Optional Features in the reqwest documentation.)

Example for using the TLS functionality provided by rustls:

[dependencies]
hcloud = { version = "*", default-features = false, features = ["rustls-tls"] }

Example

A very basic example for listing all existing servers:

use hcloud::apis::configuration::Configuration;
use hcloud::apis::servers_api;

// set up basic configuration using API token
let mut configuration = Configuration::new();
configuration.bearer_access_token =
   Some("YOUR_HCLOUD_API_TOKEN".to_string());

// get list of all existing servers from servers API
let servers = servers_api::list_servers(&configuration, Default::default())
   .await?
   .servers;

// handle server data
for server in servers {
   println!("{:?}", server);
}

License

Licensed under either of

at your option.

Contribution

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

Dependencies

~5–20MB
~321K SLoC