diff --git a/hcloud/actions/client.py b/hcloud/actions/client.py index a3d6b033..7ec192c8 100644 --- a/hcloud/actions/client.py +++ b/hcloud/actions/client.py @@ -47,7 +47,7 @@ def wait_until_finished(self, max_retries: int | None = None) -> None: class ActionsPageResult(NamedTuple): actions: list[BoundAction] - meta: Meta | None + meta: Meta class ResourceActionsClient(ClientEntityBase): diff --git a/hcloud/certificates/client.py b/hcloud/certificates/client.py index a5fe1d77..cb1aef58 100644 --- a/hcloud/certificates/client.py +++ b/hcloud/certificates/client.py @@ -100,7 +100,7 @@ def retry_issuance(self) -> BoundAction: class CertificatesPageResult(NamedTuple): certificates: list[BoundCertificate] - meta: Meta | None + meta: Meta class CertificatesClient(ClientEntityBase): diff --git a/hcloud/core/domain.py b/hcloud/core/domain.py index fa4b4bb9..f3050301 100644 --- a/hcloud/core/domain.py +++ b/hcloud/core/domain.py @@ -99,13 +99,12 @@ def __init__(self, pagination: Pagination | None = None): self.pagination = pagination @classmethod - def parse_meta(cls, response: dict) -> Meta | None: + def parse_meta(cls, response: dict) -> Meta: """ If present, extract the meta details from the response and return a meta object. """ - meta = None + meta = cls() if response and "meta" in response: - meta = cls() try: meta.pagination = Pagination(**response["meta"]["pagination"]) except KeyError: diff --git a/hcloud/datacenters/client.py b/hcloud/datacenters/client.py index 1be1e126..935a7c77 100644 --- a/hcloud/datacenters/client.py +++ b/hcloud/datacenters/client.py @@ -52,7 +52,7 @@ def __init__(self, client: DatacentersClient, data: dict): class DatacentersPageResult(NamedTuple): datacenters: list[BoundDatacenter] - meta: Meta | None + meta: Meta class DatacentersClient(ClientEntityBase): diff --git a/hcloud/firewalls/client.py b/hcloud/firewalls/client.py index fbcd1008..ae365a4b 100644 --- a/hcloud/firewalls/client.py +++ b/hcloud/firewalls/client.py @@ -180,7 +180,7 @@ def remove_from_resources( class FirewallsPageResult(NamedTuple): firewalls: list[BoundFirewall] - meta: Meta | None + meta: Meta class FirewallsClient(ClientEntityBase): diff --git a/hcloud/floating_ips/client.py b/hcloud/floating_ips/client.py index a7669147..9306ac2f 100644 --- a/hcloud/floating_ips/client.py +++ b/hcloud/floating_ips/client.py @@ -136,7 +136,7 @@ def change_dns_ptr(self, ip: str, dns_ptr: str) -> BoundAction: class FloatingIPsPageResult(NamedTuple): floating_ips: list[BoundFloatingIP] - meta: Meta | None + meta: Meta class FloatingIPsClient(ClientEntityBase): diff --git a/hcloud/images/client.py b/hcloud/images/client.py index a7d41e01..36c59e06 100644 --- a/hcloud/images/client.py +++ b/hcloud/images/client.py @@ -109,7 +109,7 @@ def change_protection(self, delete: bool | None = None) -> BoundAction: class ImagesPageResult(NamedTuple): images: list[BoundImage] - meta: Meta | None + meta: Meta class ImagesClient(ClientEntityBase): diff --git a/hcloud/isos/client.py b/hcloud/isos/client.py index fa7b1a8b..31620d8f 100644 --- a/hcloud/isos/client.py +++ b/hcloud/isos/client.py @@ -17,7 +17,7 @@ class BoundIso(BoundModelBase, Iso): class IsosPageResult(NamedTuple): isos: list[BoundIso] - meta: Meta | None + meta: Meta class IsosClient(ClientEntityBase): diff --git a/hcloud/load_balancer_types/client.py b/hcloud/load_balancer_types/client.py index 9a83dc70..5f332c6e 100644 --- a/hcloud/load_balancer_types/client.py +++ b/hcloud/load_balancer_types/client.py @@ -17,7 +17,7 @@ class BoundLoadBalancerType(BoundModelBase, LoadBalancerType): class LoadBalancerTypesPageResult(NamedTuple): load_balancer_types: list[BoundLoadBalancerType] - meta: Meta | None + meta: Meta class LoadBalancerTypesClient(ClientEntityBase): diff --git a/hcloud/load_balancers/client.py b/hcloud/load_balancers/client.py index e0635eec..aeeeb879 100644 --- a/hcloud/load_balancers/client.py +++ b/hcloud/load_balancers/client.py @@ -366,7 +366,7 @@ def change_type( class LoadBalancersPageResult(NamedTuple): load_balancers: list[BoundLoadBalancer] - meta: Meta | None + meta: Meta class LoadBalancersClient(ClientEntityBase): diff --git a/hcloud/locations/client.py b/hcloud/locations/client.py index 047ad9d4..411a184d 100644 --- a/hcloud/locations/client.py +++ b/hcloud/locations/client.py @@ -17,7 +17,7 @@ class BoundLocation(BoundModelBase, Location): class LocationsPageResult(NamedTuple): locations: list[BoundLocation] - meta: Meta | None + meta: Meta class LocationsClient(ClientEntityBase): diff --git a/hcloud/networks/client.py b/hcloud/networks/client.py index d819d580..c446ae6b 100644 --- a/hcloud/networks/client.py +++ b/hcloud/networks/client.py @@ -163,7 +163,7 @@ def change_protection(self, delete: bool | None = None) -> BoundAction: class NetworksPageResult(NamedTuple): networks: list[BoundNetwork] - meta: Meta | None + meta: Meta class NetworksClient(ClientEntityBase): diff --git a/hcloud/placement_groups/client.py b/hcloud/placement_groups/client.py index fcfd86ae..0c53724f 100644 --- a/hcloud/placement_groups/client.py +++ b/hcloud/placement_groups/client.py @@ -40,7 +40,7 @@ def delete(self) -> bool: class PlacementGroupsPageResult(NamedTuple): placement_groups: list[BoundPlacementGroup] - meta: Meta | None + meta: Meta class PlacementGroupsClient(ClientEntityBase): diff --git a/hcloud/primary_ips/client.py b/hcloud/primary_ips/client.py index 41ef3bfb..818737c5 100644 --- a/hcloud/primary_ips/client.py +++ b/hcloud/primary_ips/client.py @@ -94,7 +94,7 @@ def change_dns_ptr(self, ip: str, dns_ptr: str) -> BoundAction: class PrimaryIPsPageResult(NamedTuple): primary_ips: list[BoundPrimaryIP] - meta: Meta | None + meta: Meta class PrimaryIPsClient(ClientEntityBase): diff --git a/hcloud/server_types/client.py b/hcloud/server_types/client.py index 31f56a20..6901d995 100644 --- a/hcloud/server_types/client.py +++ b/hcloud/server_types/client.py @@ -17,7 +17,7 @@ class BoundServerType(BoundModelBase, ServerType): class ServerTypesPageResult(NamedTuple): server_types: list[BoundServerType] - meta: Meta | None + meta: Meta class ServerTypesClient(ClientEntityBase): diff --git a/hcloud/servers/client.py b/hcloud/servers/client.py index ca741ebf..d72bf803 100644 --- a/hcloud/servers/client.py +++ b/hcloud/servers/client.py @@ -479,7 +479,7 @@ def remove_from_placement_group(self) -> BoundAction: class ServersPageResult(NamedTuple): servers: list[BoundServer] - meta: Meta | None + meta: Meta class ServersClient(ClientEntityBase): diff --git a/hcloud/ssh_keys/client.py b/hcloud/ssh_keys/client.py index 69c1683d..12064ea9 100644 --- a/hcloud/ssh_keys/client.py +++ b/hcloud/ssh_keys/client.py @@ -38,7 +38,7 @@ def delete(self) -> bool: class SSHKeysPageResult(NamedTuple): ssh_keys: list[BoundSSHKey] - meta: Meta | None + meta: Meta class SSHKeysClient(ClientEntityBase): diff --git a/hcloud/volumes/client.py b/hcloud/volumes/client.py index a4709748..371a8bd1 100644 --- a/hcloud/volumes/client.py +++ b/hcloud/volumes/client.py @@ -132,7 +132,7 @@ def change_protection(self, delete: bool | None = None) -> BoundAction: class VolumesPageResult(NamedTuple): volumes: list[BoundVolume] - meta: Meta | None + meta: Meta class VolumesClient(ClientEntityBase): diff --git a/tests/unit/actions/test_client.py b/tests/unit/actions/test_client.py index a8091b72..f9943087 100644 --- a/tests/unit/actions/test_client.py +++ b/tests/unit/actions/test_client.py @@ -89,7 +89,7 @@ def test_get_list(self, actions_client, generic_action_list, params): url="/resource/actions", method="GET", params=params ) - assert result.meta is None + assert result.meta is not None actions = result.actions assert len(actions) == 2 @@ -157,7 +157,7 @@ def test_get_list(self, actions_client, generic_action_list, params): url="/actions", method="GET", params=params ) - assert result.meta is None + assert result.meta is not None actions = result.actions assert len(actions) == 2 diff --git a/tests/unit/certificates/test_client.py b/tests/unit/certificates/test_client.py index 0857d0c9..a4e5ad2e 100644 --- a/tests/unit/certificates/test_client.py +++ b/tests/unit/certificates/test_client.py @@ -29,7 +29,7 @@ def test_get_actions_list( ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -315,7 +315,7 @@ def test_actions_get_list(self, certificates_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/core/test_domain.py b/tests/unit/core/test_domain.py index c449df4e..484799f6 100644 --- a/tests/unit/core/test_domain.py +++ b/tests/unit/core/test_domain.py @@ -10,7 +10,7 @@ class TestMeta: @pytest.mark.parametrize("json_content", [None, "", {}]) def test_parse_meta_empty_json(self, json_content): result = Meta.parse_meta(json_content) - assert result is None + assert result is not None def test_parse_meta_json_no_paginaton(self): json_content = {"meta": {}} diff --git a/tests/unit/datacenters/test_client.py b/tests/unit/datacenters/test_client.py index 369566b4..3da55e37 100644 --- a/tests/unit/datacenters/test_client.py +++ b/tests/unit/datacenters/test_client.py @@ -82,7 +82,7 @@ def test_get_list(self, datacenters_client, two_datacenters_response, params): ) datacenters = result.datacenters - assert result.meta is None + assert result.meta is not None assert len(datacenters) == 2 diff --git a/tests/unit/firewalls/test_client.py b/tests/unit/firewalls/test_client.py index 4e8cea94..1226c61f 100644 --- a/tests/unit/firewalls/test_client.py +++ b/tests/unit/firewalls/test_client.py @@ -84,7 +84,7 @@ def test_get_actions_list( ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -231,7 +231,7 @@ def test_get_list(self, firewalls_client, two_firewalls_response, params): ) firewalls = result.firewalls - assert result.meta is None + assert result.meta is not None assert len(firewalls) == 2 @@ -305,7 +305,7 @@ def test_get_actions_list(self, firewalls_client, firewall, response_get_actions ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -489,7 +489,7 @@ def test_actions_get_list(self, firewalls_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/floating_ips/test_client.py b/tests/unit/floating_ips/test_client.py index a56f0829..1f1160c6 100644 --- a/tests/unit/floating_ips/test_client.py +++ b/tests/unit/floating_ips/test_client.py @@ -165,7 +165,7 @@ def test_get_list(self, floating_ips_client, two_floating_ips_response, params): ) bound_floating_ips = result.floating_ips - assert result.meta is None + assert result.meta is not None assert len(bound_floating_ips) == 2 @@ -419,7 +419,7 @@ def test_actions_get_list(self, floating_ips_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/images/test_client.py b/tests/unit/images/test_client.py index 8e1dc490..744b13bb 100644 --- a/tests/unit/images/test_client.py +++ b/tests/unit/images/test_client.py @@ -59,7 +59,7 @@ def test_get_actions_list( ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -162,7 +162,7 @@ def test_get_list(self, images_client, two_images_response, params): ) images = result.images - assert result.meta is None + assert result.meta is not None assert len(images) == 2 @@ -254,7 +254,7 @@ def test_get_actions_list(self, images_client, image, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -337,7 +337,7 @@ def test_actions_get_list(self, images_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/isos/test_client.py b/tests/unit/isos/test_client.py index fc64ab47..7e71f8dc 100644 --- a/tests/unit/isos/test_client.py +++ b/tests/unit/isos/test_client.py @@ -63,7 +63,7 @@ def test_get_list(self, isos_client, two_isos_response, params): ) isos = result.isos - assert result.meta is None + assert result.meta is not None assert len(isos) == 2 diff --git a/tests/unit/load_balancer_types/test_client.py b/tests/unit/load_balancer_types/test_client.py index 23d2d14f..f0a4c12e 100644 --- a/tests/unit/load_balancer_types/test_client.py +++ b/tests/unit/load_balancer_types/test_client.py @@ -39,7 +39,7 @@ def test_get_list( ) load_balancer_types = result.load_balancer_types - assert result.meta is None + assert result.meta is not None assert len(load_balancer_types) == 2 diff --git a/tests/unit/load_balancers/test_client.py b/tests/unit/load_balancers/test_client.py index 3e9f281a..02ce1e50 100644 --- a/tests/unit/load_balancers/test_client.py +++ b/tests/unit/load_balancers/test_client.py @@ -46,7 +46,7 @@ def test_get_actions_list( ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -421,7 +421,7 @@ def test_get_list( ) bound_load_balancers = result.load_balancers - assert result.meta is None + assert result.meta is not None assert len(bound_load_balancers) == 2 @@ -569,7 +569,7 @@ def test_actions_get_list(self, load_balancers_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/locations/test_client.py b/tests/unit/locations/test_client.py index 9356707a..c288230a 100644 --- a/tests/unit/locations/test_client.py +++ b/tests/unit/locations/test_client.py @@ -34,7 +34,7 @@ def test_get_list(self, locations_client, two_locations_response, params): ) locations = result.locations - assert result.meta is None + assert result.meta is not None assert len(locations) == 2 diff --git a/tests/unit/networks/test_client.py b/tests/unit/networks/test_client.py index ff4dd233..4e986414 100644 --- a/tests/unit/networks/test_client.py +++ b/tests/unit/networks/test_client.py @@ -214,7 +214,7 @@ def test_get_list(self, networks_client, two_networks_response, params): ) bound_networks = result.networks - assert result.meta is None + assert result.meta is not None assert len(bound_networks) == 2 @@ -613,7 +613,7 @@ def test_actions_get_list(self, networks_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/placement_groups/test_client.py b/tests/unit/placement_groups/test_client.py index 6ba5db5c..27410cf9 100644 --- a/tests/unit/placement_groups/test_client.py +++ b/tests/unit/placement_groups/test_client.py @@ -108,7 +108,7 @@ def test_get_list( ) placement_groups = result.placement_groups - assert result.meta is None + assert result.meta is not None assert len(placement_groups) == len( two_placement_groups_response["placement_groups"] diff --git a/tests/unit/primary_ips/test_client.py b/tests/unit/primary_ips/test_client.py index 9db08fe4..65a19be9 100644 --- a/tests/unit/primary_ips/test_client.py +++ b/tests/unit/primary_ips/test_client.py @@ -321,7 +321,7 @@ def test_actions_get_list(self, primary_ips_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/server_types/test_client.py b/tests/unit/server_types/test_client.py index 54ab3a9b..91d94e28 100644 --- a/tests/unit/server_types/test_client.py +++ b/tests/unit/server_types/test_client.py @@ -64,7 +64,7 @@ def test_get_list(self, server_types_client, two_server_types_response, params): ) server_types = result.server_types - assert result.meta is None + assert result.meta is not None assert len(server_types) == 2 diff --git a/tests/unit/servers/test_client.py b/tests/unit/servers/test_client.py index b338979b..8f103df7 100644 --- a/tests/unit/servers/test_client.py +++ b/tests/unit/servers/test_client.py @@ -143,7 +143,7 @@ def test_get_actions_list( ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -558,7 +558,7 @@ def test_get_list(self, servers_client, response_simple_servers, params): ) bound_servers = result.servers - assert result.meta is None + assert result.meta is not None assert len(bound_servers) == 2 @@ -853,7 +853,7 @@ def test_get_actions_list(self, servers_client, server, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) @@ -1288,7 +1288,7 @@ def test_actions_get_list(self, servers_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction) diff --git a/tests/unit/volumes/test_client.py b/tests/unit/volumes/test_client.py index bb8bed00..1133a417 100644 --- a/tests/unit/volumes/test_client.py +++ b/tests/unit/volumes/test_client.py @@ -159,7 +159,7 @@ def test_get_list(self, volumes_client, two_volumes_response, params): ) bound_volumes = result.volumes - assert result.meta is None + assert result.meta is not None assert len(bound_volumes) == 2 @@ -412,7 +412,7 @@ def test_actions_get_list(self, volumes_client, response_get_actions): ) actions = result.actions - assert result.meta is None + assert result.meta is not None assert len(actions) == 1 assert isinstance(actions[0], BoundAction)