### Power On Server Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.servers.md Starts a server by turning its power on. ```APIDOC ## POST /servers/{server_id}/poweron ### Description Starts a server by turning its power on. ### Method POST ### Endpoint /servers/{server_id}/poweron ### Parameters #### Path Parameters - **server_id** (int) - Required - The ID of the server to power on. ### Response #### Success Response (200) - **action** (object) - An object representing the power on action. ``` -------------------------------- ### Power On Server Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.servers.md Starts a server by turning its power on. ```APIDOC ## POST /servers/{server_id}/power_on ### Description Starts a server by turning its power on. ### Method POST ### Endpoint `/servers/{server_id}/power_on` ### Parameters #### Path Parameters - **server_id** (int) - Required - The ID of the server to power on. #### Request Body This endpoint does not require a request body. ### Response #### Success Response (200) - **action** (BoundAction) - The action object representing the power on operation. ``` -------------------------------- ### Install Hetzner Cloud Python Library Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/index.md Installs the hcloud library using pip. This is the primary method for obtaining the library for use in Python projects. No specific inputs or outputs are detailed beyond successful installation. ```shell pip install hcloud ``` -------------------------------- ### Install Pre-commit Hooks for Development Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/index.md Installs pre-commit hooks to automate code quality checks before commits. This ensures code consistency and adherence to standards. It requires the pre-commit tool to be installed. ```shell pre-commit install ``` -------------------------------- ### Complete Application Deployment Example with Python Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Provides a comprehensive example of deploying a full application stack on Hetzner Cloud using the hcloud-python SDK. This includes creating SSH keys, private networks, database servers with attached volumes, and multiple web servers, along with enabling backups for all resources. ```python from hcloud import Client from hcloud.images import Image from hcloud.server_types import ServerType from hcloud.ssh_keys import SSHKey from hcloud.networks import Network, NetworkSubnet from hcloud.volumes import Volume from datetime import datetime # Initialize client client = Client(token="your-api-token") # Create SSH key with open("/home/user/.ssh/id_rsa.pub") as f: ssh_key = client.ssh_keys.create( name=f"deploy-key-{datetime.now().strftime('%Y%m%d')}", public_key=f.read() ) # Create private network network = client.networks.create( name="app-network", ip_range="10.0.0.0/16" ) network.add_subnet(NetworkSubnet( type="cloud", network_zone="eu-central", ip_range="10.0.1.0/24" )).wait_until_finished() # Create database server db_response = client.servers.create( name="database-01", server_type=ServerType(name="cx32"), image=Image(name="ubuntu-24.04"), ssh_keys=[ssh_key], networks=[network], labels={"role": "database", "env": "production"} ) db_server = db_response.server db_server.attach_to_network(network, ip="10.0.1.10").wait_until_finished() # Create and attach volume for database db_volume = client.volumes.create( size=100, name="postgres-data", server=db_server, format="ext4", automount=True ).volume # Create web servers web_servers = [] for i in range(1, 3): response = client.servers.create( name=f"web-{i:02d}", server_type=ServerType(name="cx22"), image=Image(name="ubuntu-24.04"), ssh_keys=[ssh_key], networks=[network], labels={"role": "web", "env": "production"} ) web_server = response.server web_server.attach_to_network(network, ip=f"10.0.1.{20+i}").wait_until_finished() web_servers.append(web_server) # Enable backups for server in [db_server] + web_servers: server.enable_backup().wait_until_finished() print(f"Backup enabled for {server.name}") ``` -------------------------------- ### Reset Server Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.servers.md Cuts power to a server and then starts it again. ```APIDOC ## POST /servers/{server_id}/reset ### Description Cuts power to a server and starts it again. ### Method POST ### Endpoint `/servers/{server_id}/reset` ### Parameters #### Path Parameters - **server_id** (int) - Required - The ID of the server to reset. #### Request Body This endpoint does not require a request body. ### Response #### Success Response (200) - **action** (BoundAction) - The action object representing the reset operation. ``` -------------------------------- ### Get Server Metrics Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Retrieves time-series metrics for CPU, disk, and network performance within a specified time range. It requires defining start and end datetimes, preferably in UTC. It uses `client.servers.get_by_name()` to retrieve the server object. ```python from hcloud import Client from datetime import datetime, timedelta, timezone client = Client(token="your-api-token") server = client.servers.get_by_name("my-server") if not server: print("Server not found") exit() # Define time range (last hour) end = datetime.now(timezone.utc) start = end - timedelta(hours=1) ``` -------------------------------- ### GET /firewalls Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.firewalls.md Get all firewalls from this account. ```APIDOC ## GET /firewalls ### Description Get all firewalls from this account. ### Method GET ### Endpoint `/firewalls` ### Parameters #### Query Parameters - **label_selector** (string) - Optional - Filter firewalls by labels. - **name** (string) - Optional - Filter firewalls by their name. - **sort** (array[string]) - Optional - Specify how the results are sorted (e.g., `id`, `name`, `created:asc`). ### Response #### Success Response (200) - **firewalls** (array[object]) - A list of BoundFirewall objects. #### Response Example ```json { "firewalls": [ { "id": 1, "name": "my-firewall", "created": "2023-01-01T10:00:00Z", "labels": {"environment": "production"}, "rules": [ { "protocol": "tcp", "port": "80", "source_ips": ["0.0.0.0/0"] } ], "applied_to": [ { "id": 123, "type": "server" } ] } ] } ``` ``` -------------------------------- ### Create and List Hetzner Cloud Servers with Python Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/index.md Demonstrates how to use the hcloud Python library to create a new server instance and then list all existing servers. It requires an API token for authentication and specifies server type and image. Outputs include server ID, name, status, and root password for creation, and details for listed servers. ```python from hcloud import Client from hcloud.images import Image from hcloud.server_types import ServerType client = Client(token="{YOUR_API_TOKEN}") # Please paste your API token here # Create a server named my-server response = client.servers.create( name="my-server", server_type=ServerType(name="cx22"), image=Image(name="ubuntu-22.04"), ) server = response.server print(f"{server.id=} {server.name=} {server.status=}") print(f"root password: {response.root_password}") # List your servers servers = client.servers.get_all() for server in servers: print(f"{server.id=} {server.name=} {server.status=}") ``` -------------------------------- ### Client Initialization Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.md Initialize the Hetzner Cloud API client with your API token and optional parameters. ```APIDOC ## Client Initialization ### Description Initializes the Hetzner Cloud API client. This is the main entry point for interacting with the API. ### Method ```python Client(token: str, api_endpoint: str = 'https://api.hetzner.cloud/v1', application_name: str | None = None, application_version: str | None = None, poll_interval: int | float | BackoffFunction = 1.0, poll_max_retries: int = 120, timeout: float | tuple[float, float] | None = None) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from hcloud import Client client = Client(token='YOUR_API_TOKEN') ``` ### Response None (This is a constructor) ``` -------------------------------- ### Setup Python Virtual Environment for Development Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/index.md Creates and activates a virtual environment for developing the hcloud Python library. This isolates project dependencies. It involves running 'make venv' and then sourcing the activate script. ```shell make venv source venv/bin/activate ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/index.md Builds the project's documentation locally and opens it in a web browser. This is useful for developers to preview documentation changes. It relies on the Makefile to execute the build process. ```shell make docs ``` -------------------------------- ### Reset Server Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.servers.md Resets a server by cutting its power and then starting it again. ```APIDOC ## POST /servers/{server_id}/reset ### Description Cuts power to a server and starts it again. ### Method POST ### Endpoint /servers/{server_id}/reset ### Parameters #### Path Parameters - **server_id** (int) - Required - The ID of the server to reset. ### Response #### Success Response (200) - **action** (object) - An object representing the reset action. ``` -------------------------------- ### POST /servers Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.servers.md Creates a new server with specified configurations. ```APIDOC ## POST /servers ### Description Creates a new server with specified configurations. Returns preliminary information about the server as well as an action that covers progress of creation. ### Method POST ### Endpoint /servers ### Parameters #### Query Parameters None #### Request Body - **name** (str) - Required - Name of the server to create (must be unique per project and a valid hostname as per RFC 1123) - **server_type** (object) - Required - Server type this server should be created with. Can be a `ServerType` object or a `BoundServerType` object. - **image** (object) - Required - Image the server is created from. Can be an `Image` object or a `BoundImage` object. - **ssh_keys** (list[object]) - Optional - SSH keys which should be injected into the server at creation time. Each element can be an `SSHKey` or `BoundSSHKey` object. - **volumes** (list[object]) - Optional - Volumes which should be attached to the server at the creation time. Volumes must be in the same location. Each element can be a `Volume` or `BoundVolume` object. - **firewalls** (list[object]) - Optional - Firewall rules to attach to the server. - **networks** (list[object]) - Optional - Networks which should be attached to the server at the creation time. Each element can be a `Network` or `BoundNetwork` object. - **user_data** (str) - Optional - Cloud-Init user data to use during server creation. This field is limited to 32KiB. - **labels** (dict[str, str]) - Optional - User-defined labels (key-value pairs). - **location** (object) - Optional - Location for the server. Can be a `Location` or `BoundLocation` object. - **datacenter** (object) - Optional - Datacenter for the server. Can be a `Datacenter` or `BoundDatacenter` object. - **start_after_create** (bool) - Optional - Start Server right after creation. Defaults to True. - **automount** (bool) - Optional - Auto mount volumes after attach. - **placement_group** (object) - Optional - Placement Group where server should be added during creation. Can be a `PlacementGroup` or `BoundPlacementGroup` object. - **public_net** (object) - Optional - Options to configure the public network of a server on creation. See `ServerCreatePublicNetwork`. ### Request Example ```json { "name": "my-server", "server_type": {"id": 123, "name": "cx11"}, "image": {"id": 456, "type": "ubuntu", "name": "ubuntu-22.04"}, "ssh_keys": [{"id": 789, "name": "my-ssh-key"}], "location": {"id": 10, "name": "nbg1"}, "start_after_create": true } ``` ### Response #### Success Response (201) - **server** (object) - Preliminary information about the created server. - **action** (object) - Information about the server creation action. #### Response Example ```json { "server": { "id": 9876, "name": "my-server", "status": "creating", "created": "2023-10-27T10:00:00Z", "public_net": {"ipv4": {"ip": "192.0.2.1", "blocked": false}, "ipv6": {"ip": "2001:db8::1", "blocked": false}}, "private_net": [], "image": {"id": 456, "type": "ubuntu", "name": "ubuntu-22.04"}, "server_type": {"id": 123, "name": "cx11"}, "datacenter": {"id": 1, "name": "nbg1-dc3", "location": {"id": 10, "name": "nbg1"}}, "rescue_enabled": false, "user_data": null, "labels": {} }, "action": { "id": 54321, "command": "create_server", "status": "running", "progress": 10, "started": "2023-10-27T10:00:05Z", "finished": null, "resources": {"type": "server", "id": 9876} } } ``` ``` -------------------------------- ### Create Hetzner Cloud Server (Python) Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Creates a new Hetzner Cloud server with specified configuration, including name, server type, and image. Returns server details, root password, and action object for tracking. Supports creating servers with SSH keys, labels, and specific locations, with an option to start the server after creation. ```python from hcloud import Client from hcloud.images import Image from hcloud.server_types import ServerType client = Client(token="your-api-token") # Create a basic server response = client.servers.create( name="my-server", server_type=ServerType(name="cx22"), # 2 vCPU, 4 GB RAM image=Image(name="ubuntu-24.04") ) server = response.server root_password = response.root_password action = response.action print(f"Server created: {server.name} (ID: {server.id})") print(f"Root password: {root_password}") print(f"IPv4 Address: {server.public_net.ipv4.ip}") print(f"Status: {server.status}") # Wait for server to be ready action.wait_until_finished() print("Server is ready!") # Create server with SSH keys and labels from hcloud.ssh_keys import SSHKey response = client.servers.create( name="production-server", server_type=ServerType(name="cx32"), image=Image(name="ubuntu-24.04"), ssh_keys=[SSHKey(name="my-key")], labels={"env": "production", "app": "web"}, location="fsn1", # Falkenstein datacenter start_after_create=True ) server = response.server ``` -------------------------------- ### Get a Single Zone Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.zones.md Retrieves a single Zone by its ID or name. ```APIDOC ## GET /zones/{id_or_name} ### Description Returns a single Zone specified by its ID or name. ### Method GET ### Endpoint `/zones/{id_or_name}` ### Parameters #### Path Parameters - **id_or_name** (int | str) - Required - The ID or Name of the Zone to retrieve. ### Response #### Success Response (200) - **zone** (BoundZone) - The retrieved Zone object. #### Response Example ```json { "zone": { "id": 123, "name": "zone-name", "server_count": 5, "prices": [ { "location": "fsn1", "price_hourly": "0.003", "price_monthly": "0.9" } ], "default_subscription_map": {}, "cname_api": "cname.example.com", "deprecated": false } } ``` ``` -------------------------------- ### GET /networks/{id} Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.networks.md Retrieves details for a specific network by its ID. ```APIDOC ## GET /networks/{id} ### Description Get a specific network. ### Method GET ### Endpoint /networks/{id} ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the network to retrieve. ### Response #### Success Response (200) - **network** (`BoundNetwork`) - The network object. #### Response Example ```json { "network": { "id": 123, "name": "my-network", "ip_range": "10.0.1.0/24", "created": "2023-01-15T10:30:00Z", "labels": { "environment": "production" } } } ``` ``` -------------------------------- ### Create Server with Networks Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Creates a new server instance with specified network configurations attached. Requires server type, image, and network objects as input. ```python from hcloud.servers import ServerCreatePublicNetwork response = client.servers.create( name="web-server", server_type=ServerType(name="cx22"), image=Image(name="ubuntu-24.04"), networks=[network] ) ``` -------------------------------- ### GET /firewalls/{id}/actions Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.firewalls.md Returns all action objects for a Firewall. ```APIDOC ## GET /firewalls/{id}/actions ### Description Returns all action objects for a Firewall. ### Method GET ### Endpoint `/firewalls/{id}/actions` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the firewall. #### Query Parameters - **status** (array[string]) - Optional - Filter actions by status (running, success, error). - **sort** (array[string]) - Optional - Specify how the results are sorted (e.g., `id:asc`, `command:desc`). ### Response #### Success Response (200) - **actions** (array[object]) - A list of BoundAction objects. #### Response Example ```json { "actions": [ { "id": 1, "command": "apply_firewall", "status": "success", "progress": 100, "started": "2023-01-01T10:00:00Z", "finished": "2023-01-01T10:00:05Z", "resources": {"id": 123, "type": "server"}, "related_resources": [{"id": 456, "type": "server"}] } ] } ``` ``` -------------------------------- ### Get Network Actions Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.networks.md Retrieves a list of all actions performed on a specific network. ```APIDOC ## GET /v1/networks/{network_id}/actions ### Description Returns all action objects for a network. ### Method GET ### Endpoint `/v1/networks/{network_id}/actions` ### Parameters #### Path Parameters - **network_id** (int) - Required - The ID of the network to retrieve actions for. #### Query Parameters - **status** (list[str]) - Optional - Response will have only actions with specified statuses. Choices: running, success, error. - **sort** (list[str]) - Optional - Specify how the results are sorted. Choices: id, id:asc, id:desc, command, command:asc, command:desc, status, status:asc, status:desc, progress, progress:asc, progress:desc, started, started:asc, started:desc, finished, finished:asc, finished:desc. ### Request Example (No request body for GET) ### Response #### Success Response (200) - **actions** (array) - An array of action objects. - **id** (int) - ID of the action. - **command** (str) - Command executed. - **status** (str) - Status of the action. - **progress** (int) - Progress of the action in percent. - **started** (str) - Timestamp when the action was started. - **finished** (str) - Timestamp when the action was finished. - **error** (object) - Error details if the action failed. #### Response Example ```json { "actions": [ { "id": 112, "command": "change_network_protection", "status": "success", "progress": 100, "started": "2023-10-27T14:00:00Z", "finished": "2023-10-27T14:00:05Z", "error": null } ] } ``` ``` -------------------------------- ### Initialize Hetzner Cloud API Client (Python) Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Initializes the Hetzner Cloud API client using an API token. Supports basic initialization and advanced configuration including custom endpoints, application names, polling intervals, and timeouts. Also demonstrates initialization using an environment variable. ```python from hcloud import Client # Basic initialization with API token client = Client(token="your-api-token-here") # Advanced initialization with custom configuration client = Client( token="your-api-token-here", api_endpoint="https://api.hetzner.cloud/v1", # default endpoint application_name="MyApp", # custom user agent application_version="1.0.0", poll_interval=1.0, # wait time when polling actions poll_max_retries=120, # max retries for action polling timeout=60.0 # request timeout in seconds ) # Initialize with environment variable from os import environ token = environ.get("HCLOUD_TOKEN") client = Client(token=token) ``` -------------------------------- ### Get Volume by ID Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.volumes.md Retrieves a specific volume using its unique identifier. ```APIDOC ## GET /volumes/{id} ### Description Get a specific volume by its id. ### Method GET ### Endpoint /volumes/{id} ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the volume to retrieve. ### Response #### Success Response (200) - **volume** (BoundVolume) - The requested volume object. #### Response Example { "volume": { "id": 1, "name": "my-volume", "size": 100, "created": "2023-01-01T10:00:00Z", "status": "available", "location": { "id": 1, "name": "fsn1", "description": "Falkenstein", "country": "de", "city": "Falkenstein" }, "server": null, "labels": { "environment": "production" } } } ``` -------------------------------- ### Create Private Network using hcloud-python Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Shows how to create a private network, add subnets, and configure routes using the Hetzner Cloud client. Requires client initialization. Outputs network details and confirmation messages. ```python from hcloud import Client from hcloud.networks import Network, NetworkSubnet client = Client(token="your-api-token") # Create private network network = client.networks.create( name="private-network", ip_range="10.0.0.0/16", labels={"env": "production"} ) print(f"Network created: {network.name} (ID: {network.id})") print(f"IP range: {network.ip_range}") # Add subnet to network action = network.add_subnet( NetworkSubnet( type="cloud", network_zone="eu-central", ip_range="10.0.1.0/24" ) ) action.wait_until_finished() print("Subnet added") # Add route to network from hcloud.networks import NetworkRoute action = network.add_route( NetworkRoute( destination="10.100.0.0/16", gateway="10.0.1.1" ) ) action.wait_until_finished() print("Route added") ``` -------------------------------- ### Get Actions for a Certificate Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.certificates.md Retrieves a list of all actions associated with a specific certificate. ```APIDOC ## GET /certificates/{id}/actions ### Description Returns all action objects for a Certificate. ### Method GET ### Endpoint /certificates/{id}/actions ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the certificate. #### Query Parameters - **status** (list[str]) - Optional - Response will have only actions with specified statuses. Choices: running, success, error. - **sort** (list[str]) - Optional - Specify how the results are sorted. Choices: id, id:asc, id:desc, command, command:asc, command:desc, status, status:asc, status:desc, progress, progress:asc, progress:desc, started, started:asc, started:desc, finished, finished:asc, finished:desc. ### Response #### Success Response (200) - **actions** (list[BoundAction]) - A list of action objects related to the certificate. #### Response Example { "actions": [ { "id": 789, "command": "retry_certificate", "status": "success", "started": "2023-10-27T11:00:00Z", "finished": "2023-10-27T11:05:00Z", "resources": [ { "id": 123, "type": "certificate" } ], "error": null, "_links": { "self": "https://api.hetzner.cloud/v1/actions/789" } } ] } ``` -------------------------------- ### Get Certificate by ID Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.certificates.md Retrieves a specific certificate using its unique ID. ```APIDOC ## GET /certificates/{id} ### Description Gets a specific certificate by its ID. ### Method GET ### Endpoint /certificates/{id} ### Parameters #### Path Parameters - **id** (int) - Required - The unique identifier of the certificate. ### Response #### Success Response (200) - **certificate** (BoundCertificate) - The certificate object. #### Response Example { "certificate": { "id": 123, "name": "example.com", "domain": { "id": 456, "name": "example.com" }, "type": "managed", "status": "active", "created": "2023-10-27T10:00:00Z", "labels": {}, "_links": { "self": "https://api.hetzner.cloud/v1/certificates/123", "actions": "https://api.hetzner.cloud/v1/certificates/123/actions" } } } ``` -------------------------------- ### POST /firewalls Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.firewalls.md Creates a new Firewall. ```APIDOC ## POST /firewalls ### Description Creates a new Firewall. ### Method POST ### Endpoint `/firewalls` ### Parameters #### Request Body - **name** (string) - Required - Firewall Name - **rules** (array[object]) - Optional - Firewall rules. - **labels** (object) - Optional - User-defined labels (key-value pairs) - **resources** (array[object]) - Optional - Resources to attach the firewall to. ### Request Example ```json { "name": "my-firewall", "rules": [ { "protocol": "tcp", "port": "80", "source_ips": ["0.0.0.0/0"] } ], "labels": {"environment": "production"}, "resources": [{"id": 123}] } ``` ### Response #### Success Response (201) - **firewall** (object) - The created Firewall object. - **actions** (array[object]) - A list of actions performed during creation. #### Response Example ```json { "firewall": { "id": 1, "name": "my-firewall", "created": "2023-01-01T10:00:00Z", "labels": {"environment": "production"}, "rules": [ { "protocol": "tcp", "port": "80", "source_ips": ["0.0.0.0/0"] } ], "applied_to": [ { "id": 123, "type": "server" } ] }, "actions": [ { "id": 1, "command": "create_firewall", "status": "success", "progress": 100, "started": "2023-01-01T10:00:00Z", "finished": "2023-01-01T10:00:05Z" } ] } ``` ``` -------------------------------- ### Server Management API Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.md Provides methods for managing Hetzner Cloud servers, including power operations, configuration, and network management. ```APIDOC ## Server Management Endpoints ### Detach Server from Network **Description**: Detaches a server from a specific network. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/detach_from_network` ### Detach ISO Image **Description**: Detaches an ISO image from a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/detach_iso` ### Disable Backup **Description**: Disables the backup feature for a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/disable_backup` ### Disable Rescue Mode **Description**: Disables rescue mode for a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/disable_rescue` ### Enable Backup **Description**: Enables the backup feature for a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/enable_backup` ### Enable Rescue Mode **Description**: Enables rescue mode for a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/enable_rescue` ### Get Server Actions **Description**: Retrieves a list of all actions performed on a server. **Method**: GET **Endpoint**: `/servers/{server_id}/actions` ### Get Server Actions List **Description**: Retrieves a paginated list of actions for a server. **Method**: GET **Endpoint**: `/servers/{server_id}/actions` ### Get Server Metrics **Description**: Retrieves performance metrics for a server. **Method**: GET **Endpoint**: `/servers/{server_id}/metrics` ### Power Off Server **Description**: Powers off a running server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/poweroff` ### Power On Server **Description**: Powers on a stopped server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/poweron` ### Reboot Server **Description**: Reboots a running server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/reboot` ### Rebuild Server **Description**: Rebuilds a server with a new OS image. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/rebuild` ### Remove Server from Placement Group **Description**: Removes a server from its associated placement group. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/remove_from_placement_group` ### Request Server Console **Description**: Requests a console access for a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/console` ### Reset Server **Description**: Resets a server to its initial state. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/reset` ### Reset Server Password **Description**: Resets the root password for a server. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/reset_password` ### Shutdown Server **Description**: Shuts down a running server gracefully. **Method**: POST **Endpoint**: `/servers/{server_id}/actions/shutdown` ### Update Server **Description**: Updates server properties like name or labels. **Method**: PUT **Endpoint**: `/servers/{server_id}` #### Parameters ##### Request Body - **server** (object) - Required - Server data to update - **name** (string) - Optional - New name for the server - **labels** (object) - Optional - New labels for the server ``` -------------------------------- ### GET /certificates/{certificate_id}/actions Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.certificates.md Returns all action objects for a specific certificate. ```APIDOC ## GET /certificates/{certificate_id}/actions ### Description Returns all action objects for a Certificate. ### Method GET ### Endpoint /certificates/{certificate_id}/actions ### Parameters #### Path Parameters - **certificate_id** (int) - Required - The ID of the certificate. #### Query Parameters - **status** (list[str]) - Optional - Response will have only actions with specified statuses. Choices: running, success, error. - **sort** (list[str]) - Optional - Specify how the results are sorted. Choices: id, id:asc, id:desc, command, command:asc, command:desc, status, status:asc, status:desc, progress, progress:asc, progress:desc, started, started:asc, started:desc, finished, finished:asc, finished:desc. ### Response #### Success Response (200) - **actions** (list[object]) - A list of action objects. - **id** (int) - The ID of the action. - **command** (str) - The command executed. - **status** (str) - The status of the action. - **progress** (int) - The progress of the action in percent. - **started** (str) - The start time of the action. - **finished** (str) - The finish time of the action. - **resources** (list[object]) - Resources associated with the action. - **error** (object | None) - Error details if the action failed. #### Response Example ```json { "actions": [ { "id": 9876, "command": "create_certificate", "status": "success", "progress": 100, "started": "2023-10-27T10:10:00Z", "finished": "2023-10-27T10:11:00Z", "resources": [ { "id": 12345, "type": "certificate" } ], "error": null } ] } ``` ``` -------------------------------- ### Object-Oriented vs. Procedural Server Management with Python Source: https://context7.com/fahreddinozcan/hcloud-python-test20/llms.txt Illustrates two distinct styles for managing Hetzner Cloud resources using the hcloud-python client: Object-Oriented (Bound Models) and Procedural (Client Methods). Both styles achieve the same outcomes for server and volume operations, allowing developers to choose based on their preference for API interaction. ```python from hcloud import Client from hcloud.images import Image from hcloud.server_types import ServerType client = Client(token="your-api-token") # ============================================ # Object-Oriented Style (Bound Models) # ============================================ response = client.servers.create( name="server-oop", server_type=ServerType(name="cx22"), image=Image(name="ubuntu-24.04") ) server = response.server # Use methods on the server object server.power_off().wait_until_finished() server.update(labels={"env": "production"}) server.power_on().wait_until_finished() volume = client.volumes.create(size=50, name="data", location=server.location).volume volume.attach(server).wait_until_finished() volume.detach().wait_until_finished() server.delete() # ============================================ # Procedural Style (Client Methods) # ============================================ response = client.servers.create( name="server-proc", server_type=ServerType(name="cx22"), image=Image(name="ubuntu-24.04") ) server = response.server # Use client methods with server as argument client.servers.power_off(server).wait_until_finished() client.servers.update(server, labels={"env": "production"}) client.servers.power_on(server).wait_until_finished() volume = client.volumes.create(size=50, name="data", location=server.location).volume client.volumes.attach(volume, server).wait_until_finished() client.volumes.detach(volume).wait_until_finished() client.servers.delete(server) # Both styles are equivalent - choose based on preference ``` -------------------------------- ### Get Server Type by Name Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.server_types.md Retrieves a server type using its name. ```APIDOC ## GET /server_types?name={name} ### Description Retrieves a server type by its name. Returns `None` if no server type with the specified name is found. ### Method GET ### Endpoint /server_types #### Query Parameters - **name** (str) - Required - The name of the server type to retrieve. ### Response #### Success Response (200) - **server_type** (BoundServerType | None) - The requested server type object, or None if not found. ### Response Example ```json { "server_type": { "id": 1, "name": "cx11", "description": "Standard vCPU", "cores": 2, "memory": 2048, "disk": 20, "storage_type": "local", "cpu_type": "shared", "locations": [ { "name": "hel1", "price": { "monthly": {"currency": "EUR", "net": "5.50", "gross": "6.54"}, "hourly": {"currency": "EUR", "net": "0.0082", "gross": "0.0097"} }, "storage_price": {"currency": "EUR", "net": "3.00", "gross": "3.57"}, "deprecated": null } ], "included_traffic": 10000000000, "architecture": "x86" } } ``` ``` -------------------------------- ### Annotating Experimental Python Features Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/index.md This snippet shows the required docstring format for annotating experimental Python classes and functions. It includes placeholders for product name, maturity level, and a changelog slug, along with a link to the changelog for more details. This ensures users are aware of potential breaking changes. ```python """ Experimental: $PRODUCT is $MATURITY, breaking changes may occur within minor releases. See https://docs.hetzner.cloud/changelog#$SLUG for more details. """ ``` -------------------------------- ### Floating IP Get Actions API Source: https://github.com/fahreddinozcan/hcloud-python-test20/blob/main/docs/api.clients.floating_ips.md Returns all action objects for a Floating IP. ```APIDOC ## GET /floating_ips/{id}/actions ### Description Returns all action objects for a Floating IP. ### Method GET ### Endpoint `/floating_ips/{id}/actions` ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the Floating IP. #### Query Parameters - **status** (list[str]) - Optional - Response will have only actions with specified statuses. Choices: running success error. - **sort** (list[str]) - Optional - Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc. ### Response #### Success Response (200) - **actions** (list[object]) - A list of action objects. - **id** (int) - ID of the Action - **command** (str) - Command of the Action - **status** (str) - Status of the Action. Choices: running success error - **progress** (int) - Progress of the Action in percent - **started** (str) - Timestamp of the Action start - **finished** (str) - Timestamp of the Action end - **error** (object | None) - **code** (str) - Error code qualifier - **message** (str) - Description of the error - **resources** (list[object]) - Resources affected by the Action - **type** (str) - Type of the resource. Choices: server floating_ip image iso volume network private_net backup - **id** (int) - ID of the resource - **root_fs_size** (int | None) - **description** (str | None) #### Response Example ```json { "actions": [ { "id": 54321, "command": "assign_floating_ip", "status": "success", "progress": 100, "started": "2023-10-27T11:00:00Z", "finished": "2023-10-27T11:00:05Z", "error": null, "resources": [ {"type": "floating_ip", "id": 12345}, {"type": "server", "id": 7890} ], "root_fs_size": null, "description": null }, { "id": 54323, "command": "change_protection", "status": "success", "progress": 100, "started": "2023-10-27T11:20:00Z", "finished": "2023-10-27T11:20:03Z", "error": null, "resources": [ {"type": "floating_ip", "id": 12345} ], "root_fs_size": null, "description": "Change protection for Floating IP 12345" } ] } ``` ```