### Install from source Source: https://hcloud-python.readthedocs.io/en/stable/_sources/installation.rst.txt Methods for obtaining the source code and installing it locally. ```console $ git clone git://github.com/hetznercloud/hcloud-python ``` ```console $ curl -OL https://github.com/hetznercloud/hcloud-python/tarball/main ``` ```console $ pip install . ``` -------------------------------- ### Install from local source Source: https://hcloud-python.readthedocs.io/en/stable/installation.html Installs the library from the current directory after cloning or downloading the source. ```bash $ pip install . ``` -------------------------------- ### Install via pip Source: https://hcloud-python.readthedocs.io/en/stable/_sources/installation.rst.txt The preferred method for installing the most recent stable release. ```console $ pip install hcloud ``` -------------------------------- ### power_on Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Starts a server by turning its power on. ```APIDOC ## power_on(server) ### Description Starts a server by turning its power on. ### Parameters - **server** (BoundServer | Server) - Required - The server to power on. ### Returns - **BoundAction** - The action object representing the power on operation. ``` -------------------------------- ### Install hcloud library Source: https://hcloud-python.readthedocs.io/en/stable/index.html Use pip to install the official Hetzner Cloud Python library. ```bash pip install hcloud ``` -------------------------------- ### reset() Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Cuts power to a server and starts it again. ```APIDOC ## reset() ### Description Cuts power to a server and starts it again. ### Returns - **BoundAction** ``` -------------------------------- ### POST /servers/{id}/actions/poweron Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Starts a server by turning its power on. ```APIDOC ## POST /servers/{id}/actions/poweron ### Description Starts a server by turning its power on. ### Method POST ### Endpoint /servers/{id}/actions/poweron ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the server. ``` -------------------------------- ### Install via conda Source: https://hcloud-python.readthedocs.io/en/stable/_sources/installation.rst.txt Installs the library using the conda-forge channel. Note that this package is third-party and may be outdated. ```console $ conda install -c conda-forge hcloud ``` -------------------------------- ### Development environment setup Source: https://hcloud-python.readthedocs.io/en/stable/index.html Commands to initialize a virtual environment and configure pre-commit hooks for development. ```bash make venv source venv/bin/activate ``` ```bash pre-commit install ``` -------------------------------- ### POST /servers/{id}/actions/reset Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Cuts power to a server and starts it again. ```APIDOC ## POST /servers/{id}/actions/reset ### Description Cuts power to a server and starts it again. ### Method POST ### Endpoint /servers/{id}/actions/reset ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the server. ``` -------------------------------- ### Clone from source Source: https://hcloud-python.readthedocs.io/en/stable/installation.html Downloads the source code repository from GitHub for local development or manual installation. ```bash $ git clone git://github.com/hetznercloud/hcloud-python ``` -------------------------------- ### get_metrics(type, start, end, step=None) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Get Metrics for a Server. ```APIDOC ## get_metrics(type, start, end, step=None) ### Description Get Metrics for a Server. ### Parameters - **type** (Literal['cpu', 'disk', 'network'] | list[Literal['cpu', 'disk', 'network']]) - Required - Type of metrics to get. - **start** (datetime | str) - Required - Start of period to get Metrics for (in ISO-8601 format). - **end** (datetime | str) - Required - End of period to get Metrics for (in ISO-8601 format). - **step** (float) - Optional - Resolution of results in seconds. ### Returns - **GetMetricsResponse** ``` -------------------------------- ### Create and list servers Source: https://hcloud-python.readthedocs.io/en/stable/index.html Initialize the client with an API token to create a new server and retrieve a list of existing 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 application_name="my-app", application_version="v1.0.0", ) # Create a server named my-server response = client.servers.create( name="my-server", server_type=ServerType(name="cx23"), 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=}") ``` -------------------------------- ### create(name, server_type, image, ...) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Creates a new server instance with the specified configuration. ```APIDOC ## create(name, server_type, image, ...) ### Description Creates a new server. Returns preliminary information about the server as well as an action that covers progress of creation. ### Parameters - **name** (str) - Required - Name of the server to create (must be unique per project and a valid hostname as per RFC 1123) - **server_type** (BoundServerType or ServerType) - Required - Server type this server should be created with - **image** (BoundImage or Image) - Required - Image the server is created from - **ssh_keys** (List[BoundSSHKey or SSHKey]) - Optional - SSH keys which should be injected into the server at creation time - **volumes** (List[BoundVolume or Volume]) - Optional - Volumes which should be attached to the server at the creation time - **networks** (List[BoundNetwork or Network]) - Optional - Networks which should be attached to the server at the creation time - **user_data** (str) - Optional - Cloud-Init user data to use during server creation - **labels** (Dict[str,str]) - Optional - User-defined labels - **location** (BoundLocation or Location) - Optional - **datacenter** (BoundDatacenter or Datacenter) - Optional - **start_after_create** (boolean) - Optional - Start Server right after creation. Defaults to True. - **automount** (boolean) - Optional - Auto mount volumes after attach. - **placement_group** (BoundPlacementGroup or Location) - Optional - Placement Group where server should be added during creation - **public_net** (ServerCreatePublicNetwork) - Optional - Options to configure the public network of a server on creation ### Returns - **CreateServerResponse** ``` -------------------------------- ### Create a New Server Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Creates a new server instance with specified configuration parameters such as image, server type, and network settings. ```python def create( self, name: str, server_type: ServerType | BoundServerType, image: Image, ssh_keys: list[SSHKey | BoundSSHKey] | None = None, volumes: list[Volume | BoundVolume] | None = None, firewalls: list[Firewall | BoundFirewall] | None = None, networks: list[Network | BoundNetwork] | None = None, user_data: str | None = None, labels: dict[str, str] | None = None, location: Location | BoundLocation | None = None, datacenter: Datacenter | BoundDatacenter | None = None, start_after_create: bool | None = True, automount: bool | None = None, placement_group: PlacementGroup | BoundPlacementGroup | None = None, public_net: ServerCreatePublicNetwork | None = None, ) -> CreateServerResponse: """Creates a new server. Returns preliminary information about the server as well as an action that covers progress of creation. :param name: str Name of the server to create (must be unique per project and a valid hostname as per RFC 1123) :param server_type: :class:`BoundServerType ` or :class:`ServerType ` Server type this server should be created with :param image: :class:`BoundImage ` or :class:`Image ` Image the server is created from :param ssh_keys: List[:class:`BoundSSHKey ` or :class:`SSHKey `] (optional) SSH keys which should be injected into the server at creation time :param volumes: List[:class:`BoundVolume ` or :class:`Volume `] (optional) Volumes which should be attached to the server at the creation time. Volumes must be in the same location. :param networks: List[:class:`BoundNetwork ` or :class:`Network `] (optional) Networks which should be attached to the server at the creation time. :param user_data: str (optional) Cloud-Init user data to use during server creation. This field is limited to 32KiB. :param labels: Dict[str,str] (optional) User-defined labels (key-value pairs) :param location: :class:`BoundLocation ` or :class:`Location ` :param datacenter: :class:`BoundDatacenter ` or :class:`Datacenter ` :param start_after_create: boolean (optional) Start Server right after creation. Defaults to True. :param automount: boolean (optional) Auto mount volumes after attach. :param placement_group: :class:`BoundPlacementGroup ` or :class:`Location ` Placement Group where server should be added during creation :param public_net: :class:`ServerCreatePublicNetwork ` Options to configure the public network of a server on creation :return: :class:`CreateServerResponse ` """ data: dict[str, Any] = { "name": name, "server_type": server_type.id_or_name, "start_after_create": start_after_create, "image": image.id_or_name, } ``` -------------------------------- ### get_metrics Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Get Metrics for a Server. ```APIDOC ## get_metrics(type, start, end, step=None) ### Description Get Metrics for a Server. ### Parameters - **type** (MetricsType | list[MetricsType]) - Required - The type of metrics to retrieve. - **start** (datetime | str) - Required - Start time for the metrics. - **end** (datetime | str) - Required - End time for the metrics. - **step** (float) - Optional - Step size for the metrics. ### Returns - **GetMetricsResponse** - The metrics data for the server. ``` -------------------------------- ### create(...) Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Creates a new server instance with the specified configuration. ```APIDOC ## create(...) ### Description Creates a new server. Returns preliminary information about the server as well as an action that covers progress of creation. ### Parameters - **name** (str) - Required - Name of the server to create. - **server_type** (ServerType/BoundServerType) - Required - Server type for the new server. - **image** (Image/BoundImage) - Required - Image to create the server from. - **ssh_keys** (list) - Optional - SSH keys to inject. - **volumes** (list) - Optional - Volumes to attach. - **networks** (list) - Optional - Networks to attach. - **user_data** (str) - Optional - Cloud-Init user data. - **labels** (dict) - Optional - User-defined labels. - **location** (Location/BoundLocation) - Optional - Server location. - **datacenter** (Datacenter/BoundDatacenter) - Optional - Server datacenter. - **start_after_create** (bool) - Optional - Start server after creation (default: True). - **automount** (bool) - Optional - Auto mount volumes. - **placement_group** (PlacementGroup/BoundPlacementGroup) - Optional - Placement group for the server. - **public_net** (ServerCreatePublicNetwork) - Optional - Public network configuration. ### Returns - **CreateServerResponse** - Object containing server details and creation action. ``` -------------------------------- ### VolumesClient.get_all Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.volumes.html Get all volumes from this account. ```APIDOC ## get_all(label_selector=None, status=None) ### Description Get all volumes from this account. ### Parameters - **label_selector** (str) - Optional - Filter volumes by labels. - **status** (list[str]) - Optional - Filter volumes by status. ### Returns - **list[BoundVolume]** - A list of volumes. ``` -------------------------------- ### Initialize Client and Resource Clients Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/_client.html Configures the base API clients and registers individual resource clients for interacting with Hetzner Cloud services. ```python self._client = ClientBase( token=token, endpoint=api_endpoint, application_name=application_name, application_version=application_version, poll_interval=poll_interval, poll_max_retries=poll_max_retries, timeout=timeout, ) self._client_hetzner = ClientBase( token=token, endpoint=api_endpoint_hetzner, application_name=application_name, application_version=application_version, poll_interval=poll_interval, poll_max_retries=poll_max_retries, timeout=timeout, ) with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) self.datacenters = DatacentersClient(self) self.locations = LocationsClient(self) self.servers = ServersClient(self) self.server_types = ServerTypesClient(self) self.volumes = VolumesClient(self) self.actions = ActionsClient(self) self.images = ImagesClient(self) self.isos = IsosClient(self) self.ssh_keys = SSHKeysClient(self) self.floating_ips = FloatingIPsClient(self) self.primary_ips = PrimaryIPsClient(self) self.networks = NetworksClient(self) self.certificates = CertificatesClient(self) self.load_balancers = LoadBalancersClient(self) self.load_balancer_types = LoadBalancerTypesClient(self) self.firewalls = FirewallsClient(self) self.placement_groups = PlacementGroupsClient(self) self.zones = ZonesClient(self) self.storage_box_types = StorageBoxTypesClient(self) self.storage_boxes = StorageBoxesClient(self) ``` -------------------------------- ### NetworksClient.get_all Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.networks.html Get all networks from this account. ```APIDOC ## get_all(name=None, label_selector=None) ### Description Get all networks from this account. ### Parameters - **name** (str) - Optional - Can be used to filter networks by their name. - **label_selector** (str) - Optional - Can be used to filter networks by labels. ### Response - **list[BoundNetwork]** - A list of all networks. ``` -------------------------------- ### NetworksClient.get_by_name Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.networks.html Get a specific network by its name. ```APIDOC ## get_by_name(name) ### Description Get network by name. ### Parameters - **name** (str) - Required - Used to get network by name. ### Response - **BoundNetwork | None** - The requested network or None if not found. ``` -------------------------------- ### Initialize ClientBase Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/_client.html Initializes the base client with authentication, endpoint configuration, and retry settings. ```python def __init__( self, token: str, *, endpoint: str, 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, ): self._token = token self._endpoint = endpoint self._user_agent = _build_user_agent(application_name, application_version) self._headers = { "User-Agent": self._user_agent, "Authorization": f"Bearer {self._token}", "Accept": "application/json", } if isinstance(poll_interval, (int, float)): poll_interval_func = constant_backoff_function(poll_interval) else: poll_interval_func = poll_interval self._poll_interval_func = poll_interval_func self._poll_max_retries = poll_max_retries self._retry_interval_func = exponential_backoff_function( base=1.0, multiplier=2, cap=60.0, jitter=True ) self._retry_max_retries = 5 self._timeout = timeout self._session = requests.Session() ``` -------------------------------- ### Create Server Image Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Creates a snapshot or backup image of the server. Supports optional labels and custom descriptions. ```python def create_image( self, server: Server | BoundServer, description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None, ) -> CreateImageResponse: """Creates an image (snapshot) from a server by copying the contents of its disks. :param server: :class:`BoundServer ` or :class:`Server ` :param description: str (optional) Description of the image. If you do not set this we auto-generate one for you. :param type: str (optional) Type of image to create (default: snapshot) Choices: snapshot, backup :param labels: Dict[str, str] User-defined labels (key-value pairs) :return: :class:`CreateImageResponse ` """ data: dict[str, Any] = {} if description is not None: data.update({"description": description}) if type is not None: data.update({"type": type}) ``` -------------------------------- ### Get All Actions Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/zones/client.html Retrieves all actions associated with the zone. ```python def get_actions( self, *, status: list[ActionStatus] | None = None, sort: list[ActionSort] | None = None, ) -> list[BoundAction]: """ Returns all Actions for a Zone. See https://docs.hetzner.cloud/reference/cloud#zones-list-zones :param status: Filter the Actions by status. :param sort: Sort Actions by field and direction. """ return self._client.get_actions( self, status=status, sort=sort, ) ``` -------------------------------- ### Get Volume by Name Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/volumes/client.html Retrieves a volume by its name. ```python def get_by_name(self, name: str) -> BoundVolume | None: """Get volume by name :param name: str Used to get volume by name. :return: :class:`BoundVolume ` """ return self._get_first_by(self.get_list, name=name) ``` -------------------------------- ### ServersClient Initialization Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Initializes the ServersClient with the provided client instance. ```python class ServersClient( ResourceClientBaseActionsMixin, ResourceClientBase, ): _base_url = "/servers" actions: ResourceActionsClient """Servers scoped actions client :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): super().__init__(client) self.actions = ResourceActionsClient(client, self._base_url) ``` -------------------------------- ### NetworksClient.get_list Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.networks.html Get a list of networks from this account with pagination support. ```APIDOC ## get_list(name=None, label_selector=None, page=None, per_page=None) ### Description Get a list of networks from this account. ### Parameters - **name** (str) - Optional - Can be used to filter networks by their name. - **label_selector** (str) - Optional - Can be used to filter networks by labels. - **page** (int) - Optional - Specifies the page to fetch. - **per_page** (int) - Optional - Specifies how many results are returned by page. ### Response - **(List[BoundNetwork], Meta)** - A tuple containing the list of networks and metadata. ``` -------------------------------- ### get_all(label_selector=None, name=None) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.floating_ips.html Get all floating ips from this account. ```APIDOC ## get_all(label_selector=None, name=None) ### Description Get all floating ips from this account. ### Parameters - **label_selector** (str | None) - Optional - Filter by labels. - **name** (str | None) - Optional - Filter by name. ### Returns - **list[BoundFloatingIP]** - A list of all Floating IPs. ``` -------------------------------- ### Initialize LoadBalancerTargetIP Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/load_balancers/domain.html Represents an IP address used as a load balancer target. ```python def __init__(self, ip: str | None = None): self.ip = ip ``` -------------------------------- ### Get All Volumes Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/volumes/client.html Retrieves all volumes by iterating through all available pages. ```python def get_all( self, label_selector: str | None = None, status: list[str] | None = None, ) -> list[BoundVolume]: """Get all volumes from this account :param label_selector: Can be used to filter volumes by labels. The response will only contain volumes matching the label selector. :param status: List[str] (optional) Can be used to filter volumes by their status. The response will only contain volumes matching the status. :return: List[:class:`BoundVolume `] """ return self._iter_pages( self.get_list, label_selector=label_selector, status=status, ) ``` -------------------------------- ### Create server image Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Creates a snapshot or backup image of the server disks. ```python return self._client.create_image( self, description=description, type=type, labels=labels ) ``` -------------------------------- ### Get Single Zone Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/zones/client.html Retrieves a single zone by its ID or name. ```python def get(self, id_or_name: int | str) -> BoundZone: """ Returns a single Zone. See https://docs.hetzner.cloud/reference/cloud#zones-get-a-zone :param id_or_name: ID or Name of the Zone. """ response = self._client.request( method="GET", url=f"{self._base_url}/{id_or_name}", ) return BoundZone(self, response["zone"]) ``` -------------------------------- ### get(id_or_name) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.zones.html Retrieves a single DNS Zone by ID or name. ```APIDOC ## get(id_or_name) ### Description Returns a single Zone. ### Parameters - **id_or_name** (int | str) - Required - ID or Name of the Zone. ``` -------------------------------- ### Initialize the Hetzner Cloud Client Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/_client.html Constructor for the main Client class used to interact with the Hetzner Cloud API. ```python def __init__( self, 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, *, api_endpoint_hetzner: str = "https://api.hetzner.com/v1", ): """Create a new Client instance ``` -------------------------------- ### GET /volumes/{id} Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/volumes/client.html Retrieves a specific volume by 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 unique identifier of the volume. ``` -------------------------------- ### Clone the repository Source: https://hcloud-python.readthedocs.io/en/stable/contributing.html Initial step to create a local copy of the project fork. ```bash $ git clone git@github.com:your_name_here/hcloud-python.git ``` -------------------------------- ### create Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/storage_boxes/client.html Creates a new Storage Box with the specified configuration. ```APIDOC ## POST /storage_boxes ### Description Creates a new Storage Box. ### Method POST ### Endpoint /storage_boxes ### Parameters #### Request Body - **name** (str) - Required - Name of the Storage Box. - **password** (str) - Required - Password of the Storage Box. - **location** (BoundLocation | Location) - Required - Location of the Storage Box. - **storage_box_type** (BoundStorageBoxType | StorageBoxType) - Required - Type of the Storage Box. - **ssh_keys** (list[str | SSHKey | BoundSSHKey]) - Optional - SSH public keys. - **access_settings** (StorageBoxAccessSettings) - Optional - Access settings. - **labels** (dict[str, str]) - Optional - User-defined labels. ``` -------------------------------- ### Get Firewall by Name Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/firewalls/client.html Retrieves a specific firewall instance by its name. ```python def get_by_name(self, name: str) -> BoundFirewall | None: """Get Firewall by name :param name: str Used to get Firewall by name. :return: :class:`BoundFirewall ` """ return self._get_first_by(self.get_list, name=name) ``` -------------------------------- ### Initialize LoadBalancerAlgorithm Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/load_balancers/domain.html Represents the load balancing algorithm configuration. ```python def __init__(self, type: str | None = None): self.type = type ``` -------------------------------- ### Get All Firewall Actions Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/firewalls/client.html Retrieves all actions for a firewall by iterating through pages. ```python def get_actions( self, firewall: Firewall | BoundFirewall, status: list[ActionStatus] | None = None, sort: list[ActionSort] | None = None, ) -> list[BoundAction]: """ Returns all Actions for a Firewall. :param firewall: Firewall to get the Actions for. :param status: Filter the Actions by status. :param sort: Sort Actions by field and direction. """ return self._iter_pages( self.get_actions_list, firewall, status=status, sort=sort, ) ``` -------------------------------- ### Get Certificate by Name Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/certificates/client.html Retrieves a single certificate by its unique name. ```python def get_by_name(self, name: str) -> BoundCertificate | None: """Get certificate by name :param name: str Used to get certificate by name. :return: :class:`BoundCertificate ` """ return self._get_first_by(self.get_list, name=name) ``` -------------------------------- ### ActionsClient Initialization Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/actions/client.html Initializes the ActionsClient with a provided client instance. ```python class ActionsClient(ResourceActionsClient): def __init__(self, client: Client): super().__init__(client, None) ``` -------------------------------- ### Get All Certificates Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/certificates/client.html Returns a list of all certificates, utilizing pagination internally. ```python def get_all( self, name: str | None = None, label_selector: str | None = None, ) -> list[BoundCertificate]: """Get all certificates :param name: str (optional) Can be used to filter certificates by their name. :param label_selector: str (optional) Can be used to filter certificates by labels. The response will only contain certificates matching the label selector. :return: List[:class:`BoundCertificate `] """ return self._iter_pages(self.get_list, name=name, label_selector=label_selector) ``` -------------------------------- ### Create a DNS Zone Source: https://hcloud-python.readthedocs.io/en/stable/changelog.html Demonstrates creating a new DNS zone with initial resource records using the DNS API. ```python resp = client.zones.create( name="example.com", mode="primary", labels={"key": "value"}, rrsets=[ ZoneRRSet( name="@", type="A", records=[ ZoneRecord(value="201.180.75.2", comment="server1") ], ) ], ) resp.action.wait_until_finished() zone = resp.zone ``` -------------------------------- ### create Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/load_balancers/client.html Creates a new Load Balancer with the specified configuration. ```APIDOC ## create(name, load_balancer_type, algorithm=None, services=None, targets=None, labels=None, location=None, network_zone=None, public_interface=None, network=None) ### Description Creates a new Load Balancer instance with the provided parameters. ### Parameters - **name** (str) - Required - Name of the Load Balancer - **load_balancer_type** (LoadBalancerType) - Required - Type of the Load Balancer - **algorithm** (LoadBalancerAlgorithm) - Optional - The algorithm the Load Balancer is currently using - **services** (list[LoadBalancerService]) - Optional - The services the Load Balancer is currently serving - **targets** (list[LoadBalancerTarget]) - Optional - The targets the Load Balancer is currently serving - **labels** (dict[str, str]) - Optional - User-defined labels (key-value pairs) - **location** (Location) - Optional - Location of the Load Balancer - **network_zone** (str) - Optional - Network Zone of the Load Balancer - **public_interface** (bool) - Optional - Enable or disable the public interface of the Load Balancer - **network** (Network) - Optional - Adds the Load Balancer to a Network ### Response - **CreateLoadBalancerResponse** - Returns a response object containing the created Load Balancer and the associated action. ``` -------------------------------- ### GET /zones/{id_or_name}/zonefile Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/zones/client.html Exports a zone file in BIND format. ```APIDOC ## GET /zones/{id_or_name}/zonefile ### Description Returns a generated Zone file in BIND (RFC 1034/1035) format. ### Method GET ### Endpoint /zones/{id_or_name}/zonefile ### Parameters #### Path Parameters - **id_or_name** (string) - Required - The ID or name of the zone. ``` -------------------------------- ### GET /zones/{id_or_name} Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/zones/client.html Retrieves a single DNS zone by its ID or name. ```APIDOC ## GET /zones/{id_or_name} ### Description Returns a single Zone object based on the provided ID or name. ### Method GET ### Endpoint /zones/{id_or_name} ### Parameters #### Path Parameters - **id_or_name** (int | str) - Required - ID or Name of the Zone. ``` -------------------------------- ### Enable Server Backups Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Enables automatic daily backups for a server, increasing the server price by 20%. ```python def enable_backup(self, server: Server | BoundServer) -> BoundAction: """Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%. :param server: :class:`BoundServer ` or :class:`Server ` :return: :class:`BoundAction ` """ response = self._client.request( url=f"{self._base_url}/{server.id}/actions/enable_backup", method="POST", ) return BoundAction(self._parent.actions, response["action"]) ``` -------------------------------- ### GET /servers/{id}/metrics Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Retrieves performance metrics for a specific server. ```APIDOC ## GET /servers/{id}/metrics ### Description Get Metrics for a Server. ### Method GET ### Endpoint /servers/{id}/metrics ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the server. #### Query Parameters - **type** (string|list) - Required - Type of metrics to get. - **start** (string) - Required - Start of period to get Metrics for (in ISO-8601 format). - **end** (string) - Required - End of period to get Metrics for (in ISO-8601 format). - **step** (float) - Optional - Resolution of results in seconds. ``` -------------------------------- ### create Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/firewalls/client.html Creates a new firewall with specified rules, labels, and resources. ```APIDOC ## create ### Description Creates a new firewall resource. ### Parameters - **name** (str) - Required - Firewall name. - **rules** (List[FirewallRule]) - Optional - List of firewall rules. - **labels** (dict) - Optional - User-defined labels. - **resources** (List[FirewallResource]) - Optional - Resources to apply the firewall to. ``` -------------------------------- ### GET /servers/{id} Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Retrieves details for a specific server by its unique identifier. ```APIDOC ## GET /servers/{id} ### Description Get a specific server by its ID. ### Method GET ### Endpoint /servers/{id} ### Parameters #### Path Parameters - **id** (int) - Required - The unique identifier of the server. ``` -------------------------------- ### create(name, ip_range, subnets=None, routes=None, expose_routes_to_vswitch=None, labels=None) Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/networks/client.html Creates a new network with the specified IP range and optional subnets, routes, and labels. ```APIDOC ## POST /networks ### Description Creates a network with the specified IP range. ### Parameters - **name** (str) - Required - Name of the network - **ip_range** (str) - Required - IP range of the whole network - **subnets** (list[NetworkSubnet]) - Optional - Array of subnets allocated - **routes** (list[NetworkRoute]) - Optional - Array of routes set in this network - **expose_routes_to_vswitch** (bool) - Optional - Indicates if routes should be exposed to the vSwitch connection - **labels** (dict[str, str]) - Optional - User-defined labels ``` -------------------------------- ### Get Actions List Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/zones/client.html Retrieves a paginated list of actions associated with the zone. ```python def get_actions_list( self, *, status: list[ActionStatus] | None = None, sort: list[ActionSort] | None = None, page: int | None = None, per_page: int | None = None, ) -> ActionsPageResult: """ Returns a paginated list of Actions for a Zone. See https://docs.hetzner.cloud/reference/cloud#zones-list-zones :param status: Filter the Actions by status. :param sort: Sort Actions by field and direction. :param page: Page number to get. :param per_page: Maximum number of Actions returned per page. """ return self._client.get_actions_list( self, status=status, sort=sort, page=page, per_page=per_page, ) ``` -------------------------------- ### create Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/zones/client.html Creates a new DNS zone. ```APIDOC ## POST /zones ### Description Creates a new zone. A default SOA and three NS resource records are created automatically. ### Method POST ### Endpoint /zones ### Parameters #### Request Body - **name** (string) - Required - Name of the Zone. - **mode** (string) - Required - Mode of the Zone. - **ttl** (integer) - Optional - Default TTL. - **labels** (dict) - Optional - User-defined labels. - **primary_nameservers** (list) - Optional - Primary nameservers. - **rrsets** (list) - Optional - RRSets to add. - **zonefile** (string) - Optional - Zone file to import. ``` -------------------------------- ### NetworksClient Initialization Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/networks/client.html Initializes the NetworksClient with a base URL and scoped actions client. ```python class NetworksClient( ResourceClientBaseActionsMixin, ResourceClientBase, ): _base_url = "/networks" actions: ResourceActionsClient """Networks scoped actions client :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): super().__init__(client) self.actions = ResourceActionsClient(client, self._base_url) ``` -------------------------------- ### Get All Actions for a Volume Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/volumes/client.html Retrieves all actions for a volume by iterating through all available pages. ```python def get_actions( self, volume: Volume | BoundVolume, status: list[ActionStatus] | None = None, sort: list[ActionSort] | None = None, ) -> list[BoundAction]: """ Returns all Actions for a Volume. :param volume: Volume to get the Actions for. :param status: Filter the Actions by status. :param sort: Sort Actions by field and direction. """ return self._iter_pages( self.get_actions_list, volume, status=status, sort=sort, ) ``` -------------------------------- ### Get Volume by ID Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/volumes/client.html Retrieves a specific volume using its unique identifier. ```python def get_by_id(self, id: int) -> BoundVolume: """Get a specific volume by its id :param id: int :return: :class:`BoundVolume ` """ response = self._client.request(url=f"{self._base_url}/{id}", method="GET") return BoundVolume(self, response["volume"]) ``` -------------------------------- ### create_image(description=None, type=None, labels=None) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Creates an image (snapshot) from a server by copying the contents of its disks. ```APIDOC ## create_image(description=None, type=None, labels=None) ### Description Creates an image (snapshot) from a server by copying the contents of its disks. ### Parameters - **description** (str) - Optional - Description of the image. If you do not set this we auto-generate one for you. - **type** (str) - Optional - Type of image to create (default: snapshot). Choices: snapshot, backup. - **labels** (dict[str, str]) - Optional - User-defined labels (key-value pairs). ### Returns - **CreateImageResponse** ``` -------------------------------- ### create_image(server, description, type, labels) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Creates an image (snapshot) from a server by copying the contents of its disks. ```APIDOC ## create_image(server, description, type, labels) ### Description Creates an image (snapshot) from a server by copying the contents of its disks. ### Parameters - **server** (BoundServer or Server) - Required - **description** (str) - Optional - Description of the image - **type** (str) - Optional - Type of image to create (snapshot or backup) - **labels** (Dict[str, str]) - Required - User-defined labels ### Returns - **CreateImageResponse** ``` -------------------------------- ### Get Firewall by ID Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/firewalls/client.html Fetches a specific firewall object by its unique identifier. ```python def get_by_id(self, id: int) -> BoundFirewall: """Returns a specific Firewall object. :param id: int :return: :class:`BoundFirewall ` """ response = self._client.request(url=f"{self._base_url}/{id}", method="GET") return BoundFirewall(self, response["firewall"]) ``` -------------------------------- ### Create Image from Server Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/servers/client.html Creates an image from a server, optionally applying labels. ```python if labels is not None: data.update({"labels": labels}) response = self._client.request( url=f"{self._base_url}/{server.id}/actions/create_image", method="POST", json=data, ) return CreateImageResponse( action=BoundAction(self._parent.actions, response["action"]), image=BoundImage(self._parent.images, response["image"]), ) ``` -------------------------------- ### Get Placement Group by name Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/placement_groups/client.html Retrieves a specific placement group by its name. ```python def get_by_name(self, name: str) -> BoundPlacementGroup | None: """Get Placement Group by name :param name: str Used to get Placement Group by name :return: class:`BoundPlacementGroup ` """ return self._get_first_by(self.get_list, name=name) ``` -------------------------------- ### Get All Certificate Actions Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/certificates/client.html Retrieves all actions for a certificate by iterating through all available pages. ```python def get_actions( self, certificate: Certificate | BoundCertificate, status: list[ActionStatus] | None = None, sort: list[ActionSort] | None = None, ) -> list[BoundAction]: """ Returns all Actions for a Certificate. :param certificate: Certificate to get the Actions for. :param status: Filter the Actions by status. :param sort: Sort Actions by field and direction. """ return self._iter_pages( self.get_actions_list, certificate, status=status, sort=sort, ) ``` -------------------------------- ### Initialize FirewallsClient Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/firewalls/client.html Constructor for the FirewallsClient, initializing the scoped actions client. ```python def __init__(self, client: Client): super().__init__(client) self.actions = ResourceActionsClient(client, self._base_url) ``` -------------------------------- ### create(type, description=None, labels=None, home_location=None, server=None, name=None) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.floating_ips.html Creates a new Floating IP assigned to a server. ```APIDOC ## create(type, description=None, labels=None, home_location=None, server=None, name=None) ### Description Creates a new Floating IP assigned to a server. ### Parameters - **type** (str) - Required - Floating IP type (ipv4, ipv6). - **description** (str | None) - Optional - Description of the Floating IP. - **labels** (dict[str, str] | None) - Optional - User-defined labels. - **home_location** (BoundLocation | Location | None) - Optional - Home location. - **server** (BoundServer | Server | None) - Optional - Server to assign the Floating IP to. - **name** (str | None) - Optional - Name of the Floating IP. ### Returns - **CreateFloatingIPResponse** - The response object containing details of the created Floating IP. ``` -------------------------------- ### GET /server_types/{id} Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/server_types/client.html Retrieves a specific server type by its unique identifier. ```APIDOC ## GET /server_types/{id} ### Description Returns a specific Server Type. ### Method GET ### Endpoint /server_types/{id} ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the server type. ``` -------------------------------- ### get_metrics(type, start, end, step=None) Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/load_balancers/client.html Retrieves metrics for a Load Balancer. ```APIDOC ## get_metrics(type, start, end, step) ### Description Get Metrics for a LoadBalancer. ### Parameters - **type** (MetricsType) - Required - Type of metrics to get. - **start** (datetime | str) - Required - Start of period to get Metrics for (in ISO-8601 format). - **end** (datetime | str) - Required - End of period to get Metrics for (in ISO-8601 format). - **step** (float) - Optional - Resolution of results in seconds. ### Returns - **GetMetricsResponse** - The metrics data. ``` -------------------------------- ### get_all(name=None, architecture=None, include_architecture_wildcard=None) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.isos.html Retrieves a list of all ISOs, with optional filtering by name and architecture. ```APIDOC ## get_all(name=None, architecture=None, include_architecture_wildcard=None) ### Description Retrieves a list of all ISOs. Supports filtering by name and architecture, with an optional flag to include custom ISOs when filtering by architecture. ### Parameters - **name** (str) - Optional - Can be used to filter ISOs by their name. - **architecture** (list[str]) - Optional - Can be used to filter ISOs by their architecture (Choices: x86, arm). - **include_architecture_wildcard** (bool) - Optional - Must be set to True if filtering by architecture and including custom ISOs. ### Returns - **list[BoundIso]** - A list of BoundIso objects. ``` -------------------------------- ### Enable Storage Box Snapshot Plan Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/storage_boxes/client.html Enables a snapshot plan for a Storage Box using a provided plan configuration. ```python def enable_snapshot_plan( self, storage_box: StorageBox | BoundStorageBox, snapshot_plan: StorageBoxSnapshotPlan, ) -> BoundAction: """ Enable the snapshot plan of a Storage Box. See https://docs.hetzner.cloud/reference/hetzner#storage-box-actions-enable-snapshot-plan :param storage_box: Storage Box to update. :param snapshot_plan: Snapshot Plan to enable. """ data: dict[str, Any] = snapshot_plan.to_payload() response = self._client.request( method="POST", url=f"{self._base_url}/{storage_box.id}/actions/enable_snapshot_plan", json=data, ) return BoundAction(self._parent.actions, response["action"]) ``` -------------------------------- ### Get Subaccount by Username Source: https://hcloud-python.readthedocs.io/en/stable/_modules/hcloud/storage_boxes/client.html Retrieves a single subaccount from a storage box using its username. ```python def get_subaccount_by_username( self, storage_box: StorageBox | BoundStorageBox, username: str, ) -> BoundStorageBoxSubaccount | None: """ Returns a single Subaccount from a Storage Box. See https://docs.hetzner.cloud/reference/hetzner#storage-box-subaccounts-list-subaccounts :param storage_box: Storage Box to get the Subaccount from. :param username: User name of the Subaccount. """ return self._get_first_by( self.get_subaccount_list, storage_box, username=username, ) ``` -------------------------------- ### enable_rescue(type=None, ssh_keys=None) Source: https://hcloud-python.readthedocs.io/en/stable/api.clients.servers.html Enable the Hetzner Rescue System for this server. ```APIDOC ## enable_rescue(type=None, ssh_keys=None) ### Description Enable the Hetzner Rescue System for this server. ### Parameters - **type** (str) - Optional - Type of rescue system to boot (default: linux64). Choices: linux64, linux32, freebsd64. - **ssh_keys** (list[str]) - Optional - Array of SSH key IDs which should be injected into the rescue system. Only available for types: linux64 and linux32. ### Returns - **EnableRescueResponse** ```