11from __future__ import annotations
22
3- from typing import TYPE_CHECKING , TypedDict
3+ import warnings
4+ from datetime import datetime
5+ from typing import TYPE_CHECKING , Any , TypedDict
46
57from ..core import BaseDomain , DomainIdentityMixin
8+ from ..deprecation import DeprecationInfo
69
710if TYPE_CHECKING :
811 from ..actions import BoundAction
@@ -52,8 +55,10 @@ class Image(BaseDomain, DomainIdentityMixin):
5255 Protection configuration for the image
5356 :param deprecated: datetime, None
5457 Point in time when the image is considered to be deprecated (in ISO-8601 format)
58+ :param deprecation:
59+ Describes wether the resources is deprecated.
5560 :param labels: Dict
56- User-defined labels (key-value pairs)
61+ User-defined labels (key-value pairs)
5762 """
5863
5964 __api_properties__ = (
@@ -73,11 +78,11 @@ class Image(BaseDomain, DomainIdentityMixin):
7378 "protection" ,
7479 "labels" ,
7580 "created" ,
76- "deprecated " ,
81+ "deprecation " ,
7782 )
7883 __slots__ = __api_properties__
7984
80- # pylint: disable=too-many-locals
85+ # pylint: disable=too-many-locals,unused-argument
8186 def __init__ (
8287 self ,
8388 id : int | None = None ,
@@ -87,7 +92,7 @@ def __init__(
8792 description : str | None = None ,
8893 image_size : int | None = None ,
8994 disk_size : int | None = None ,
90- deprecated : str | None = None ,
95+ deprecated : str | None = None , # Preserved for backward compatibility
9196 bound_to : Server | BoundServer | None = None ,
9297 os_flavor : str | None = None ,
9398 os_version : str | None = None ,
@@ -97,6 +102,7 @@ def __init__(
97102 protection : ImageProtection | None = None ,
98103 labels : dict [str , str ] | None = None ,
99104 status : str | None = None ,
105+ deprecation : dict [str , Any ] | None = None ,
100106 ):
101107 self .id = id
102108 self .name = name
@@ -105,7 +111,6 @@ def __init__(
105111 self .description = description
106112 self .image_size = image_size
107113 self .disk_size = disk_size
108- self .deprecated = self ._parse_datetime (deprecated )
109114 self .bound_to = bound_to
110115 self .os_flavor = os_flavor
111116 self .os_version = os_version
@@ -115,6 +120,27 @@ def __init__(
115120 self .protection = protection
116121 self .labels = labels
117122 self .status = status
123+ self .deprecation = (
124+ None if deprecation is None else DeprecationInfo .from_dict (deprecation )
125+ )
126+
127+ @property
128+ def deprecated (self ) -> datetime | None :
129+ """
130+ .. deprecated:: 2.24.0
131+ The 'deprecated' property is deprecated. Please use to the '.deprecation' property instead.
132+
133+ See https://docs.hetzner.cloud/changelog#2026-09-08-removing-the-deprecated-field.
134+ """
135+ warnings .warn (
136+ "The 'deprecated' property is deprecated. Please use to the '.deprecation' property instead. "
137+ "See https://docs.hetzner.cloud/changelog#2026-09-08-removing-the-deprecated-field." ,
138+ DeprecationWarning ,
139+ stacklevel = 2 ,
140+ )
141+ if self .deprecation is None :
142+ return None
143+ return self .deprecation .announced
118144
119145
120146class ImageProtection (TypedDict ):
0 commit comments