Crates.io | hrobot |
lib.rs | hrobot |
version | 6.1.0 |
source | src |
created_at | 2022-01-15 13:40:57.638278 |
updated_at | 2024-05-10 12:59:00.265475 |
description | Unofficial Hetzner Robot API client |
homepage | |
repository | https://github.com/MathiasPius/hrobot-rs |
max_upload_size | |
id | 514336 |
size | 434,998 |
hrobot
is an unofficial asynchronous Rust client for interacting with the Hetzner Robot API
See the AsyncRobot
struct for a complete list of supported API Endpoints.
Disclaimer: the authors are not associated with Hetzner (except as customers), and the crate is in no way endorsed or supported by Hetzner Online GmbH.
A Hetzner WebService/app user is required to make use of this library.
If you already have a Hetzner account, you can create one through the Hetzner Robot web interface under Settings/Preferences.
Here's a quick example showing how to instantiate the AsyncRobot
client object
and fetching a list of all dedicated servers owned by the account identified by username
use hrobot::*;
#[tokio::main]
async fn main() {
// Robot is instantiated using the environment
// variables HROBOT_USERNAME an HROBOT_PASSWORD.
let robot = AsyncRobot::default();
for server in robot.list_servers().await.unwrap() {
println!("{name}: {product} in {location}",
name = server.name,
product = server.product,
location = server.dc
);
}
}
Running the above example should yield something similar to the output below:
foo: AX51-NVMe in FSN1-DC18
bar: Server Auction in FSN1-DC5
The entire Hetzner Robot API is covered at this point!
Some endpoints have not been tested due to the cost and disruption to running servers, so please consult the section below for a detailed overview of the endpoints.
Warning!
1 not tested, use at your own risk.
2 not officially documented by Hetzner, use at own risk.
Tests are divided into two categories:
Unit tests. s These do not touch the Hetzner API at all and generally test assumptions made in some of the constructs of the library such as serialization/deserialization from known API output. These are always safe to run and do not require Hetzner credentials.
Integration tests. ⚠️
These tests do interact with the Hetzner API, and therefore require the following two environment variables to be set:
HROBOT_USERNAME
HROBOT_PASSWORD
These tests will ⚠️ PURCHASE AN AUCTION SERVER ⚠️ and (ideally) cancel the server once tests have run.
They interact ⚠️ DESTRUCTIVELY ⚠️ with the resources provided through the following environment variables:
HETZNER_INTEGRATION_TEST_STORAGEBOX_ID
specifies a pre-allocated storagebox resource which Storagebox-related tests are run against.