From 1a007702441746aeeec595c3e75740e142ce111b Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 17 Nov 2025 16:00:44 +0100 Subject: [PATCH] feat: add support for Hetzner API --- plugins/doc_fragments/hcloud.py | 14 ++++++++++---- plugins/module_utils/hcloud.py | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/doc_fragments/hcloud.py b/plugins/doc_fragments/hcloud.py index eee4a9c..70bbd3c 100644 --- a/plugins/doc_fragments/hcloud.py +++ b/plugins/doc_fragments/hcloud.py @@ -10,24 +10,30 @@ class ModuleDocFragment: options: api_token: description: - - The API Token for the Hetzner Cloud. + - The token for the Hetzner Cloud API. - You can also set this option by using the C(HCLOUD_TOKEN) environment variable. required: True type: str api_endpoint: description: - - The API Endpoint for the Hetzner Cloud. + - The endpoint for the Hetzner Cloud API. - You can also set this option by using the C(HCLOUD_ENDPOINT) environment variable. default: https://api.hetzner.cloud/v1 type: str aliases: [endpoint] + api_endpoint_hetzner: + description: + - The endpoint for the Hetzner API. + - You can also set this option by using the C(HETZNER_ENDPOINT) environment variable. + default: https://api.hetzner.com/v1 + type: str requirements: - python-dateutil >= 2.7.5 - requests >=2.20 seealso: - - name: Documentation for Hetzner Cloud API - description: Complete reference for the Hetzner Cloud API. + - name: Documentation for Hetzner APIs + description: Complete reference for the Hetzner APIs. link: https://docs.hetzner.cloud """ diff --git a/plugins/module_utils/hcloud.py b/plugins/module_utils/hcloud.py index 9332cb0..5a9864d 100644 --- a/plugins/module_utils/hcloud.py +++ b/plugins/module_utils/hcloud.py @@ -84,6 +84,7 @@ class AnsibleHCloud: self.client = Client( token=self.module.params["api_token"], api_endpoint=self.module.params["api_endpoint"], + api_endpoint_hetzner=self.module.params["api_endpoint_hetzner"], application_name="ansible-module", application_version=version, # Total waiting time before timeout is > 117.0 @@ -144,6 +145,11 @@ class AnsibleHCloud: "default": "https://api.hetzner.cloud/v1", "aliases": ["endpoint"], }, + "api_endpoint_hetzner": { + "type": "str", + "fallback": (env_fallback, ["HETZNER_ENDPOINT"]), + "default": "https://api.hetzner.com/v1", + }, } def _prepare_result(self) -> dict[str, Any]: