Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecate ServerType included_traffic property #423

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions hcloud/server_types/domain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import warnings

from ..core import BaseDomain, DomainIdentityMixin
from ..deprecation import DeprecationInfo

Expand Down Expand Up @@ -36,7 +38,7 @@ class ServerType(BaseDomain, DomainIdentityMixin):
Free traffic per month in bytes
"""

__api_properties__ = (
__properties__ = (
"id",
"name",
"description",
Expand All @@ -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,
Expand Down Expand Up @@ -84,3 +92,25 @@ 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 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 https://docs.hetzner.cloud/changelog#2024-07-25-cloud-api-returns-traffic-information-in-different-format",
DeprecationWarning,
stacklevel=2,
)
return self._included_traffic

@included_traffic.setter
def included_traffic(self, value: int | None) -> None:
self._included_traffic = value