Skip to content

Commit 3d56ac5

Browse files
authored
feat: deprecate ServerType included_traffic property (#423)
The API has been updated to provide a better insight and more flexibility for displaying the pricing of traffic for servers and load balancers. The old fields are deprecated and will be set to `None` in the API on 2024-08-05. You can learn more about this change in [our changelog](https://docs.hetzner.cloud/changelog#2024-07-25-cloud-api-returns-traffic-information-in-different-format).
1 parent f306073 commit 3d56ac5

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

hcloud/server_types/domain.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import warnings
4+
35
from ..core import BaseDomain, DomainIdentityMixin
46
from ..deprecation import DeprecationInfo
57

@@ -36,7 +38,7 @@ class ServerType(BaseDomain, DomainIdentityMixin):
3638
Free traffic per month in bytes
3739
"""
3840

39-
__api_properties__ = (
41+
__properties__ = (
4042
"id",
4143
"name",
4244
"description",
@@ -49,9 +51,15 @@ class ServerType(BaseDomain, DomainIdentityMixin):
4951
"architecture",
5052
"deprecated",
5153
"deprecation",
54+
)
55+
__api_properties__ = (
56+
*__properties__,
5257
"included_traffic",
5358
)
54-
__slots__ = __api_properties__
59+
__slots__ = (
60+
*__properties__,
61+
"_included_traffic",
62+
)
5563

5664
def __init__(
5765
self,
@@ -84,3 +92,25 @@ def __init__(
8492
DeprecationInfo.from_dict(deprecation) if deprecation is not None else None
8593
)
8694
self.included_traffic = included_traffic
95+
96+
@property
97+
def included_traffic(self) -> int | None:
98+
"""
99+
.. deprecated:: 2.1.0
100+
The 'included_traffic' property is deprecated and will be set to 'None' on 5 August 2024.
101+
Please refer to the 'prices' property instead.
102+
103+
See https://docs.hetzner.cloud/changelog#2024-07-25-cloud-api-returns-traffic-information-in-different-format.
104+
"""
105+
warnings.warn(
106+
"The 'included_traffic' property is deprecated and will be set to 'None' on 5 August 2024. "
107+
"Please refer to the 'prices' property instead. "
108+
"See https://docs.hetzner.cloud/changelog#2024-07-25-cloud-api-returns-traffic-information-in-different-format",
109+
DeprecationWarning,
110+
stacklevel=2,
111+
)
112+
return self._included_traffic
113+
114+
@included_traffic.setter
115+
def included_traffic(self, value: int | None) -> None:
116+
self._included_traffic = value

0 commit comments

Comments
 (0)