Skip to content

Commit 3c2bea4

Browse files
committed
init
1 parent 7b7f647 commit 3c2bea4

File tree

8 files changed

+500
-163
lines changed

8 files changed

+500
-163
lines changed

linode_api4/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# isort: skip_file
22
from linode_api4.objects import *
33
from linode_api4.errors import ApiError, UnexpectedResponseError
4-
from linode_api4.linode_client import LinodeClient
4+
from linode_api4.linode_client import LinodeClient, MonitorClient
55
from linode_api4.login_client import LinodeLoginClient, OAuthScopes
66
from linode_api4.paginated_list import PaginatedList
77
from linode_api4.polling import EventPoller

linode_api4/groups/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .lke_tier import *
1212
from .longview import *
1313
from .monitor import *
14+
from .monitor_api import *
1415
from .networking import *
1516
from .nodebalancer import *
1617
from .object_storage import *

linode_api4/groups/monitor_api.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from typing import Optional
2+
3+
from linode_api4.groups import Group
4+
from linode_api4.objects.monitor_api import EntityMetrics
5+
6+
7+
class MetricsGroup(Group):
8+
"""
9+
Encapsulates Monitor-related methods of the :any:`MonitorClient`.
10+
11+
This group contains all features related to metrics in the API monitor-api.
12+
"""
13+
def fetch_metrics(
14+
self,
15+
service_type: str,
16+
entity_ids: list,
17+
**kwargs,
18+
) -> Optional[EntityMetrics]:
19+
"""
20+
Returns metrics information for the individual entities within a specific service type.
21+
22+
API documentation: https://techdocs.akamai.com/linode-api/reference/post-read-metric
23+
24+
:param service_type: The service being monitored.
25+
Currently, only the Managed Databases (dbaas) service type is supported.
26+
:type service_type: str
27+
28+
:param entity_ids: The id for each individual entity from a service_type.
29+
:type entity_ids: list
30+
31+
:param kwargs: Any other arguments accepted by the api. Please refer to the API documentation for full info.
32+
33+
:returns: Service metrics requested.
34+
:rtype: EntityMetrics or None
35+
"""
36+
37+
params = {
38+
"entity_ids": entity_ids
39+
}
40+
41+
params.update(kwargs)
42+
43+
result = self.client.post(
44+
f"/monitor/services/{service_type}/metrics", data=params
45+
)
46+
47+
return EntityMetrics.from_json(result)

0 commit comments

Comments
 (0)