From 1b9e133d5ab6b3b296df10fdf3a6fb587404ba34 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 23 Jul 2024 12:35:04 +0200 Subject: [PATCH 1/2] feat: deprecate `ServerType` `included_traffic` property --- hcloud/server_types/domain.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/hcloud/server_types/domain.py b/hcloud/server_types/domain.py index 54f9bf4..1b21f7b 100644 --- a/hcloud/server_types/domain.py +++ b/hcloud/server_types/domain.py @@ -1,5 +1,7 @@ from __future__ import annotations +import warnings + from ..core import BaseDomain, DomainIdentityMixin from ..deprecation import DeprecationInfo @@ -36,7 +38,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): Free traffic per month in bytes """ - __api_properties__ = ( + __properties__ = ( "id", "name", "description", @@ -49,9 +51,15 @@ class ServerType(BaseDomain, DomainIdentityMixin): "architecture", "deprecated", "deprecation", + ) + __api_properties__ = ( + *__properties__, "included_traffic", ) - __slots__ = __api_properties__ + __slots__ = ( + *__properties__, + "_included_traffic", + ) def __init__( self, @@ -84,3 +92,24 @@ def __init__( DeprecationInfo.from_dict(deprecation) if deprecation is not None else None ) self.included_traffic = included_traffic + + @property + def included_traffic(self) -> int | None: + """ + .. deprecated:: 2.1.0 + The 'included_traffic' property is deprecated and will be set to 'None' on 5 August 2024. + Please refer to the 'prices' property instead. + See $LINK. + """ + warnings.warn( + "The 'included_traffic' property is deprecated and will be set to 'None' on 5 August 2024. " + "Please refer to the 'prices' property instead. " + "See $LINK.", + DeprecationWarning, + stacklevel=2, + ) + return self._included_traffic + + @included_traffic.setter + def included_traffic(self, value: int | None) -> None: + self._included_traffic = value From 5d4b3451884bd46eca53c1de949779c864e6b74a Mon Sep 17 00:00:00 2001 From: jo Date: Thu, 25 Jul 2024 13:09:23 +0200 Subject: [PATCH 2/2] update link --- hcloud/server_types/domain.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hcloud/server_types/domain.py b/hcloud/server_types/domain.py index 1b21f7b..d026f86 100644 --- a/hcloud/server_types/domain.py +++ b/hcloud/server_types/domain.py @@ -99,12 +99,13 @@ def included_traffic(self) -> int | None: .. deprecated:: 2.1.0 The 'included_traffic' property is deprecated and will be set to 'None' on 5 August 2024. Please refer to the 'prices' property instead. - See $LINK. + + See https://docs.hetzner.cloud/changelog#2024-07-25-cloud-api-returns-traffic-information-in-different-format. """ warnings.warn( "The 'included_traffic' property is deprecated and will be set to 'None' on 5 August 2024. " "Please refer to the 'prices' property instead. " - "See $LINK.", + "See https://docs.hetzner.cloud/changelog#2024-07-25-cloud-api-returns-traffic-information-in-different-format", DeprecationWarning, stacklevel=2, )