Skip to content

Commit 19b8779

Browse files
authored
Add included_traffic, outgoing_traffic and ingoing_traffic properties to Load Balancer domain (#97)
1 parent 0dbfa8a commit 19b8779

4 files changed

Lines changed: 39 additions & 4 deletions

File tree

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
=======
22
History
33
=======
4+
master (XXXX-XX-XX)
5+
--------------------
6+
7+
* Add `included_traffic`, `outgoing_traffic` and `ingoing_traffic` properties to Load Balancer domain
48

59
v1.8.2 (2020-07-20)
610
--------------------

hcloud/load_balancers/domain.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ class LoadBalancer(BaseDomain):
3131
The targets the LoadBalancer is currently serving
3232
:param load_balancer_type: LoadBalancerType
3333
The type of the Load Balancer
34-
35-
34+
:param outgoing_traffic: int, None
35+
Outbound Traffic for the current billing period in bytes
36+
:param ingoing_traffic: int, None
37+
Inbound Traffic for the current billing period in bytes
38+
:param included_traffic: int
39+
Free Traffic for the current billing period in bytes
3640
"""
3741

3842
__slots__ = (
@@ -47,7 +51,10 @@ class LoadBalancer(BaseDomain):
4751
"protection",
4852
"labels",
4953
"targets",
50-
"created"
54+
"created",
55+
"outgoing_traffic",
56+
"ingoing_traffic",
57+
"included_traffic",
5158
)
5259

5360
def __init__(
@@ -63,7 +70,10 @@ def __init__(
6370
protection=None,
6471
labels=None,
6572
targets=None,
66-
created=None
73+
created=None,
74+
outgoing_traffic=None,
75+
ingoing_traffic=None,
76+
included_traffic=None,
6777
):
6878
self.id = id
6979
self.name = name
@@ -77,6 +87,9 @@ def __init__(
7787
self.targets = targets
7888
self.protection = protection
7989
self.labels = labels
90+
self.outgoing_traffic = outgoing_traffic
91+
self.ingoing_traffic = ingoing_traffic
92+
self.included_traffic = included_traffic
8093

8194

8295
class LoadBalancerService(BaseDomain):

tests/unit/load_balancers/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def response_load_balancer():
4747
},
4848
"labels": {},
4949
"created": "2016-01-30T23:50:00+00:00",
50+
"outgoing_traffic": 123456,
51+
"ingoing_traffic": 123456,
52+
"included_traffic": 654321,
5053
"services": [
5154
{
5255
"protocol": "https",
@@ -136,6 +139,9 @@ def response_create_load_balancer():
136139
"algorithm": {
137140
"type": "round_robin"
138141
},
142+
"outgoing_traffic": 123456,
143+
"ingoing_traffic": 123456,
144+
"included_traffic": 654321,
139145
"services": [
140146
{
141147
"protocol": "https",
@@ -219,6 +225,9 @@ def response_update_load_balancer():
219225
"longitude": 12.370071,
220226
"network_zone": "eu-central"
221227
},
228+
"outgoing_traffic": 123456,
229+
"ingoing_traffic": 123456,
230+
"included_traffic": 654321,
222231
"load_balancer_type": {
223232
"id": 1,
224233
"name": "lb11",
@@ -324,6 +333,9 @@ def response_simple_load_balancers():
324333
"longitude": 12.370071,
325334
"network_zone": "eu-central"
326335
},
336+
"outgoing_traffic": 123456,
337+
"ingoing_traffic": 123456,
338+
"included_traffic": 654321,
327339
"load_balancer_type": {
328340
"id": 1,
329341
"name": "lb11",
@@ -448,6 +460,9 @@ def response_simple_load_balancers():
448460
},
449461
"labels": {},
450462
"created": "2016-01-30T23:50:00+00:00",
463+
"outgoing_traffic": 123456,
464+
"ingoing_traffic": 123456,
465+
"included_traffic": 654321,
451466
"services": [
452467
{
453468
"protocol": "https",

tests/unit/load_balancers/test_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ def test_get_by_id(self, load_balancers_client, response_load_balancer):
220220
assert bound_load_balancer._client is load_balancers_client
221221
assert bound_load_balancer.id == 4711
222222
assert bound_load_balancer.name == "Web Frontend"
223+
assert bound_load_balancer.outgoing_traffic == 123456
224+
assert bound_load_balancer.ingoing_traffic == 123456
225+
assert bound_load_balancer.included_traffic == 654321
223226

224227
@pytest.mark.parametrize(
225228
"params",

0 commit comments

Comments
 (0)