mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-09-20 06:22:11 +00:00
feat: rename api_endpoint module argument (#395)
##### SUMMARY Make the api endpoint module argument consistent with the api token. - Renamed the `endpoint` module argument to `api_endpoint`, backward compatibility is maintained using an alias. - Allow to configure it using the `HCLOUD_ENDPOINT` env var. This makes the inventory config and the modules config a bit more consistent. ##### ISSUE TYPE - Feature Pull Request
This commit is contained in:
parent
9e0bf59231
commit
7c9fbf85a7
4 changed files with 26 additions and 17 deletions
3
changelogs/fragments/improve-modules-api-arguments.yml
Normal file
3
changelogs/fragments/improve-modules-api-arguments.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- Renamed the `endpoint` module argument to `api_endpoint`, backward compatibility is maintained using an alias.
|
||||||
|
- Allow to set the `api_endpoint` module argument using the `HCLOUD_ENDPOINT` environment variable.
|
|
@ -7,20 +7,24 @@ class ModuleDocFragment:
|
||||||
options:
|
options:
|
||||||
api_token:
|
api_token:
|
||||||
description:
|
description:
|
||||||
- This is the API Token for the Hetzner Cloud.
|
- The API Token for the Hetzner Cloud.
|
||||||
- You can also set this option by using the environment variable HCLOUD_TOKEN
|
- You can also set this option by using the C(HCLOUD_TOKEN) environment variable.
|
||||||
required: True
|
required: True
|
||||||
type: str
|
type: str
|
||||||
endpoint:
|
api_endpoint:
|
||||||
description:
|
description:
|
||||||
- This is the API Endpoint for the Hetzner Cloud.
|
- The API Endpoint for the Hetzner Cloud.
|
||||||
|
- You can also set this option by using the C(HCLOUD_ENDPOINT) environment variable.
|
||||||
default: https://api.hetzner.cloud/v1
|
default: https://api.hetzner.cloud/v1
|
||||||
type: str
|
type: str
|
||||||
|
aliases: [endpoint]
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- python-dateutil >= 2.7.5
|
- python-dateutil >= 2.7.5
|
||||||
- requests >=2.20
|
- requests >=2.20
|
||||||
|
|
||||||
seealso:
|
seealso:
|
||||||
- name: Documentation for Hetzner Cloud API
|
- name: Documentation for Hetzner Cloud API
|
||||||
description: Complete reference for the Hetzner Cloud API.
|
description: Complete reference for the Hetzner Cloud API.
|
||||||
link: https://docs.hetzner.cloud/
|
link: https://docs.hetzner.cloud
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -86,7 +86,7 @@ class AnsibleHCloud:
|
||||||
def _build_client(self) -> None:
|
def _build_client(self) -> None:
|
||||||
self.client = Client(
|
self.client = Client(
|
||||||
token=self.module.params["api_token"],
|
token=self.module.params["api_token"],
|
||||||
api_endpoint=self.module.params["endpoint"],
|
api_endpoint=self.module.params["api_endpoint"],
|
||||||
application_name="ansible-module",
|
application_name="ansible-module",
|
||||||
application_version=version,
|
application_version=version,
|
||||||
)
|
)
|
||||||
|
@ -124,9 +124,11 @@ class AnsibleHCloud:
|
||||||
"fallback": (env_fallback, ["HCLOUD_TOKEN"]),
|
"fallback": (env_fallback, ["HCLOUD_TOKEN"]),
|
||||||
"no_log": True,
|
"no_log": True,
|
||||||
},
|
},
|
||||||
"endpoint": {
|
"api_endpoint": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
"fallback": (env_fallback, ["HCLOUD_ENDPOINT"]),
|
||||||
"default": "https://api.hetzner.cloud/v1",
|
"default": "https://api.hetzner.cloud/v1",
|
||||||
|
"aliases": ["endpoint"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ def test_hcloud_fail_json_hcloud():
|
||||||
module = MagicMock()
|
module = MagicMock()
|
||||||
module.params = {
|
module.params = {
|
||||||
"api_token": "fake_token",
|
"api_token": "fake_token",
|
||||||
"endpoint": "https://api.hetzner.cloud/v1",
|
"api_endpoint": "https://api.hetzner.cloud/v1",
|
||||||
}
|
}
|
||||||
AnsibleHCloud.represent = "hcloud_test"
|
AnsibleHCloud.represent = "hcloud_test"
|
||||||
hcloud = AnsibleHCloud(module)
|
hcloud = AnsibleHCloud(module)
|
||||||
|
|
Loading…
Reference in a new issue