Skip to content

Commit 8ae0bc6

Browse files
authored
feat(server_type): add field for included traffic (#185)
Field was recently added to the API: https://docs.hetzner.cloud/#server-types
1 parent 9d5afe0 commit 8ae0bc6

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

hcloud/server_types/domain.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ class ServerType(BaseDomain, DomainIdentityMixin):
2323
:param cpu_type: string
2424
Type of cpu. Choices: `shared`, `dedicated`
2525
:param architecture: string
26-
Architecture of cpu. Choices: `x86`, `arm`
26+
Architecture of cpu. Choices: `x86`, `arm`
2727
:param deprecated: bool
2828
True if server type is deprecated
29+
:param included_traffic: int
30+
Free traffic per month in bytes
2931
"""
3032

3133
__slots__ = (
@@ -40,6 +42,7 @@ class ServerType(BaseDomain, DomainIdentityMixin):
4042
"cpu_type",
4143
"architecture",
4244
"deprecated",
45+
"included_traffic",
4346
)
4447

4548
def __init__(
@@ -55,6 +58,7 @@ def __init__(
5558
cpu_type=None,
5659
architecture=None,
5760
deprecated=None,
61+
included_traffic=None,
5862
):
5963
self.id = id
6064
self.name = name
@@ -67,3 +71,4 @@ def __init__(
6771
self.cpu_type = cpu_type
6872
self.architecture = architecture
6973
self.deprecated = deprecated
74+
self.included_traffic = included_traffic

tests/unit/server_types/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def server_type_response():
2727
"storage_type": "local",
2828
"cpu_type": "shared",
2929
"architecture": "x86",
30+
"included_traffic": 21990232555520,
3031
}
3132
}
3233

@@ -58,6 +59,7 @@ def two_server_types_response():
5859
"storage_type": "local",
5960
"cpu_type": "shared",
6061
"architecture": "x86",
62+
"included_traffic": 21990232555520,
6163
},
6264
{
6365
"id": 2,
@@ -93,6 +95,7 @@ def two_server_types_response():
9395
"storage_type": "local",
9496
"cpu_type": "shared",
9597
"architecture": "x86",
98+
"included_traffic": 21990232555520,
9699
},
97100
]
98101
}
@@ -125,6 +128,7 @@ def one_server_types_response():
125128
"storage_type": "local",
126129
"cpu_type": "shared",
127130
"architecture": "x86",
131+
"included_traffic": 21990232555520,
128132
}
129133
]
130134
}

tests/unit/server_types/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_bound_server_type_init(self, server_type_response):
2424
assert bound_server_type.storage_type == "local"
2525
assert bound_server_type.cpu_type == "shared"
2626
assert bound_server_type.architecture == "x86"
27+
assert bound_server_type.included_traffic == 21990232555520
2728

2829

2930
class TestServerTypesClient(object):

0 commit comments

Comments
 (0)