|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import warnings |
3 | 4 | from typing import Any, NamedTuple |
4 | 5 |
|
5 | 6 | from ..core import BoundModelBase, Meta, ResourceClientBase |
|
13 | 14 | "DatacentersClient", |
14 | 15 | ] |
15 | 16 |
|
| 17 | +with warnings.catch_warnings(): |
| 18 | + warnings.filterwarnings("ignore", category=DeprecationWarning) |
16 | 19 |
|
17 | | -class BoundDatacenter(BoundModelBase[Datacenter], Datacenter): |
18 | | - _client: DatacentersClient |
19 | | - |
20 | | - model = Datacenter |
21 | | - |
22 | | - def __init__(self, client: DatacentersClient, data: dict[str, Any]): |
23 | | - location = data.get("location") |
24 | | - if location is not None: |
25 | | - data["location"] = BoundLocation(client._parent.locations, location) |
| 20 | + class BoundDatacenter(BoundModelBase[Datacenter], Datacenter): |
| 21 | + """ |
| 22 | + .. deprecated:: 2.22.0 |
| 23 | + The bound datacenter class is deprecated and will be removed after the 2026-10-01. |
| 24 | + See https://docs.hetzner.cloud/changelog#2026-06-02-datacenters-deprecated. |
| 25 | + """ |
26 | 26 |
|
27 | | - server_types = data.get("server_types") |
28 | | - if server_types is not None: |
29 | | - available = [ |
30 | | - BoundServerType( |
31 | | - client._parent.server_types, {"id": server_type}, complete=False |
| 27 | + _client: DatacentersClient |
| 28 | + |
| 29 | + model = Datacenter |
| 30 | + |
| 31 | + def __init__(self, client: DatacentersClient, data: dict[str, Any]): |
| 32 | + location = data.get("location") |
| 33 | + if location is not None: |
| 34 | + data["location"] = BoundLocation(client._parent.locations, location) |
| 35 | + |
| 36 | + server_types = data.get("server_types") |
| 37 | + if server_types is not None: |
| 38 | + available = [ |
| 39 | + BoundServerType( |
| 40 | + client._parent.server_types, {"id": server_type}, complete=False |
| 41 | + ) |
| 42 | + for server_type in server_types["available"] |
| 43 | + ] |
| 44 | + supported = [ |
| 45 | + BoundServerType( |
| 46 | + client._parent.server_types, {"id": server_type}, complete=False |
| 47 | + ) |
| 48 | + for server_type in server_types["supported"] |
| 49 | + ] |
| 50 | + available_for_migration = [ |
| 51 | + BoundServerType( |
| 52 | + client._parent.server_types, {"id": server_type}, complete=False |
| 53 | + ) |
| 54 | + for server_type in server_types["available_for_migration"] |
| 55 | + ] |
| 56 | + data["server_types"] = DatacenterServerTypes( |
| 57 | + available=available, |
| 58 | + supported=supported, |
| 59 | + available_for_migration=available_for_migration, |
32 | 60 | ) |
33 | | - for server_type in server_types["available"] |
34 | | - ] |
35 | | - supported = [ |
36 | | - BoundServerType( |
37 | | - client._parent.server_types, {"id": server_type}, complete=False |
38 | | - ) |
39 | | - for server_type in server_types["supported"] |
40 | | - ] |
41 | | - available_for_migration = [ |
42 | | - BoundServerType( |
43 | | - client._parent.server_types, {"id": server_type}, complete=False |
44 | | - ) |
45 | | - for server_type in server_types["available_for_migration"] |
46 | | - ] |
47 | | - data["server_types"] = DatacenterServerTypes( |
48 | | - available=available, |
49 | | - supported=supported, |
50 | | - available_for_migration=available_for_migration, |
51 | | - ) |
52 | 61 |
|
53 | | - super().__init__(client, data) |
| 62 | + super().__init__(client, data) |
54 | 63 |
|
55 | 64 |
|
56 | 65 | class DatacentersPageResult(NamedTuple): |
| 66 | + """ |
| 67 | + .. deprecated:: 2.22.0 |
| 68 | + The datacenters page result class is deprecated and will be removed after the 2026-10-01. |
| 69 | + See https://docs.hetzner.cloud/changelog#2026-06-02-datacenters-deprecated. |
| 70 | + """ |
| 71 | + |
57 | 72 | datacenters: list[BoundDatacenter] |
58 | 73 | meta: Meta |
59 | 74 |
|
60 | 75 |
|
| 76 | +@warnings.deprecated( |
| 77 | + "The datacenters client class is deprecated and will be removed after the 2026-10-01. " |
| 78 | + "See https://docs.hetzner.cloud/changelog#2026-06-02-datacenters-deprecated.", |
| 79 | +) |
61 | 80 | class DatacentersClient(ResourceClientBase): |
| 81 | + """ |
| 82 | + .. deprecated:: 2.22.0 |
| 83 | + The datacenters client class is deprecated and will be removed after the 2026-10-01. |
| 84 | + See https://docs.hetzner.cloud/changelog#2026-06-02-datacenters-deprecated. |
| 85 | + """ |
| 86 | + |
62 | 87 | _base_url = "/datacenters" |
63 | 88 |
|
64 | 89 | def get_by_id(self, id: int) -> BoundDatacenter: |
|
0 commit comments