diff --git a/changelogs/fragments/returned-resource-ids.yml b/changelogs/fragments/returned-resource-ids.yml new file mode 100644 index 0000000..5964a41 --- /dev/null +++ b/changelogs/fragments/returned-resource-ids.yml @@ -0,0 +1,2 @@ +bugfixes: + - All returned resource IDs are now integers instead of strings. diff --git a/plugins/modules/certificate.py b/plugins/modules/certificate.py index 353191c..1127b7c 100644 --- a/plugins/modules/certificate.py +++ b/plugins/modules/certificate.py @@ -159,7 +159,7 @@ class AnsibleHCloudCertificate(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_certificate.id), + "id": self.hcloud_certificate.id, "name": self.hcloud_certificate.name, "type": self.hcloud_certificate.type, "fingerprint": self.hcloud_certificate.fingerprint, diff --git a/plugins/modules/certificate_info.py b/plugins/modules/certificate_info.py index 37b9443..07a7200 100644 --- a/plugins/modules/certificate_info.py +++ b/plugins/modules/certificate_info.py @@ -107,7 +107,7 @@ class AnsibleHCloudCertificateInfo(AnsibleHCloud): tmp.append( { - "id": str(certificate.id), + "id": certificate.id, "name": certificate.name, "fingerprint": certificate.fingerprint, "certificate": certificate.certificate, diff --git a/plugins/modules/datacenter_info.py b/plugins/modules/datacenter_info.py index 85475dd..0437d0b 100644 --- a/plugins/modules/datacenter_info.py +++ b/plugins/modules/datacenter_info.py @@ -138,7 +138,7 @@ class AnsibleHCloudDatacenterInfo(AnsibleHCloud): tmp.append( { - "id": str(datacenter.id), + "id": datacenter.id, "name": datacenter.name, "description": datacenter.description, "location": datacenter.location.name, diff --git a/plugins/modules/firewall.py b/plugins/modules/firewall.py index 30f17eb..4407bed 100644 --- a/plugins/modules/firewall.py +++ b/plugins/modules/firewall.py @@ -236,7 +236,7 @@ class AnsibleHCloudFirewall(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_firewall.id), + "id": self.hcloud_firewall.id, "name": self.hcloud_firewall.name, "rules": [self._prepare_result_rule(rule) for rule in self.hcloud_firewall.rules], "labels": self.hcloud_firewall.labels, @@ -256,14 +256,14 @@ class AnsibleHCloudFirewall(AnsibleHCloud): def _prepare_result_applied_to(self, resource: FirewallResource): result = { "type": resource.type, - "server": str(resource.server.id) if resource.server is not None else None, + "server": resource.server.id if resource.server is not None else None, "label_selector": resource.label_selector.selector if resource.label_selector is not None else None, } if resource.applied_to_resources is not None: result["applied_to_resources"] = [ { "type": item.type, - "server": str(item.server.id) if item.server is not None else None, + "server": item.server.id if item.server is not None else None, } for item in resource.applied_to_resources ] diff --git a/plugins/modules/firewall_info.py b/plugins/modules/firewall_info.py index a07d9ec..ed4e448 100644 --- a/plugins/modules/firewall_info.py +++ b/plugins/modules/firewall_info.py @@ -166,7 +166,7 @@ class AnsibleHCloudFirewallInfo(AnsibleHCloud): tmp.append( { - "id": str(firewall.id), + "id": firewall.id, "name": firewall.name, "labels": firewall.labels, "rules": [self._prepare_result_rule(rule) for rule in firewall.rules], @@ -189,14 +189,14 @@ class AnsibleHCloudFirewallInfo(AnsibleHCloud): def _prepare_result_applied_to(self, resource: FirewallResource): result = { "type": resource.type, - "server": str(resource.server.id) if resource.server is not None else None, + "server": resource.server.id if resource.server is not None else None, "label_selector": resource.label_selector.selector if resource.label_selector is not None else None, } if resource.applied_to_resources is not None: result["applied_to_resources"] = [ { "type": item.type, - "server": str(item.server.id) if item.server is not None else None, + "server": item.server.id if item.server is not None else None, } for item in resource.applied_to_resources ] diff --git a/plugins/modules/floating_ip.py b/plugins/modules/floating_ip.py index 0220361..08a72ac 100644 --- a/plugins/modules/floating_ip.py +++ b/plugins/modules/floating_ip.py @@ -173,7 +173,7 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_floating_ip.id), + "id": self.hcloud_floating_ip.id, "name": self.hcloud_floating_ip.name, "description": self.hcloud_floating_ip.description, "ip": self.hcloud_floating_ip.ip, diff --git a/plugins/modules/floating_ip_info.py b/plugins/modules/floating_ip_info.py index 6595799..f5fff34 100644 --- a/plugins/modules/floating_ip_info.py +++ b/plugins/modules/floating_ip_info.py @@ -120,7 +120,7 @@ class AnsibleHCloudFloatingIPInfo(AnsibleHCloud): tmp.append( { - "id": str(floating_ip.id), + "id": floating_ip.id, "name": floating_ip.name, "description": floating_ip.description, "ip": floating_ip.ip, diff --git a/plugins/modules/image_info.py b/plugins/modules/image_info.py index a3a1331..3252a12 100644 --- a/plugins/modules/image_info.py +++ b/plugins/modules/image_info.py @@ -132,7 +132,7 @@ class AnsibleHCloudImageInfo(AnsibleHCloud): tmp.append( { - "id": str(image.id), + "id": image.id, "status": image.status, "type": image.type, "name": image.name, diff --git a/plugins/modules/iso_info.py b/plugins/modules/iso_info.py index 1ba5193..caa1d13 100644 --- a/plugins/modules/iso_info.py +++ b/plugins/modules/iso_info.py @@ -142,7 +142,7 @@ class AnsibleHCloudIsoInfo(AnsibleHCloud): tmp.append( { - "id": str(iso_info.id), + "id": iso_info.id, "name": iso_info.name, "description": iso_info.description, "type": iso_info.type, diff --git a/plugins/modules/load_balancer.py b/plugins/modules/load_balancer.py index bce337c..d1b5d00 100644 --- a/plugins/modules/load_balancer.py +++ b/plugins/modules/load_balancer.py @@ -163,7 +163,7 @@ class AnsibleHCloudLoadBalancer(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_load_balancer.id), + "id": self.hcloud_load_balancer.id, "name": self.hcloud_load_balancer.name, "ipv4_address": self.hcloud_load_balancer.public_net.ipv4.ip, "ipv6_address": self.hcloud_load_balancer.public_net.ipv6.ip, diff --git a/plugins/modules/load_balancer_info.py b/plugins/modules/load_balancer_info.py index 27a3579..6a96282 100644 --- a/plugins/modules/load_balancer_info.py +++ b/plugins/modules/load_balancer_info.py @@ -296,7 +296,7 @@ class AnsibleHCloudLoadBalancerInfo(AnsibleHCloud): tmp.append( { - "id": str(load_balancer.id), + "id": load_balancer.id, "name": load_balancer.name, "ipv4_address": load_balancer.public_net.ipv4.ip, "ipv6_address": load_balancer.public_net.ipv6.ip, diff --git a/plugins/modules/load_balancer_type_info.py b/plugins/modules/load_balancer_type_info.py index 9050565..f1b6274 100644 --- a/plugins/modules/load_balancer_type_info.py +++ b/plugins/modules/load_balancer_type_info.py @@ -108,7 +108,7 @@ class AnsibleHCloudLoadBalancerTypeInfo(AnsibleHCloud): tmp.append( { - "id": str(load_balancer_type.id), + "id": load_balancer_type.id, "name": load_balancer_type.name, "description": load_balancer_type.description, "max_connections": load_balancer_type.max_connections, diff --git a/plugins/modules/location_info.py b/plugins/modules/location_info.py index 676917b..af02eb8 100644 --- a/plugins/modules/location_info.py +++ b/plugins/modules/location_info.py @@ -98,7 +98,7 @@ class AnsibleHCloudLocationInfo(AnsibleHCloud): tmp.append( { - "id": str(location.id), + "id": location.id, "name": location.name, "description": location.description, "city": location.city, diff --git a/plugins/modules/network.py b/plugins/modules/network.py index 92fe946..7315299 100644 --- a/plugins/modules/network.py +++ b/plugins/modules/network.py @@ -128,7 +128,7 @@ class AnsibleHCloudNetwork(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_network.id), + "id": self.hcloud_network.id, "name": self.hcloud_network.name, "ip_range": self.hcloud_network.ip_range, "expose_routes_to_vswitch": self.hcloud_network.expose_routes_to_vswitch, diff --git a/plugins/modules/network_info.py b/plugins/modules/network_info.py index 00f2d9a..e24f9fc 100644 --- a/plugins/modules/network_info.py +++ b/plugins/modules/network_info.py @@ -221,7 +221,7 @@ class AnsibleHCloudNetworkInfo(AnsibleHCloud): servers = [] for server in network.servers: prepared_server = { - "id": str(server.id), + "id": server.id, "name": server.name, "ipv4_address": server.public_net.ipv4.ip if server.public_net.ipv4 is not None else None, "ipv6": server.public_net.ipv6.ip if server.public_net.ipv6 is not None else None, @@ -238,7 +238,7 @@ class AnsibleHCloudNetworkInfo(AnsibleHCloud): tmp.append( { - "id": str(network.id), + "id": network.id, "name": network.name, "ip_range": network.ip_range, "subnetworks": subnets, diff --git a/plugins/modules/placement_group.py b/plugins/modules/placement_group.py index 45a0cd7..2f42ea2 100644 --- a/plugins/modules/placement_group.py +++ b/plugins/modules/placement_group.py @@ -120,7 +120,7 @@ class AnsibleHCloudPlacementGroup(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_placement_group.id), + "id": self.hcloud_placement_group.id, "name": self.hcloud_placement_group.name, "labels": self.hcloud_placement_group.labels, "type": self.hcloud_placement_group.type, diff --git a/plugins/modules/primary_ip.py b/plugins/modules/primary_ip.py index a257325..432ee95 100644 --- a/plugins/modules/primary_ip.py +++ b/plugins/modules/primary_ip.py @@ -181,7 +181,7 @@ class AnsibleHCloudPrimaryIP(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_primary_ip.id), + "id": self.hcloud_primary_ip.id, "name": self.hcloud_primary_ip.name, "ip": self.hcloud_primary_ip.ip, "type": self.hcloud_primary_ip.type, @@ -189,7 +189,7 @@ class AnsibleHCloudPrimaryIP(AnsibleHCloud): "labels": self.hcloud_primary_ip.labels, "delete_protection": self.hcloud_primary_ip.protection["delete"], "assignee_id": ( - str(self.hcloud_primary_ip.assignee_id) if self.hcloud_primary_ip.assignee_id is not None else None + self.hcloud_primary_ip.assignee_id if self.hcloud_primary_ip.assignee_id is not None else None ), "assignee_type": self.hcloud_primary_ip.assignee_type, "auto_delete": self.hcloud_primary_ip.auto_delete, diff --git a/plugins/modules/primary_ip_info.py b/plugins/modules/primary_ip_info.py index 72e359a..9e75208 100644 --- a/plugins/modules/primary_ip_info.py +++ b/plugins/modules/primary_ip_info.py @@ -145,11 +145,11 @@ class AnsibleHCloudPrimaryIPInfo(AnsibleHCloud): tmp.append( { - "id": str(primary_ip.id), + "id": primary_ip.id, "name": primary_ip.name, "ip": primary_ip.ip, "type": primary_ip.type, - "assignee_id": str(primary_ip.assignee_id) if primary_ip.assignee_id is not None else None, + "assignee_id": primary_ip.assignee_id if primary_ip.assignee_id is not None else None, "assignee_type": primary_ip.assignee_type, "auto_delete": primary_ip.auto_delete, "home_location": primary_ip.datacenter.name, diff --git a/plugins/modules/server.py b/plugins/modules/server.py index ba70274..25e672e 100644 --- a/plugins/modules/server.py +++ b/plugins/modules/server.py @@ -369,7 +369,7 @@ class AnsibleHCloudServer(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_server.id), + "id": self.hcloud_server.id, "name": self.hcloud_server.name, "created": self.hcloud_server.created.isoformat(), "ipv4_address": ( diff --git a/plugins/modules/server_info.py b/plugins/modules/server_info.py index 5584286..39055a6 100644 --- a/plugins/modules/server_info.py +++ b/plugins/modules/server_info.py @@ -166,7 +166,7 @@ class AnsibleHCloudServerInfo(AnsibleHCloud): tmp.append( { - "id": str(server.id), + "id": server.id, "name": server.name, "created": server.created.isoformat(), "ipv4_address": server.public_net.ipv4.ip if server.public_net.ipv4 is not None else None, diff --git a/plugins/modules/server_type_info.py b/plugins/modules/server_type_info.py index f03d670..7e5873f 100644 --- a/plugins/modules/server_type_info.py +++ b/plugins/modules/server_type_info.py @@ -148,7 +148,7 @@ class AnsibleHCloudServerTypeInfo(AnsibleHCloud): tmp.append( { - "id": str(server_type.id), + "id": server_type.id, "name": server_type.name, "description": server_type.description, "cores": server_type.cores, diff --git a/plugins/modules/ssh_key.py b/plugins/modules/ssh_key.py index af3fb55..86a3416 100644 --- a/plugins/modules/ssh_key.py +++ b/plugins/modules/ssh_key.py @@ -132,7 +132,7 @@ class AnsibleHCloudSSHKey(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_ssh_key.id), + "id": self.hcloud_ssh_key.id, "name": self.hcloud_ssh_key.name, "fingerprint": self.hcloud_ssh_key.fingerprint, "public_key": self.hcloud_ssh_key.public_key, diff --git a/plugins/modules/ssh_key_info.py b/plugins/modules/ssh_key_info.py index b6b22ff..c1b2bbf 100644 --- a/plugins/modules/ssh_key_info.py +++ b/plugins/modules/ssh_key_info.py @@ -99,7 +99,7 @@ class AnsibleHCloudSSHKeyInfo(AnsibleHCloud): tmp.append( { - "id": str(ssh_key.id), + "id": ssh_key.id, "name": ssh_key.name, "fingerprint": ssh_key.fingerprint, "public_key": ssh_key.public_key, diff --git a/plugins/modules/volume.py b/plugins/modules/volume.py index 118dc4c..99c39b4 100644 --- a/plugins/modules/volume.py +++ b/plugins/modules/volume.py @@ -173,7 +173,7 @@ class AnsibleHCloudVolume(AnsibleHCloud): def _prepare_result(self): return { - "id": str(self.hcloud_volume.id), + "id": self.hcloud_volume.id, "name": self.hcloud_volume.name, "size": self.hcloud_volume.size, "location": self.hcloud_volume.location.name, diff --git a/plugins/modules/volume_info.py b/plugins/modules/volume_info.py index b30956d..fc45ba0 100644 --- a/plugins/modules/volume_info.py +++ b/plugins/modules/volume_info.py @@ -115,7 +115,7 @@ class AnsibleHCloudVolumeInfo(AnsibleHCloud): tmp.append( { - "id": str(volume.id), + "id": volume.id, "name": volume.name, "size": volume.size, "location": volume.location.name, diff --git a/tests/integration/targets/iso_info/tasks/test.yml b/tests/integration/targets/iso_info/tasks/test.yml index 5a4a42d..997e25f 100644 --- a/tests/integration/targets/iso_info/tasks/test.yml +++ b/tests/integration/targets/iso_info/tasks/test.yml @@ -26,7 +26,7 @@ ansible.builtin.assert: that: - result.hcloud_iso_info | list | count == 1 - - result.hcloud_iso_info[0].id == hcloud_iso_id | string + - result.hcloud_iso_info[0].id == hcloud_iso_id - result.hcloud_iso_info[0].name == hcloud_iso_name - result.hcloud_iso_info[0].architecture == hcloud_iso_architecture - result.hcloud_iso_info[0].type == hcloud_iso_type diff --git a/tests/integration/targets/primary_ip/tasks/test.yml b/tests/integration/targets/primary_ip/tasks/test.yml index 54c19dc..6828453 100644 --- a/tests/integration/targets/primary_ip/tasks/test.yml +++ b/tests/integration/targets/primary_ip/tasks/test.yml @@ -155,7 +155,7 @@ - result is changed - result.hcloud_primary_ip.name == hcloud_primary_ip_name - result.hcloud_primary_ip.type == "ipv6" - - result.hcloud_primary_ip.assignee_id == test_server.hcloud_server.id | string + - result.hcloud_primary_ip.assignee_id == test_server.hcloud_server.id - result.hcloud_primary_ip.assignee_type == "server" - name: Test create with server idempotency