mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
fix: more storage boxes docs and code improvements (#758)
##### SUMMARY Cleanup and missed documentation for the storage boxes modules.
This commit is contained in:
parent
d74e5e5ae2
commit
e8c554ae57
7 changed files with 25 additions and 18 deletions
|
|
@ -26,6 +26,7 @@ options:
|
|||
description:
|
||||
- ID of the Storage Box to manage.
|
||||
- Required if no Storage Box O(name) is given.
|
||||
- If the ID is invalid, the module will fail.
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
|
|
@ -614,7 +615,7 @@ def main():
|
|||
result = o.get_result()
|
||||
|
||||
# Legacy return value naming pattern
|
||||
result["hcloud_storage_box"] = result.pop("storage_box")
|
||||
result["hcloud_storage_box"] = result.pop(o.represent)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ def main():
|
|||
result = o.get_result()
|
||||
|
||||
# Legacy return value naming pattern
|
||||
result["hcloud_storage_box_info"] = result.pop("storage_box")
|
||||
result["hcloud_storage_box_info"] = result.pop(o.represent)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ options:
|
|||
description:
|
||||
- ID of the Storage Box Snapshot to manage.
|
||||
- Required when updating or deleting and if no Storage Box Snapshot O(name) is given.
|
||||
- If the ID is invalid, the module will fail.
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
|
|
@ -87,7 +88,7 @@ hcloud_storage_box_snapshot:
|
|||
type: dict
|
||||
contains:
|
||||
storage_box:
|
||||
description: ID of the Storage Box.
|
||||
description: ID of the parent Storage Box.
|
||||
returned: always
|
||||
type: int
|
||||
sample: 497436
|
||||
|
|
@ -273,7 +274,7 @@ def main():
|
|||
result = o.get_result()
|
||||
|
||||
# Legacy return value naming pattern
|
||||
result["hcloud_storage_box_snapshot"] = result.pop("storage_box_snapshot")
|
||||
result["hcloud_storage_box_snapshot"] = result.pop(o.represent)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ DOCUMENTATION = """
|
|||
---
|
||||
module: storage_box_snapshot_info
|
||||
|
||||
short_description: Gather infos about the Hetzner Storage Box Snapshots.
|
||||
short_description: Gather infos about Hetzner Storage Box Snapshots.
|
||||
|
||||
description:
|
||||
- Gather infos about available Hetzner Storage Box Snapshots.
|
||||
- Gather infos about Hetzner Storage Box Snapshots.
|
||||
- See the L(Storage Boxes API documentation,https://docs.hetzner.cloud/reference/hetzner#storage-boxes) for more details.
|
||||
- B(Experimental:) Storage Box support is experimental, breaking changes may occur within minor releases.
|
||||
See https://github.com/ansible-collections/hetzner.hcloud/issues/756 for more details.
|
||||
|
|
@ -31,6 +31,7 @@ options:
|
|||
id:
|
||||
description:
|
||||
- ID of the Storage Box Snapshot to get.
|
||||
- If the ID is invalid, the module will fail.
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
|
|
@ -203,7 +204,7 @@ def main():
|
|||
result = o.get_result()
|
||||
|
||||
# Legacy return value naming pattern
|
||||
result["hcloud_storage_box_snapshot_info"] = result.pop("storage_box_snapshots")
|
||||
result["hcloud_storage_box_snapshot_info"] = result.pop(o.represent)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ options:
|
|||
description:
|
||||
- ID of the Storage Box Subaccount to manage.
|
||||
- Required if no Storage Box Subaccount O(name) is given.
|
||||
- If the ID is invalid, the module will fail.
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
|
|
@ -150,7 +151,7 @@ hcloud_storage_box_subaccount:
|
|||
description: ID of the parent Storage Box.
|
||||
returned: always
|
||||
type: int
|
||||
sample: 514605
|
||||
sample: 497436
|
||||
id:
|
||||
description: ID of the Storage Box Subaccount.
|
||||
returned: always
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ options:
|
|||
id:
|
||||
description:
|
||||
- ID of the Storage Box Subaccount to get.
|
||||
- If the ID is invalid, the module will fail.
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ DOCUMENTATION = """
|
|||
---
|
||||
module: storage_box_type_info
|
||||
|
||||
short_description: Gather infos about the Hetzner Storage Box Types.
|
||||
short_description: Gather infos about Hetzner Storage Box Types.
|
||||
|
||||
description:
|
||||
- Gather infos about available Hetzner Storage Box Types.
|
||||
- See the L(Storage Box Types documentation,https://docs.hetzner.cloud/reference/hetzner#storage-box-types) for more details.
|
||||
- B(Experimental:) Storage Box support is experimental, breaking changes may occur within minor releases.
|
||||
See https://github.com/ansible-collections/hetzner.hcloud/issues/756 for more details.
|
||||
|
||||
|
|
@ -116,9 +117,9 @@ from ..module_utils.vendor.hcloud.storage_box_types import BoundStorageBoxType
|
|||
|
||||
|
||||
class AnsibleStorageBoxTypeInfo(AnsibleHCloud):
|
||||
represent = "storage_box_type"
|
||||
represent = "storage_box_types"
|
||||
|
||||
storage_box_type: list[BoundStorageBoxType] | None = None
|
||||
storage_box_types: list[BoundStorageBoxType] | None = None
|
||||
|
||||
def __init__(self, module: AnsibleModule):
|
||||
storage_box_experimental_warning(module)
|
||||
|
|
@ -127,7 +128,7 @@ class AnsibleStorageBoxTypeInfo(AnsibleHCloud):
|
|||
def _prepare_result(self):
|
||||
result = []
|
||||
|
||||
for o in self.storage_box_type or []:
|
||||
for o in self.storage_box_types or []:
|
||||
if o is None:
|
||||
continue
|
||||
|
||||
|
|
@ -155,11 +156,11 @@ class AnsibleStorageBoxTypeInfo(AnsibleHCloud):
|
|||
def fetch(self):
|
||||
try:
|
||||
if (id_ := self.module.params.get("id")) is not None:
|
||||
self.storage_box_type = [self.client.storage_box_types.get_by_id(id_)]
|
||||
self.storage_box_types = [self.client.storage_box_types.get_by_id(id_)]
|
||||
elif (name := self.module.params.get("name")) is not None:
|
||||
self.storage_box_type = [self.client.storage_box_types.get_by_name(name)]
|
||||
self.storage_box_types = [self.client.storage_box_types.get_by_name(name)]
|
||||
else:
|
||||
self.storage_box_type = self.client.storage_box_types.get_all()
|
||||
self.storage_box_types = self.client.storage_box_types.get_all()
|
||||
|
||||
except HCloudException as exception:
|
||||
self.fail_json_hcloud(exception)
|
||||
|
|
@ -183,9 +184,10 @@ def main():
|
|||
o.fetch()
|
||||
result = o.get_result()
|
||||
|
||||
module.exit_json(
|
||||
hcloud_storage_box_type_info=result["storage_box_type"],
|
||||
)
|
||||
# Legacy return value naming pattern
|
||||
result["hcloud_storage_box_type_info"] = result.pop(o.represent)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue