hcloud-python Documentation

repository·main·Indexed 18 days ago

https://github.com/hetznercloud/hcloud-python

The official Python library for interacting with the Hetzner Cloud API. It allows developers to programmatically manage cloud resources including servers, images, networks, firewalls, load balancers, floating IPs, and SSL/TLS certificates. The library provides specialized clients such as ActionsClient, CertificatesClient, FirewallsClient, and LoadBalancersClient to handle resource-specific operations and domain models.

Tokens
29.5K
Snippets
112
Records
160
Agent score
60%

What's inside hcloud-python

  1. Understand the difference between Iso and BoundIso

    main

    The library distinguishes between raw data models and client-aware objects:

    1. Iso: A domain object representing the data of an ISO image (e.g., name, size, etc.). It is a pure data container.
    2. BoundIso: A wrapper around an Iso that is 'bound' to an IsosClient. Use BoundIso when you need to perform actions on a specific ISO, such as deleting it, because it contains the necessary client context to make subsequent API calls.
  2. Use Zone and ZoneRecord objects

    main

    The library provides several key data models for DNS management:

    • Zone: Represents a DNS zone.
    • ZoneRecord: Represents an individual DNS record.
    • ZoneRRSet: Represents a Resource Record Set (a group of records for the same name and type).
    • ZoneAuthoritativeNameservers: Represents the nameservers authoritative for a zone.
    • ZonePrimaryNameserver: Represents the primary nameserver of a zone.
    • CreateZoneResponse: The response object returned when creating a new zone.
  3. Understand Server domain objects and responses

    main

    The hcloud.servers module contains several key domain classes used to represent server state and API responses:

    • Server: Represents a Hetzner Cloud server.
    • BoundServer: Represents a server that is associated with specific resources (often used in the context of network bindings).
    • PublicNetwork: Represents a public network configuration.
    • IPv4Address: Represents an IPv4 address assigned to a server.
    • IPv6Network: Represents an IPv6 network configuration.

    Response Objects: When performing actions, the API returns specific response types:

    • CreateServerResponse: Returned after a successful server creation.
    • ResetPasswordResponse: Returned after a password reset operation.
    • EnableRescueResponse: Returned after enabling rescue mode.
    • RequestConsoleResponse: Returned after requesting a console session.
  4. Understand BoundAction and Action objects

    main

    When performing or monitoring actions, the library uses two primary data models:

    1. BoundAction: Represents an action that is currently associated with or 'bound' to a specific resource.
    2. Action: Represents the core definition of an action performed within the Hetzner Cloud environment.

    These objects are returned by the ActionsClient to provide state information about the operation being executed.

  5. Understand ServerType and BoundServerType objects

    main

    When working with the ServerTypesClient, you will encounter two main data models:

    1. ServerType: Represents the definition of a server type (e.g., CPU, RAM, Disk capacity, and name).
    2. BoundServerType: Represents a server type that is specifically associated with a particular context or resource, often used when inspecting the relationship between existing servers and their underlying hardware definitions.
  6. Use PlacementGroup and BoundPlacementGroup objects

    main

    When working with placement groups, the library provides two main domain objects:

    • PlacementGroup: Represents a placement group definition.
    • BoundPlacementGroup: Represents a placement group that has been associated with specific resources (like servers).

    These objects are returned by the PlacementGroupsClient methods during creation or retrieval operations.

  7. Understand experimental features

    main

    Experimental features (e.g., products in public beta) are included in regular releases. Because they are experimental, breaking changes may occur within minor releases.

    Experimental features have different maturity levels (e.g., experimental, alpha, beta) based on the upstream API. You can identify experimental classes or functions by checking their docstrings, which follow this format:

    Experimental:
        $PRODUCT is $MATURITY, breaking changes may occur within minor releases.
        See https://docs.hetzner.cloud/changelog#$SLUG for more details.