From 8ae0bc6e032440538f3aeb2222a9bee34adab04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Thu, 11 May 2023 13:28:47 +0200 Subject: [PATCH] feat(server_type): add field for included traffic (#185) Field was recently added to the API: https://docs.hetzner.cloud/#server-types --- hcloud/server_types/domain.py | 7 ++++++- tests/unit/server_types/conftest.py | 4 ++++ tests/unit/server_types/test_client.py | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hcloud/server_types/domain.py b/hcloud/server_types/domain.py index 0b0891e..5293b8d 100644 --- a/hcloud/server_types/domain.py +++ b/hcloud/server_types/domain.py @@ -23,9 +23,11 @@ class ServerType(BaseDomain, DomainIdentityMixin): :param cpu_type: string Type of cpu. Choices: `shared`, `dedicated` :param architecture: string - Architecture of cpu. Choices: `x86`, `arm` + Architecture of cpu. Choices: `x86`, `arm` :param deprecated: bool True if server type is deprecated + :param included_traffic: int + Free traffic per month in bytes """ __slots__ = ( @@ -40,6 +42,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): "cpu_type", "architecture", "deprecated", + "included_traffic", ) def __init__( @@ -55,6 +58,7 @@ def __init__( cpu_type=None, architecture=None, deprecated=None, + included_traffic=None, ): self.id = id self.name = name @@ -67,3 +71,4 @@ def __init__( self.cpu_type = cpu_type self.architecture = architecture self.deprecated = deprecated + self.included_traffic = included_traffic diff --git a/tests/unit/server_types/conftest.py b/tests/unit/server_types/conftest.py index 0588252..559e8d2 100644 --- a/tests/unit/server_types/conftest.py +++ b/tests/unit/server_types/conftest.py @@ -27,6 +27,7 @@ def server_type_response(): "storage_type": "local", "cpu_type": "shared", "architecture": "x86", + "included_traffic": 21990232555520, } } @@ -58,6 +59,7 @@ def two_server_types_response(): "storage_type": "local", "cpu_type": "shared", "architecture": "x86", + "included_traffic": 21990232555520, }, { "id": 2, @@ -93,6 +95,7 @@ def two_server_types_response(): "storage_type": "local", "cpu_type": "shared", "architecture": "x86", + "included_traffic": 21990232555520, }, ] } @@ -125,6 +128,7 @@ def one_server_types_response(): "storage_type": "local", "cpu_type": "shared", "architecture": "x86", + "included_traffic": 21990232555520, } ] } diff --git a/tests/unit/server_types/test_client.py b/tests/unit/server_types/test_client.py index 6ddaba1..c3fabbc 100644 --- a/tests/unit/server_types/test_client.py +++ b/tests/unit/server_types/test_client.py @@ -24,6 +24,7 @@ def test_bound_server_type_init(self, server_type_response): assert bound_server_type.storage_type == "local" assert bound_server_type.cpu_type == "shared" assert bound_server_type.architecture == "x86" + assert bound_server_type.included_traffic == 21990232555520 class TestServerTypesClient(object):