Skip to content

Commit

Permalink
feat: prepare for iso deprecated field removal
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Oct 20, 2023
1 parent f1627d4 commit c4af68c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions hcloud/isos/domain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from dateutil.parser import isoparse
from datetime import datetime
from warnings import warn

from ..core import BaseDomain, DomainIdentityMixin
from ..deprecation import DeprecationInfo
Expand Down Expand Up @@ -32,7 +33,6 @@ class Iso(BaseDomain, DomainIdentityMixin):
"type",
"architecture",
"description",
"deprecated",
"deprecation",
)

Expand All @@ -43,15 +43,24 @@ def __init__(
type: str | None = None,
architecture: str | None = None,
description: str | None = None,
deprecated: str | None = None,
deprecated: str | None = None, # pylint: disable=unused-argument
deprecation: dict | None = None,
):
self.id = id
self.name = name
self.type = type
self.architecture = architecture
self.description = description
self.deprecated = isoparse(deprecated) if deprecated else None
self.deprecation = (
DeprecationInfo.from_dict(deprecation) if deprecation is not None else None
)

@property
def deprecated(self) -> datetime | None:
warn(
"The `deprecated` field is deprecated, please use the `deprecation` field instead.",
DeprecationWarning,
)
if self.deprecation is None:
return None
return self.deprecation.unavailable_after

0 comments on commit c4af68c

Please sign in to comment.