|
17 | 17 | "DatacentersClient", |
18 | 18 | ] |
19 | 19 |
|
20 | | -with warnings.catch_warnings(): |
21 | | - warnings.filterwarnings("ignore", category=DeprecationWarning) |
22 | 20 |
|
23 | | - class BoundDatacenter(BoundModelBase[Datacenter], Datacenter): |
24 | | - """ |
25 | | - .. deprecated:: 2.22.0 |
26 | | - The bound datacenter class is deprecated and will be removed after the 2026-10-01. |
27 | | - See https://docs.hetzner.cloud/changelog#2026-06-02-datacenters-deprecated. |
28 | | - """ |
| 21 | +class BoundDatacenter(BoundModelBase[Datacenter], Datacenter): |
| 22 | + """ |
| 23 | + .. deprecated:: 2.22.0 |
| 24 | + The bound datacenter class is deprecated and will be removed after the 2026-10-01. |
| 25 | + See https://docs.hetzner.cloud/changelog#2026-06-02-datacenters-deprecated. |
| 26 | + """ |
29 | 27 |
|
30 | | - _client: DatacentersClient |
31 | | - |
32 | | - model = Datacenter |
33 | | - |
34 | | - def __init__(self, client: DatacentersClient, data: dict[str, Any]): |
35 | | - location = data.get("location") |
36 | | - if location is not None: |
37 | | - data["location"] = BoundLocation(client._parent.locations, location) |
38 | | - |
39 | | - server_types = data.get("server_types") |
40 | | - if server_types is not None: |
41 | | - available = [ |
42 | | - BoundServerType( |
43 | | - client._parent.server_types, {"id": server_type}, complete=False |
44 | | - ) |
45 | | - for server_type in server_types["available"] |
46 | | - ] |
47 | | - supported = [ |
48 | | - BoundServerType( |
49 | | - client._parent.server_types, {"id": server_type}, complete=False |
50 | | - ) |
51 | | - for server_type in server_types["supported"] |
52 | | - ] |
53 | | - available_for_migration = [ |
54 | | - BoundServerType( |
55 | | - client._parent.server_types, {"id": server_type}, complete=False |
56 | | - ) |
57 | | - for server_type in server_types["available_for_migration"] |
58 | | - ] |
59 | | - data["server_types"] = DatacenterServerTypes( |
60 | | - available=available, |
61 | | - supported=supported, |
62 | | - available_for_migration=available_for_migration, |
63 | | - ) |
| 28 | + _client: DatacentersClient |
| 29 | + |
| 30 | + model = Datacenter |
| 31 | + |
| 32 | + def __init__(self, client: DatacentersClient, data: dict[str, Any]): |
| 33 | + location = data.get("location") |
| 34 | + if location is not None: |
| 35 | + data["location"] = BoundLocation(client._parent.locations, location) |
64 | 36 |
|
65 | | - super().__init__(client, data) |
| 37 | + server_types = data.get("server_types") |
| 38 | + if server_types is not None: |
| 39 | + available = [ |
| 40 | + BoundServerType( |
| 41 | + client._parent.server_types, {"id": server_type}, complete=False |
| 42 | + ) |
| 43 | + for server_type in server_types["available"] |
| 44 | + ] |
| 45 | + supported = [ |
| 46 | + BoundServerType( |
| 47 | + client._parent.server_types, {"id": server_type}, complete=False |
| 48 | + ) |
| 49 | + for server_type in server_types["supported"] |
| 50 | + ] |
| 51 | + available_for_migration = [ |
| 52 | + BoundServerType( |
| 53 | + client._parent.server_types, {"id": server_type}, complete=False |
| 54 | + ) |
| 55 | + for server_type in server_types["available_for_migration"] |
| 56 | + ] |
| 57 | + data["server_types"] = DatacenterServerTypes( |
| 58 | + available=available, |
| 59 | + supported=supported, |
| 60 | + available_for_migration=available_for_migration, |
| 61 | + ) |
| 62 | + |
| 63 | + super().__init__(client, data) |
66 | 64 |
|
67 | 65 |
|
68 | 66 | class DatacentersPageResult(NamedTuple): |
|
0 commit comments