# Hetzner Cloud API - Rhai Wrapper This project provides a Rhai wrapper for interacting with the Hetzner Cloud API, allowing you to manage your servers through simple scripts. ## Setup To use this wrapper, you need to set your Hetzner API Token as an environment variable. You can create your own API Token by following the steps [from the Hetzner docs](https://docs.hetzner.com/cloud/api/getting-started/generating-api-token/). ```bash export HETZNER_API_TOKEN="YOUR_API_TOKEN_HERE" ``` Replace `"YOUR_API_TOKEN_HERE"` with your actual Hetzner API token. ## Usage You can execute any of the example scripts by passing the file path to `cargo run`. ```bash cargo run -- examples/.rhai ``` For example, to run the script that creates a server: ```bash cargo run -- examples/01_create_server.rhai ``` ## Examples The `examples/` directory contains a collection of scripts demonstrating the available functionality. For detailed examples, please see the files in that directory: - [`examples/01_create_server.rhai`](examples/01_create_server.rhai): Shows how to create a new server with various configuration options using a builder pattern. - [`examples/02_list_servers.rhai`](examples/02_list_servers.rhai): Lists all servers in your project. - [`examples/03_get_server_details.rhai`](examples/03_get_server_details.rhai): Fetches and displays detailed information for a single server. - [`examples/04_server_actions.rhai`](examples/04_server_actions.rhai): Demonstrates how to reboot, reset, and manage rescue mode for a server. - [`examples/05_list_ssh_keys.rhai`](examples/05_list_ssh_keys.rhai): Lists all SSH keys in your project. - [`examples/06_list_images.rhai`](examples/06_list_images.rhai): Shows how to list system images and snapshots, with examples of filtering and sorting. - [`examples/07_install_image.rhai`](examples/07_install_image.rhai): Demonstrates server rebuild functionality using install_image (equivalent to traditional installimage). ## Features ### Server Management - **Create servers** with flexible configuration options - **List and inspect** server details and status - **Reboot and reset** servers - **Rebuild servers** with new images (install_image functionality) - **Rescue mode** management ### Image Management - **List images** with advanced filtering (by type, status, architecture, etc.) - **Support for all image types**: system, backup, snapshot, and app images - **Flexible image selection** by name or ID ### SSH Key Management - **List SSH keys** in your project - **Automatic SSH key assignment** during server creation ### Monitoring and Status - **Real-time server status** monitoring - **Rebuild progress tracking** with automatic completion detection - **Comprehensive error handling** and user feedback