forked from linode/linode_api4-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregion.py
More file actions
77 lines (59 loc) · 2.12 KB
/
Copy pathregion.py
File metadata and controls
77 lines (59 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from dataclasses import dataclass
from typing import List, Optional
from linode_api4.errors import UnexpectedResponseError
from linode_api4.objects.base import Base, JSONObject, Property
@dataclass
class RegionPlacementGroupLimits(JSONObject):
"""
Represents the Placement Group limits for the current account
in a specific region.
"""
maximum_pgs_per_customer: int = 0
maximum_linodes_per_pg: int = 0
@dataclass
class RegionMonitors(JSONObject):
"""
Represents the monitor services available in a region.
Lists the services in this region that support metrics and alerts
use with Akamai Cloud Pulse (ACLP).
"""
alerts: Optional[list[str]] = None
metrics: Optional[list[str]] = None
class Region(Base):
"""
A Region. Regions correspond to individual data centers, each located in a different geographical area.
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-region
"""
api_endpoint = "/regions/{id}"
properties = {
"id": Property(identifier=True),
"country": Property(),
"capabilities": Property(unordered=True),
"status": Property(),
"resolvers": Property(),
"label": Property(),
"site_type": Property(),
"placement_group_limits": Property(
json_object=RegionPlacementGroupLimits
),
"monitors": Property(json_object=RegionMonitors),
}
@property
def availability(self) -> List["RegionAvailabilityEntry"]:
result = self._client.get(
f"{self.api_endpoint}/availability", model=self
)
if result is None:
raise UnexpectedResponseError(
"Expected availability data, got None."
)
return [RegionAvailabilityEntry.from_json(v) for v in result]
@dataclass
class RegionAvailabilityEntry(JSONObject):
"""
Represents the availability of a Linode type within a region.
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-region-availability
"""
region: Optional[str] = None
plan: Optional[str] = None
available: bool = False