diff --git a/plugins/modules/storage_box.py b/plugins/modules/storage_box.py index a6f4b23..c6490c3 100644 --- a/plugins/modules/storage_box.py +++ b/plugins/modules/storage_box.py @@ -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) diff --git a/plugins/modules/storage_box_info.py b/plugins/modules/storage_box_info.py index 54eae27..ac8dd4a 100644 --- a/plugins/modules/storage_box_info.py +++ b/plugins/modules/storage_box_info.py @@ -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) diff --git a/plugins/modules/storage_box_snapshot.py b/plugins/modules/storage_box_snapshot.py index b381b7c..3c2cfd3 100644 --- a/plugins/modules/storage_box_snapshot.py +++ b/plugins/modules/storage_box_snapshot.py @@ -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) diff --git a/plugins/modules/storage_box_snapshot_info.py b/plugins/modules/storage_box_snapshot_info.py index ebf7737..f12cd29 100644 --- a/plugins/modules/storage_box_snapshot_info.py +++ b/plugins/modules/storage_box_snapshot_info.py @@ -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) diff --git a/plugins/modules/storage_box_subaccount.py b/plugins/modules/storage_box_subaccount.py index f737c44..8a801a8 100644 --- a/plugins/modules/storage_box_subaccount.py +++ b/plugins/modules/storage_box_subaccount.py @@ -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 diff --git a/plugins/modules/storage_box_subaccount_info.py b/plugins/modules/storage_box_subaccount_info.py index 42a2010..b821946 100644 --- a/plugins/modules/storage_box_subaccount_info.py +++ b/plugins/modules/storage_box_subaccount_info.py @@ -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: diff --git a/plugins/modules/storage_box_type_info.py b/plugins/modules/storage_box_type_info.py index f6fe885..1a1e78c 100644 --- a/plugins/modules/storage_box_type_info.py +++ b/plugins/modules/storage_box_type_info.py @@ -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__":