1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

feat: add support for Hetzner API (#743)

##### SUMMARY

Add support the Hetzner API. Users can override the Hetzner API
endpoint.
This commit is contained in:
Jonas L. 2025-11-18 15:04:19 +01:00 committed by jo
parent 782625decb
commit 03e3e1574f
No known key found for this signature in database
GPG key ID: B2FEC9B22722B984
2 changed files with 16 additions and 4 deletions

View file

@ -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
"""

View file

@ -103,6 +103,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
@ -163,6 +164,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]: