From 13bb69e2c2d15e1bb3bd90673ccf1c0094f2892b Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 23 Jul 2024 12:09:44 +0200 Subject: [PATCH 1/2] refactor: allow differences between api fields and slots --- hcloud/actions/domain.py | 3 ++- hcloud/certificates/domain.py | 7 +++-- hcloud/core/domain.py | 13 ++++----- hcloud/datacenters/domain.py | 6 +++-- hcloud/deprecation/domain.py | 3 ++- hcloud/firewalls/domain.py | 15 +++++++---- hcloud/floating_ips/domain.py | 6 +++-- hcloud/images/domain.py | 6 +++-- hcloud/isos/domain.py | 3 ++- hcloud/load_balancer_types/domain.py | 3 ++- hcloud/load_balancers/domain.py | 21 ++++++++++----- hcloud/locations/domain.py | 3 ++- hcloud/metrics/domain.py | 3 ++- hcloud/networks/domain.py | 13 ++++++--- hcloud/placement_groups/domain.py | 6 +++-- hcloud/primary_ips/domain.py | 6 +++-- hcloud/server_types/domain.py | 3 ++- hcloud/servers/domain.py | 40 +++++++++++++++++++--------- hcloud/ssh_keys/domain.py | 3 ++- hcloud/volumes/domain.py | 6 +++-- tests/unit/core/test_client.py | 3 ++- tests/unit/core/test_domain.py | 9 ++++--- 22 files changed, 120 insertions(+), 61 deletions(-) diff --git a/hcloud/actions/domain.py b/hcloud/actions/domain.py index 6950aea..46b700e 100644 --- a/hcloud/actions/domain.py +++ b/hcloud/actions/domain.py @@ -31,7 +31,7 @@ class Action(BaseDomain): STATUS_ERROR = "error" """Action Status error""" - __slots__ = ( + __fields__ = ( "id", "command", "status", @@ -41,6 +41,7 @@ class Action(BaseDomain): "started", "finished", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/certificates/domain.py b/hcloud/certificates/domain.py index 20be3e3..998fe93 100644 --- a/hcloud/certificates/domain.py +++ b/hcloud/certificates/domain.py @@ -31,7 +31,7 @@ class Certificate(BaseDomain, DomainIdentityMixin): :param status: ManagedCertificateStatus Current status of a type managed Certificate, always none for type uploaded Certificates """ - __slots__ = ( + __fields__ = ( "id", "name", "certificate", @@ -44,6 +44,8 @@ class Certificate(BaseDomain, DomainIdentityMixin): "type", "status", ) + __slots__ = __fields__ + TYPE_UPLOADED = "uploaded" TYPE_MANAGED = "managed" @@ -119,7 +121,8 @@ class CreateManagedCertificateResponse(BaseDomain): Shows the progress of the certificate creation """ - __slots__ = ("certificate", "action") + __fields__ = ("certificate", "action") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/core/domain.py b/hcloud/core/domain.py index bba954f..e0d292c 100644 --- a/hcloud/core/domain.py +++ b/hcloud/core/domain.py @@ -2,23 +2,22 @@ class BaseDomain: - __slots__ = () + __fields__: tuple @classmethod def from_dict(cls, data: dict): # type: ignore[no-untyped-def] """ Build the domain object from the data dict. """ - supported_data = {k: v for k, v in data.items() if k in cls.__slots__} + supported_data = {k: v for k, v in data.items() if k in cls.__fields__} return cls(**supported_data) def __repr__(self) -> str: - kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__slots__] # type: ignore[var-annotated] + kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__fields__] # type: ignore[var-annotated] return f"{self.__class__.__qualname__}({', '.join(kwargs)})" class DomainIdentityMixin: - __slots__ = () id: int | None name: str | None @@ -54,7 +53,7 @@ def has_id_or_name(self, id_or_name: int | str) -> bool: class Pagination(BaseDomain): - __slots__ = ( + __fields__ = ( "page", "per_page", "previous_page", @@ -62,6 +61,7 @@ class Pagination(BaseDomain): "last_page", "total_entries", ) + __slots__ = __fields__ def __init__( self, @@ -81,7 +81,8 @@ def __init__( class Meta(BaseDomain): - __slots__ = ("pagination",) + __fields__ = ("pagination",) + __slots__ = __fields__ def __init__(self, pagination: Pagination | None = None): self.pagination = pagination diff --git a/hcloud/datacenters/domain.py b/hcloud/datacenters/domain.py index 05d5f79..889f1f0 100644 --- a/hcloud/datacenters/domain.py +++ b/hcloud/datacenters/domain.py @@ -19,7 +19,8 @@ class Datacenter(BaseDomain, DomainIdentityMixin): :param server_types: :class:`DatacenterServerTypes ` """ - __slots__ = ("id", "name", "description", "location", "server_types") + __fields__ = ("id", "name", "description", "location", "server_types") + __slots__ = __fields__ def __init__( self, @@ -47,7 +48,8 @@ class DatacenterServerTypes(BaseDomain): All available for migration (change type) server types for this datacenter """ - __slots__ = ("available", "supported", "available_for_migration") + __fields__ = ("available", "supported", "available_for_migration") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/deprecation/domain.py b/hcloud/deprecation/domain.py index cd1b536..79822f0 100644 --- a/hcloud/deprecation/domain.py +++ b/hcloud/deprecation/domain.py @@ -17,10 +17,11 @@ class DeprecationInfo(BaseDomain): new servers with this image after the mentioned date. """ - __slots__ = ( + __fields__ = ( "announced", "unavailable_after", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/firewalls/domain.py b/hcloud/firewalls/domain.py index 41959ce..0fd3c87 100644 --- a/hcloud/firewalls/domain.py +++ b/hcloud/firewalls/domain.py @@ -29,7 +29,8 @@ class Firewall(BaseDomain, DomainIdentityMixin): Point in time when the image was created """ - __slots__ = ("id", "name", "labels", "rules", "applied_to", "created") + __fields__ = ("id", "name", "labels", "rules", "applied_to", "created") + __slots__ = __fields__ def __init__( self, @@ -66,7 +67,7 @@ class FirewallRule(BaseDomain): Short description of the firewall rule """ - __slots__ = ( + __fields__ = ( "direction", "port", "protocol", @@ -74,6 +75,7 @@ class FirewallRule(BaseDomain): "destination_ips", "description", ) + __slots__ = __fields__ DIRECTION_IN = "in" """Firewall Rule Direction In""" @@ -138,7 +140,8 @@ class FirewallResource(BaseDomain): applied to. """ - __slots__ = ("type", "server", "label_selector", "applied_to_resources") + __fields__ = ("type", "server", "label_selector", "applied_to_resources") + __slots__ = __fields__ TYPE_SERVER = "server" """Firewall Used By Type Server""" @@ -177,7 +180,8 @@ class FirewallResourceAppliedToResources(BaseDomain): :param server: Server the Firewall is applied to """ - __slots__ = ("type", "server") + __fields__ = ("type", "server") + __slots__ = __fields__ def __init__( self, @@ -207,7 +211,8 @@ class CreateFirewallResponse(BaseDomain): The Action which shows the progress of the Firewall Creation """ - __slots__ = ("firewall", "actions") + __fields__ = ("firewall", "actions") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/floating_ips/domain.py b/hcloud/floating_ips/domain.py index 78b701f..ddac571 100644 --- a/hcloud/floating_ips/domain.py +++ b/hcloud/floating_ips/domain.py @@ -42,7 +42,7 @@ class FloatingIP(BaseDomain, DomainIdentityMixin): Name of the Floating IP """ - __slots__ = ( + __fields__ = ( "id", "type", "description", @@ -56,6 +56,7 @@ class FloatingIP(BaseDomain, DomainIdentityMixin): "name", "created", ) + __slots__ = __fields__ def __init__( self, @@ -95,7 +96,8 @@ class CreateFloatingIPResponse(BaseDomain): The Action which shows the progress of the Floating IP Creation """ - __slots__ = ("floating_ip", "action") + __fields__ = ("floating_ip", "action") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/images/domain.py b/hcloud/images/domain.py index 37d6d9f..bcc0496 100644 --- a/hcloud/images/domain.py +++ b/hcloud/images/domain.py @@ -51,7 +51,7 @@ class Image(BaseDomain, DomainIdentityMixin): User-defined labels (key-value pairs) """ - __slots__ = ( + __fields__ = ( "id", "name", "type", @@ -70,6 +70,7 @@ class Image(BaseDomain, DomainIdentityMixin): "created", "deprecated", ) + __slots__ = __fields__ # pylint: disable=too-many-locals def __init__( @@ -120,7 +121,8 @@ class CreateImageResponse(BaseDomain): The Action which shows the progress of the Floating IP Creation """ - __slots__ = ("action", "image") + __fields__ = ("action", "image") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/isos/domain.py b/hcloud/isos/domain.py index b2f4d30..e0da348 100644 --- a/hcloud/isos/domain.py +++ b/hcloud/isos/domain.py @@ -27,7 +27,7 @@ class Iso(BaseDomain, DomainIdentityMixin): deprecated. If it has a value, it is considered deprecated. """ - __slots__ = ( + __fields__ = ( "id", "name", "type", @@ -35,6 +35,7 @@ class Iso(BaseDomain, DomainIdentityMixin): "description", "deprecation", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/load_balancer_types/domain.py b/hcloud/load_balancer_types/domain.py index 35719db..b23b299 100644 --- a/hcloud/load_balancer_types/domain.py +++ b/hcloud/load_balancer_types/domain.py @@ -25,7 +25,7 @@ class LoadBalancerType(BaseDomain, DomainIdentityMixin): """ - __slots__ = ( + __fields__ = ( "id", "name", "description", @@ -35,6 +35,7 @@ class LoadBalancerType(BaseDomain, DomainIdentityMixin): "max_assigned_certificates", "prices", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/load_balancers/domain.py b/hcloud/load_balancers/domain.py index fdf211a..7a09dd6 100644 --- a/hcloud/load_balancers/domain.py +++ b/hcloud/load_balancers/domain.py @@ -52,7 +52,7 @@ class LoadBalancer(BaseDomain, DomainIdentityMixin): Free Traffic for the current billing period in bytes """ - __slots__ = ( + __fields__ = ( "id", "name", "public_net", @@ -69,6 +69,7 @@ class LoadBalancer(BaseDomain, DomainIdentityMixin): "ingoing_traffic", "included_traffic", ) + __slots__ = __fields__ # pylint: disable=too-many-locals def __init__( @@ -422,7 +423,8 @@ class PublicNetwork(BaseDomain): :param enabled: boolean """ - __slots__ = ("ipv4", "ipv6", "enabled") + __fields__ = ("ipv4", "ipv6", "enabled") + __slots__ = __fields__ def __init__( self, @@ -442,7 +444,8 @@ class IPv4Address(BaseDomain): The IPv4 Address """ - __slots__ = ("ip", "dns_ptr") + __fields__ = ("ip", "dns_ptr") + __slots__ = __fields__ def __init__( self, @@ -460,7 +463,8 @@ class IPv6Network(BaseDomain): The IPv6 Network as CIDR Notation """ - __slots__ = ("ip", "dns_ptr") + __fields__ = ("ip", "dns_ptr") + __slots__ = __fields__ def __init__( self, @@ -480,7 +484,8 @@ class PrivateNet(BaseDomain): The main IP Address of the LoadBalancer in the Network """ - __slots__ = ("network", "ip") + __fields__ = ("network", "ip") + __slots__ = __fields__ def __init__( self, @@ -500,7 +505,8 @@ class CreateLoadBalancerResponse(BaseDomain): Shows the progress of the Load Balancer creation """ - __slots__ = ("load_balancer", "action") + __fields__ = ("load_balancer", "action") + __slots__ = __fields__ def __init__( self, @@ -525,7 +531,8 @@ class GetMetricsResponse(BaseDomain): :param metrics: The Load Balancer metrics """ - __slots__ = ("metrics",) + __fields__ = ("metrics",) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/locations/domain.py b/hcloud/locations/domain.py index 7d4af22..5f1cc3a 100644 --- a/hcloud/locations/domain.py +++ b/hcloud/locations/domain.py @@ -24,7 +24,7 @@ class Location(BaseDomain, DomainIdentityMixin): Name of network zone this location resides in """ - __slots__ = ( + __fields__ = ( "id", "name", "description", @@ -34,6 +34,7 @@ class Location(BaseDomain, DomainIdentityMixin): "longitude", "network_zone", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/metrics/domain.py b/hcloud/metrics/domain.py index 4693f15..cc14820 100644 --- a/hcloud/metrics/domain.py +++ b/hcloud/metrics/domain.py @@ -26,12 +26,13 @@ class Metrics(BaseDomain): step: float time_series: TimeSeries - __slots__ = ( + __fields__ = ( "start", "end", "step", "time_series", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/networks/domain.py b/hcloud/networks/domain.py index 2135d5f..853e5cb 100644 --- a/hcloud/networks/domain.py +++ b/hcloud/networks/domain.py @@ -35,7 +35,7 @@ class Network(BaseDomain, DomainIdentityMixin): User-defined labels (key-value pairs) """ - __slots__ = ( + __fields__ = ( "id", "name", "ip_range", @@ -47,6 +47,7 @@ class Network(BaseDomain, DomainIdentityMixin): "labels", "created", ) + __slots__ = __fields__ def __init__( self, @@ -94,7 +95,9 @@ class NetworkSubnet(BaseDomain): """Subnet Type cloud""" TYPE_VSWITCH = "vswitch" """Subnet Type vSwitch""" - __slots__ = ("type", "ip_range", "network_zone", "gateway", "vswitch_id") + + __fields__ = ("type", "ip_range", "network_zone", "gateway", "vswitch_id") + __slots__ = __fields__ def __init__( self, @@ -120,7 +123,8 @@ class NetworkRoute(BaseDomain): Gateway for the route. """ - __slots__ = ("destination", "gateway") + __fields__ = ("destination", "gateway") + __slots__ = __fields__ def __init__(self, destination: str, gateway: str): self.destination = destination @@ -136,7 +140,8 @@ class CreateNetworkResponse(BaseDomain): The Action which shows the progress of the network Creation """ - __slots__ = ("network", "action") + __fields__ = ("network", "action") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/placement_groups/domain.py b/hcloud/placement_groups/domain.py index 7b7fcb3..9c19f88 100644 --- a/hcloud/placement_groups/domain.py +++ b/hcloud/placement_groups/domain.py @@ -28,7 +28,8 @@ class PlacementGroup(BaseDomain, DomainIdentityMixin): Point in time when the image was created """ - __slots__ = ("id", "name", "labels", "servers", "type", "created") + __fields__ = ("id", "name", "labels", "servers", "type", "created") + __slots__ = __fields__ """Placement Group type spread spreads all servers in the group on different vhosts @@ -61,7 +62,8 @@ class CreatePlacementGroupResponse(BaseDomain): The Action which shows the progress of the Placement Group Creation """ - __slots__ = ("placement_group", "action") + __fields__ = ("placement_group", "action") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/primary_ips/domain.py b/hcloud/primary_ips/domain.py index bd47060..d4697f1 100644 --- a/hcloud/primary_ips/domain.py +++ b/hcloud/primary_ips/domain.py @@ -43,7 +43,7 @@ class PrimaryIP(BaseDomain, DomainIdentityMixin): Delete the Primary IP when the Assignee it is assigned to is deleted. """ - __slots__ = ( + __fields__ = ( "id", "ip", "type", @@ -58,6 +58,7 @@ class PrimaryIP(BaseDomain, DomainIdentityMixin): "assignee_type", "auto_delete", ) + __slots__ = __fields__ def __init__( self, @@ -99,7 +100,8 @@ class CreatePrimaryIPResponse(BaseDomain): The Action which shows the progress of the Primary IP Creation """ - __slots__ = ("primary_ip", "action") + __fields__ = ("primary_ip", "action") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/server_types/domain.py b/hcloud/server_types/domain.py index ab2553b..7882885 100644 --- a/hcloud/server_types/domain.py +++ b/hcloud/server_types/domain.py @@ -36,7 +36,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): Free traffic per month in bytes """ - __slots__ = ( + __fields__ = ( "id", "name", "description", @@ -51,6 +51,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): "deprecation", "included_traffic", ) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/servers/domain.py b/hcloud/servers/domain.py index e886e1a..2a1fac0 100644 --- a/hcloud/servers/domain.py +++ b/hcloud/servers/domain.py @@ -81,7 +81,8 @@ class Server(BaseDomain, DomainIdentityMixin): """Server Status rebuilding""" STATUS_UNKNOWN = "unknown" """Server Status unknown""" - __slots__ = ( + + __fields__ = ( "id", "name", "status", @@ -104,6 +105,7 @@ class Server(BaseDomain, DomainIdentityMixin): "primary_disk_size", "placement_group", ) + __slots__ = __fields__ # pylint: disable=too-many-locals def __init__( @@ -166,7 +168,8 @@ class CreateServerResponse(BaseDomain): The root password of the server if no SSH-Key was given on server creation """ - __slots__ = ("server", "action", "next_actions", "root_password") + __fields__ = ("server", "action", "next_actions", "root_password") + __slots__ = __fields__ def __init__( self, @@ -190,7 +193,8 @@ class ResetPasswordResponse(BaseDomain): The root password of the server """ - __slots__ = ("action", "root_password") + __fields__ = ("action", "root_password") + __slots__ = __fields__ def __init__( self, @@ -210,7 +214,8 @@ class EnableRescueResponse(BaseDomain): The root password of the server in the rescue mode """ - __slots__ = ("action", "root_password") + __fields__ = ("action", "root_password") + __slots__ = __fields__ def __init__( self, @@ -232,7 +237,8 @@ class RequestConsoleResponse(BaseDomain): VNC password to use for this connection. This password only works in combination with a wss_url with valid token. """ - __slots__ = ("action", "wss_url", "password") + __fields__ = ("action", "wss_url", "password") + __slots__ = __fields__ def __init__( self, @@ -252,7 +258,8 @@ class RebuildResponse(BaseDomain): :param root_password: The root password of the server when not using SSH keys """ - __slots__ = ("action", "root_password") + __fields__ = ("action", "root_password") + __slots__ = __fields__ def __init__( self, @@ -274,7 +281,7 @@ class PublicNetwork(BaseDomain): :param firewalls: List[:class:`PublicNetworkFirewall `] """ - __slots__ = ( + __fields__ = ( "ipv4", "ipv6", "floating_ips", @@ -282,6 +289,7 @@ class PublicNetwork(BaseDomain): "primary_ipv4", "primary_ipv6", ) + __slots__ = __fields__ def __init__( self, @@ -307,7 +315,8 @@ class PublicNetworkFirewall(BaseDomain): :param status: str """ - __slots__ = ("firewall", "status") + __fields__ = ("firewall", "status") + __slots__ = __fields__ STATUS_APPLIED = "applied" """Public Network Firewall Status applied""" @@ -334,7 +343,8 @@ class IPv4Address(BaseDomain): DNS PTR for the ip """ - __slots__ = ("ip", "blocked", "dns_ptr") + __fields__ = ("ip", "blocked", "dns_ptr") + __slots__ = __fields__ def __init__( self, @@ -362,7 +372,8 @@ class IPv6Network(BaseDomain): The network mask """ - __slots__ = ("ip", "blocked", "dns_ptr", "network", "network_mask") + __fields__ = ("ip", "blocked", "dns_ptr", "network", "network_mask") + __slots__ = __fields__ def __init__( self, @@ -391,7 +402,8 @@ class PrivateNet(BaseDomain): The mac address of the interface on the server """ - __slots__ = ("network", "ip", "alias_ips", "mac_address") + __fields__ = ("network", "ip", "alias_ips", "mac_address") + __slots__ = __fields__ def __init__( self, @@ -415,7 +427,8 @@ class ServerCreatePublicNetwork(BaseDomain): :param enable_ipv6: bool """ - __slots__ = ("ipv4", "ipv6", "enable_ipv4", "enable_ipv6") + __fields__ = ("ipv4", "ipv6", "enable_ipv4", "enable_ipv6") + __slots__ = __fields__ def __init__( self, @@ -443,7 +456,8 @@ class GetMetricsResponse(BaseDomain): :param metrics: The Server metrics """ - __slots__ = ("metrics",) + __fields__ = ("metrics",) + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/ssh_keys/domain.py b/hcloud/ssh_keys/domain.py index 09c98ca..ced1ea6 100644 --- a/hcloud/ssh_keys/domain.py +++ b/hcloud/ssh_keys/domain.py @@ -22,7 +22,8 @@ class SSHKey(BaseDomain, DomainIdentityMixin): Point in time when the SSH Key was created """ - __slots__ = ("id", "name", "fingerprint", "public_key", "labels", "created") + __fields__ = ("id", "name", "fingerprint", "public_key", "labels", "created") + __slots__ = __fields__ def __init__( self, diff --git a/hcloud/volumes/domain.py b/hcloud/volumes/domain.py index fb793ef..f9f01c6 100644 --- a/hcloud/volumes/domain.py +++ b/hcloud/volumes/domain.py @@ -45,7 +45,7 @@ class Volume(BaseDomain, DomainIdentityMixin): STATUS_AVAILABLE = "available" """Volume Status available""" - __slots__ = ( + __fields__ = ( "id", "name", "server", @@ -58,6 +58,7 @@ class Volume(BaseDomain, DomainIdentityMixin): "status", "created", ) + __slots__ = __fields__ def __init__( self, @@ -97,7 +98,8 @@ class CreateVolumeResponse(BaseDomain): List of actions that are performed after the creation, like attaching to a server """ - __slots__ = ("volume", "action", "next_actions") + __fields__ = ("volume", "action", "next_actions") + __slots__ = __fields__ def __init__( self, diff --git a/tests/unit/core/test_client.py b/tests/unit/core/test_client.py index 584af8c..5c9cff4 100644 --- a/tests/unit/core/test_client.py +++ b/tests/unit/core/test_client.py @@ -13,7 +13,8 @@ class TestBoundModelBase: @pytest.fixture() def bound_model_class(self): class Model(BaseDomain): - __slots__ = ("id", "name", "description") + __fields__ = ("id", "name", "description") + __slots__ = __fields__ def __init__(self, id, name="", description=""): self.id = id diff --git a/tests/unit/core/test_domain.py b/tests/unit/core/test_domain.py index fabf762..3ff33ba 100644 --- a/tests/unit/core/test_domain.py +++ b/tests/unit/core/test_domain.py @@ -42,7 +42,8 @@ def test_parse_meta_json_ok(self): class SomeDomain(BaseDomain, DomainIdentityMixin): - __slots__ = ("id", "name") + __fields__ = ("id", "name") + __slots__ = __fields__ def __init__(self, id=None, name=None): self.id = id @@ -86,7 +87,8 @@ def test_has_id_or_name_exception(self, other, expected): class ActionDomain(BaseDomain, DomainIdentityMixin): - __slots__ = ("id", "name", "started") + __fields__ = ("id", "name", "started") + __slots__ = __fields__ def __init__(self, id, name="name1", started=None): self.id = id @@ -95,7 +97,8 @@ def __init__(self, id, name="name1", started=None): class SomeOtherDomain(BaseDomain): - __slots__ = ("id", "name", "child") + __fields__ = ("id", "name", "child") + __slots__ = __fields__ def __init__(self, id=None, name=None, child=None): self.id = id From e41435dbd7655029bd637158e4bb301b61241e2d Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 23 Jul 2024 12:30:27 +0200 Subject: [PATCH 2/2] rename fields to api properties --- hcloud/actions/domain.py | 4 +-- hcloud/certificates/domain.py | 8 ++--- hcloud/core/domain.py | 14 ++++---- hcloud/datacenters/domain.py | 8 ++--- hcloud/deprecation/domain.py | 4 +-- hcloud/firewalls/domain.py | 20 +++++------ hcloud/floating_ips/domain.py | 8 ++--- hcloud/images/domain.py | 8 ++--- hcloud/isos/domain.py | 4 +-- hcloud/load_balancer_types/domain.py | 4 +-- hcloud/load_balancers/domain.py | 28 +++++++-------- hcloud/locations/domain.py | 4 +-- hcloud/metrics/domain.py | 4 +-- hcloud/networks/domain.py | 16 ++++----- hcloud/placement_groups/domain.py | 8 ++--- hcloud/primary_ips/domain.py | 8 ++--- hcloud/server_types/domain.py | 4 +-- hcloud/servers/domain.py | 52 ++++++++++++++-------------- hcloud/ssh_keys/domain.py | 11 ++++-- hcloud/volumes/domain.py | 8 ++--- tests/unit/core/test_client.py | 4 +-- tests/unit/core/test_domain.py | 12 +++---- 22 files changed, 124 insertions(+), 117 deletions(-) diff --git a/hcloud/actions/domain.py b/hcloud/actions/domain.py index 46b700e..71f3f3a 100644 --- a/hcloud/actions/domain.py +++ b/hcloud/actions/domain.py @@ -31,7 +31,7 @@ class Action(BaseDomain): STATUS_ERROR = "error" """Action Status error""" - __fields__ = ( + __api_properties__ = ( "id", "command", "status", @@ -41,7 +41,7 @@ class Action(BaseDomain): "started", "finished", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/certificates/domain.py b/hcloud/certificates/domain.py index 998fe93..2434a74 100644 --- a/hcloud/certificates/domain.py +++ b/hcloud/certificates/domain.py @@ -31,7 +31,7 @@ class Certificate(BaseDomain, DomainIdentityMixin): :param status: ManagedCertificateStatus Current status of a type managed Certificate, always none for type uploaded Certificates """ - __fields__ = ( + __api_properties__ = ( "id", "name", "certificate", @@ -44,7 +44,7 @@ class Certificate(BaseDomain, DomainIdentityMixin): "type", "status", ) - __slots__ = __fields__ + __slots__ = __api_properties__ TYPE_UPLOADED = "uploaded" TYPE_MANAGED = "managed" @@ -121,8 +121,8 @@ class CreateManagedCertificateResponse(BaseDomain): Shows the progress of the certificate creation """ - __fields__ = ("certificate", "action") - __slots__ = __fields__ + __api_properties__ = ("certificate", "action") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/core/domain.py b/hcloud/core/domain.py index e0d292c..d848525 100644 --- a/hcloud/core/domain.py +++ b/hcloud/core/domain.py @@ -2,18 +2,18 @@ class BaseDomain: - __fields__: tuple + __api_properties__: tuple @classmethod def from_dict(cls, data: dict): # type: ignore[no-untyped-def] """ Build the domain object from the data dict. """ - supported_data = {k: v for k, v in data.items() if k in cls.__fields__} + supported_data = {k: v for k, v in data.items() if k in cls.__api_properties__} return cls(**supported_data) def __repr__(self) -> str: - kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__fields__] # type: ignore[var-annotated] + kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__api_properties__] # type: ignore[var-annotated] return f"{self.__class__.__qualname__}({', '.join(kwargs)})" @@ -53,7 +53,7 @@ def has_id_or_name(self, id_or_name: int | str) -> bool: class Pagination(BaseDomain): - __fields__ = ( + __api_properties__ = ( "page", "per_page", "previous_page", @@ -61,7 +61,7 @@ class Pagination(BaseDomain): "last_page", "total_entries", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, @@ -81,8 +81,8 @@ def __init__( class Meta(BaseDomain): - __fields__ = ("pagination",) - __slots__ = __fields__ + __api_properties__ = ("pagination",) + __slots__ = __api_properties__ def __init__(self, pagination: Pagination | None = None): self.pagination = pagination diff --git a/hcloud/datacenters/domain.py b/hcloud/datacenters/domain.py index 889f1f0..badd335 100644 --- a/hcloud/datacenters/domain.py +++ b/hcloud/datacenters/domain.py @@ -19,8 +19,8 @@ class Datacenter(BaseDomain, DomainIdentityMixin): :param server_types: :class:`DatacenterServerTypes ` """ - __fields__ = ("id", "name", "description", "location", "server_types") - __slots__ = __fields__ + __api_properties__ = ("id", "name", "description", "location", "server_types") + __slots__ = __api_properties__ def __init__( self, @@ -48,8 +48,8 @@ class DatacenterServerTypes(BaseDomain): All available for migration (change type) server types for this datacenter """ - __fields__ = ("available", "supported", "available_for_migration") - __slots__ = __fields__ + __api_properties__ = ("available", "supported", "available_for_migration") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/deprecation/domain.py b/hcloud/deprecation/domain.py index 79822f0..152a24e 100644 --- a/hcloud/deprecation/domain.py +++ b/hcloud/deprecation/domain.py @@ -17,11 +17,11 @@ class DeprecationInfo(BaseDomain): new servers with this image after the mentioned date. """ - __fields__ = ( + __api_properties__ = ( "announced", "unavailable_after", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/firewalls/domain.py b/hcloud/firewalls/domain.py index 0fd3c87..e0787ec 100644 --- a/hcloud/firewalls/domain.py +++ b/hcloud/firewalls/domain.py @@ -29,8 +29,8 @@ class Firewall(BaseDomain, DomainIdentityMixin): Point in time when the image was created """ - __fields__ = ("id", "name", "labels", "rules", "applied_to", "created") - __slots__ = __fields__ + __api_properties__ = ("id", "name", "labels", "rules", "applied_to", "created") + __slots__ = __api_properties__ def __init__( self, @@ -67,7 +67,7 @@ class FirewallRule(BaseDomain): Short description of the firewall rule """ - __fields__ = ( + __api_properties__ = ( "direction", "port", "protocol", @@ -75,7 +75,7 @@ class FirewallRule(BaseDomain): "destination_ips", "description", ) - __slots__ = __fields__ + __slots__ = __api_properties__ DIRECTION_IN = "in" """Firewall Rule Direction In""" @@ -140,8 +140,8 @@ class FirewallResource(BaseDomain): applied to. """ - __fields__ = ("type", "server", "label_selector", "applied_to_resources") - __slots__ = __fields__ + __api_properties__ = ("type", "server", "label_selector", "applied_to_resources") + __slots__ = __api_properties__ TYPE_SERVER = "server" """Firewall Used By Type Server""" @@ -180,8 +180,8 @@ class FirewallResourceAppliedToResources(BaseDomain): :param server: Server the Firewall is applied to """ - __fields__ = ("type", "server") - __slots__ = __fields__ + __api_properties__ = ("type", "server") + __slots__ = __api_properties__ def __init__( self, @@ -211,8 +211,8 @@ class CreateFirewallResponse(BaseDomain): The Action which shows the progress of the Firewall Creation """ - __fields__ = ("firewall", "actions") - __slots__ = __fields__ + __api_properties__ = ("firewall", "actions") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/floating_ips/domain.py b/hcloud/floating_ips/domain.py index ddac571..1b02d8c 100644 --- a/hcloud/floating_ips/domain.py +++ b/hcloud/floating_ips/domain.py @@ -42,7 +42,7 @@ class FloatingIP(BaseDomain, DomainIdentityMixin): Name of the Floating IP """ - __fields__ = ( + __api_properties__ = ( "id", "type", "description", @@ -56,7 +56,7 @@ class FloatingIP(BaseDomain, DomainIdentityMixin): "name", "created", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, @@ -96,8 +96,8 @@ class CreateFloatingIPResponse(BaseDomain): The Action which shows the progress of the Floating IP Creation """ - __fields__ = ("floating_ip", "action") - __slots__ = __fields__ + __api_properties__ = ("floating_ip", "action") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/images/domain.py b/hcloud/images/domain.py index bcc0496..497bedb 100644 --- a/hcloud/images/domain.py +++ b/hcloud/images/domain.py @@ -51,7 +51,7 @@ class Image(BaseDomain, DomainIdentityMixin): User-defined labels (key-value pairs) """ - __fields__ = ( + __api_properties__ = ( "id", "name", "type", @@ -70,7 +70,7 @@ class Image(BaseDomain, DomainIdentityMixin): "created", "deprecated", ) - __slots__ = __fields__ + __slots__ = __api_properties__ # pylint: disable=too-many-locals def __init__( @@ -121,8 +121,8 @@ class CreateImageResponse(BaseDomain): The Action which shows the progress of the Floating IP Creation """ - __fields__ = ("action", "image") - __slots__ = __fields__ + __api_properties__ = ("action", "image") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/isos/domain.py b/hcloud/isos/domain.py index e0da348..2a5667e 100644 --- a/hcloud/isos/domain.py +++ b/hcloud/isos/domain.py @@ -27,7 +27,7 @@ class Iso(BaseDomain, DomainIdentityMixin): deprecated. If it has a value, it is considered deprecated. """ - __fields__ = ( + __api_properties__ = ( "id", "name", "type", @@ -35,7 +35,7 @@ class Iso(BaseDomain, DomainIdentityMixin): "description", "deprecation", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/load_balancer_types/domain.py b/hcloud/load_balancer_types/domain.py index b23b299..6ef4c28 100644 --- a/hcloud/load_balancer_types/domain.py +++ b/hcloud/load_balancer_types/domain.py @@ -25,7 +25,7 @@ class LoadBalancerType(BaseDomain, DomainIdentityMixin): """ - __fields__ = ( + __api_properties__ = ( "id", "name", "description", @@ -35,7 +35,7 @@ class LoadBalancerType(BaseDomain, DomainIdentityMixin): "max_assigned_certificates", "prices", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/load_balancers/domain.py b/hcloud/load_balancers/domain.py index 7a09dd6..d1a370a 100644 --- a/hcloud/load_balancers/domain.py +++ b/hcloud/load_balancers/domain.py @@ -52,7 +52,7 @@ class LoadBalancer(BaseDomain, DomainIdentityMixin): Free Traffic for the current billing period in bytes """ - __fields__ = ( + __api_properties__ = ( "id", "name", "public_net", @@ -69,7 +69,7 @@ class LoadBalancer(BaseDomain, DomainIdentityMixin): "ingoing_traffic", "included_traffic", ) - __slots__ = __fields__ + __slots__ = __api_properties__ # pylint: disable=too-many-locals def __init__( @@ -423,8 +423,8 @@ class PublicNetwork(BaseDomain): :param enabled: boolean """ - __fields__ = ("ipv4", "ipv6", "enabled") - __slots__ = __fields__ + __api_properties__ = ("ipv4", "ipv6", "enabled") + __slots__ = __api_properties__ def __init__( self, @@ -444,8 +444,8 @@ class IPv4Address(BaseDomain): The IPv4 Address """ - __fields__ = ("ip", "dns_ptr") - __slots__ = __fields__ + __api_properties__ = ("ip", "dns_ptr") + __slots__ = __api_properties__ def __init__( self, @@ -463,8 +463,8 @@ class IPv6Network(BaseDomain): The IPv6 Network as CIDR Notation """ - __fields__ = ("ip", "dns_ptr") - __slots__ = __fields__ + __api_properties__ = ("ip", "dns_ptr") + __slots__ = __api_properties__ def __init__( self, @@ -484,8 +484,8 @@ class PrivateNet(BaseDomain): The main IP Address of the LoadBalancer in the Network """ - __fields__ = ("network", "ip") - __slots__ = __fields__ + __api_properties__ = ("network", "ip") + __slots__ = __api_properties__ def __init__( self, @@ -505,8 +505,8 @@ class CreateLoadBalancerResponse(BaseDomain): Shows the progress of the Load Balancer creation """ - __fields__ = ("load_balancer", "action") - __slots__ = __fields__ + __api_properties__ = ("load_balancer", "action") + __slots__ = __api_properties__ def __init__( self, @@ -531,8 +531,8 @@ class GetMetricsResponse(BaseDomain): :param metrics: The Load Balancer metrics """ - __fields__ = ("metrics",) - __slots__ = __fields__ + __api_properties__ = ("metrics",) + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/locations/domain.py b/hcloud/locations/domain.py index 5f1cc3a..dcdf7a9 100644 --- a/hcloud/locations/domain.py +++ b/hcloud/locations/domain.py @@ -24,7 +24,7 @@ class Location(BaseDomain, DomainIdentityMixin): Name of network zone this location resides in """ - __fields__ = ( + __api_properties__ = ( "id", "name", "description", @@ -34,7 +34,7 @@ class Location(BaseDomain, DomainIdentityMixin): "longitude", "network_zone", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/metrics/domain.py b/hcloud/metrics/domain.py index cc14820..cf65571 100644 --- a/hcloud/metrics/domain.py +++ b/hcloud/metrics/domain.py @@ -26,13 +26,13 @@ class Metrics(BaseDomain): step: float time_series: TimeSeries - __fields__ = ( + __api_properties__ = ( "start", "end", "step", "time_series", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/networks/domain.py b/hcloud/networks/domain.py index 853e5cb..58e97c4 100644 --- a/hcloud/networks/domain.py +++ b/hcloud/networks/domain.py @@ -35,7 +35,7 @@ class Network(BaseDomain, DomainIdentityMixin): User-defined labels (key-value pairs) """ - __fields__ = ( + __api_properties__ = ( "id", "name", "ip_range", @@ -47,7 +47,7 @@ class Network(BaseDomain, DomainIdentityMixin): "labels", "created", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, @@ -96,8 +96,8 @@ class NetworkSubnet(BaseDomain): TYPE_VSWITCH = "vswitch" """Subnet Type vSwitch""" - __fields__ = ("type", "ip_range", "network_zone", "gateway", "vswitch_id") - __slots__ = __fields__ + __api_properties__ = ("type", "ip_range", "network_zone", "gateway", "vswitch_id") + __slots__ = __api_properties__ def __init__( self, @@ -123,8 +123,8 @@ class NetworkRoute(BaseDomain): Gateway for the route. """ - __fields__ = ("destination", "gateway") - __slots__ = __fields__ + __api_properties__ = ("destination", "gateway") + __slots__ = __api_properties__ def __init__(self, destination: str, gateway: str): self.destination = destination @@ -140,8 +140,8 @@ class CreateNetworkResponse(BaseDomain): The Action which shows the progress of the network Creation """ - __fields__ = ("network", "action") - __slots__ = __fields__ + __api_properties__ = ("network", "action") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/placement_groups/domain.py b/hcloud/placement_groups/domain.py index 9c19f88..4315140 100644 --- a/hcloud/placement_groups/domain.py +++ b/hcloud/placement_groups/domain.py @@ -28,8 +28,8 @@ class PlacementGroup(BaseDomain, DomainIdentityMixin): Point in time when the image was created """ - __fields__ = ("id", "name", "labels", "servers", "type", "created") - __slots__ = __fields__ + __api_properties__ = ("id", "name", "labels", "servers", "type", "created") + __slots__ = __api_properties__ """Placement Group type spread spreads all servers in the group on different vhosts @@ -62,8 +62,8 @@ class CreatePlacementGroupResponse(BaseDomain): The Action which shows the progress of the Placement Group Creation """ - __fields__ = ("placement_group", "action") - __slots__ = __fields__ + __api_properties__ = ("placement_group", "action") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/primary_ips/domain.py b/hcloud/primary_ips/domain.py index d4697f1..7cb0fa6 100644 --- a/hcloud/primary_ips/domain.py +++ b/hcloud/primary_ips/domain.py @@ -43,7 +43,7 @@ class PrimaryIP(BaseDomain, DomainIdentityMixin): Delete the Primary IP when the Assignee it is assigned to is deleted. """ - __fields__ = ( + __api_properties__ = ( "id", "ip", "type", @@ -58,7 +58,7 @@ class PrimaryIP(BaseDomain, DomainIdentityMixin): "assignee_type", "auto_delete", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, @@ -100,8 +100,8 @@ class CreatePrimaryIPResponse(BaseDomain): The Action which shows the progress of the Primary IP Creation """ - __fields__ = ("primary_ip", "action") - __slots__ = __fields__ + __api_properties__ = ("primary_ip", "action") + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/server_types/domain.py b/hcloud/server_types/domain.py index 7882885..54f9bf4 100644 --- a/hcloud/server_types/domain.py +++ b/hcloud/server_types/domain.py @@ -36,7 +36,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): Free traffic per month in bytes """ - __fields__ = ( + __api_properties__ = ( "id", "name", "description", @@ -51,7 +51,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): "deprecation", "included_traffic", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/servers/domain.py b/hcloud/servers/domain.py index 2a1fac0..4f9d80d 100644 --- a/hcloud/servers/domain.py +++ b/hcloud/servers/domain.py @@ -82,7 +82,7 @@ class Server(BaseDomain, DomainIdentityMixin): STATUS_UNKNOWN = "unknown" """Server Status unknown""" - __fields__ = ( + __api_properties__ = ( "id", "name", "status", @@ -105,7 +105,7 @@ class Server(BaseDomain, DomainIdentityMixin): "primary_disk_size", "placement_group", ) - __slots__ = __fields__ + __slots__ = __api_properties__ # pylint: disable=too-many-locals def __init__( @@ -168,8 +168,8 @@ class CreateServerResponse(BaseDomain): The root password of the server if no SSH-Key was given on server creation """ - __fields__ = ("server", "action", "next_actions", "root_password") - __slots__ = __fields__ + __api_properties__ = ("server", "action", "next_actions", "root_password") + __slots__ = __api_properties__ def __init__( self, @@ -193,8 +193,8 @@ class ResetPasswordResponse(BaseDomain): The root password of the server """ - __fields__ = ("action", "root_password") - __slots__ = __fields__ + __api_properties__ = ("action", "root_password") + __slots__ = __api_properties__ def __init__( self, @@ -214,8 +214,8 @@ class EnableRescueResponse(BaseDomain): The root password of the server in the rescue mode """ - __fields__ = ("action", "root_password") - __slots__ = __fields__ + __api_properties__ = ("action", "root_password") + __slots__ = __api_properties__ def __init__( self, @@ -237,8 +237,8 @@ class RequestConsoleResponse(BaseDomain): VNC password to use for this connection. This password only works in combination with a wss_url with valid token. """ - __fields__ = ("action", "wss_url", "password") - __slots__ = __fields__ + __api_properties__ = ("action", "wss_url", "password") + __slots__ = __api_properties__ def __init__( self, @@ -258,8 +258,8 @@ class RebuildResponse(BaseDomain): :param root_password: The root password of the server when not using SSH keys """ - __fields__ = ("action", "root_password") - __slots__ = __fields__ + __api_properties__ = ("action", "root_password") + __slots__ = __api_properties__ def __init__( self, @@ -281,7 +281,7 @@ class PublicNetwork(BaseDomain): :param firewalls: List[:class:`PublicNetworkFirewall `] """ - __fields__ = ( + __api_properties__ = ( "ipv4", "ipv6", "floating_ips", @@ -289,7 +289,7 @@ class PublicNetwork(BaseDomain): "primary_ipv4", "primary_ipv6", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, @@ -315,8 +315,8 @@ class PublicNetworkFirewall(BaseDomain): :param status: str """ - __fields__ = ("firewall", "status") - __slots__ = __fields__ + __api_properties__ = ("firewall", "status") + __slots__ = __api_properties__ STATUS_APPLIED = "applied" """Public Network Firewall Status applied""" @@ -343,8 +343,8 @@ class IPv4Address(BaseDomain): DNS PTR for the ip """ - __fields__ = ("ip", "blocked", "dns_ptr") - __slots__ = __fields__ + __api_properties__ = ("ip", "blocked", "dns_ptr") + __slots__ = __api_properties__ def __init__( self, @@ -372,8 +372,8 @@ class IPv6Network(BaseDomain): The network mask """ - __fields__ = ("ip", "blocked", "dns_ptr", "network", "network_mask") - __slots__ = __fields__ + __api_properties__ = ("ip", "blocked", "dns_ptr", "network", "network_mask") + __slots__ = __api_properties__ def __init__( self, @@ -402,8 +402,8 @@ class PrivateNet(BaseDomain): The mac address of the interface on the server """ - __fields__ = ("network", "ip", "alias_ips", "mac_address") - __slots__ = __fields__ + __api_properties__ = ("network", "ip", "alias_ips", "mac_address") + __slots__ = __api_properties__ def __init__( self, @@ -427,8 +427,8 @@ class ServerCreatePublicNetwork(BaseDomain): :param enable_ipv6: bool """ - __fields__ = ("ipv4", "ipv6", "enable_ipv4", "enable_ipv6") - __slots__ = __fields__ + __api_properties__ = ("ipv4", "ipv6", "enable_ipv4", "enable_ipv6") + __slots__ = __api_properties__ def __init__( self, @@ -456,8 +456,8 @@ class GetMetricsResponse(BaseDomain): :param metrics: The Server metrics """ - __fields__ = ("metrics",) - __slots__ = __fields__ + __api_properties__ = ("metrics",) + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/ssh_keys/domain.py b/hcloud/ssh_keys/domain.py index ced1ea6..8f8bdda 100644 --- a/hcloud/ssh_keys/domain.py +++ b/hcloud/ssh_keys/domain.py @@ -22,8 +22,15 @@ class SSHKey(BaseDomain, DomainIdentityMixin): Point in time when the SSH Key was created """ - __fields__ = ("id", "name", "fingerprint", "public_key", "labels", "created") - __slots__ = __fields__ + __api_properties__ = ( + "id", + "name", + "fingerprint", + "public_key", + "labels", + "created", + ) + __slots__ = __api_properties__ def __init__( self, diff --git a/hcloud/volumes/domain.py b/hcloud/volumes/domain.py index f9f01c6..f293437 100644 --- a/hcloud/volumes/domain.py +++ b/hcloud/volumes/domain.py @@ -45,7 +45,7 @@ class Volume(BaseDomain, DomainIdentityMixin): STATUS_AVAILABLE = "available" """Volume Status available""" - __fields__ = ( + __api_properties__ = ( "id", "name", "server", @@ -58,7 +58,7 @@ class Volume(BaseDomain, DomainIdentityMixin): "status", "created", ) - __slots__ = __fields__ + __slots__ = __api_properties__ def __init__( self, @@ -98,8 +98,8 @@ class CreateVolumeResponse(BaseDomain): List of actions that are performed after the creation, like attaching to a server """ - __fields__ = ("volume", "action", "next_actions") - __slots__ = __fields__ + __api_properties__ = ("volume", "action", "next_actions") + __slots__ = __api_properties__ def __init__( self, diff --git a/tests/unit/core/test_client.py b/tests/unit/core/test_client.py index 5c9cff4..3155eed 100644 --- a/tests/unit/core/test_client.py +++ b/tests/unit/core/test_client.py @@ -13,8 +13,8 @@ class TestBoundModelBase: @pytest.fixture() def bound_model_class(self): class Model(BaseDomain): - __fields__ = ("id", "name", "description") - __slots__ = __fields__ + __api_properties__ = ("id", "name", "description") + __slots__ = __api_properties__ def __init__(self, id, name="", description=""): self.id = id diff --git a/tests/unit/core/test_domain.py b/tests/unit/core/test_domain.py index 3ff33ba..d5e588f 100644 --- a/tests/unit/core/test_domain.py +++ b/tests/unit/core/test_domain.py @@ -42,8 +42,8 @@ def test_parse_meta_json_ok(self): class SomeDomain(BaseDomain, DomainIdentityMixin): - __fields__ = ("id", "name") - __slots__ = __fields__ + __api_properties__ = ("id", "name") + __slots__ = __api_properties__ def __init__(self, id=None, name=None): self.id = id @@ -87,8 +87,8 @@ def test_has_id_or_name_exception(self, other, expected): class ActionDomain(BaseDomain, DomainIdentityMixin): - __fields__ = ("id", "name", "started") - __slots__ = __fields__ + __api_properties__ = ("id", "name", "started") + __slots__ = __api_properties__ def __init__(self, id, name="name1", started=None): self.id = id @@ -97,8 +97,8 @@ def __init__(self, id, name="name1", started=None): class SomeOtherDomain(BaseDomain): - __fields__ = ("id", "name", "child") - __slots__ = __fields__ + __api_properties__ = ("id", "name", "child") + __slots__ = __api_properties__ def __init__(self, id=None, name=None, child=None): self.id = id