1+ from linode_api4 .errors import UnexpectedResponseError
2+ from linode_api4 .groups import Group
3+ from linode_api4 .objects import (
4+ CreateToken ,
5+ DashboardByService ,
6+ ServiceDetails ,
7+ Dashboard ,
8+ MonitorServiceSupported ,
9+ MetricDefinition ,
10+ DashboardsByID ,
11+ )
12+
13+ class MonitorGroup (Group ):
14+ """
15+ Encapsulates LKE-related methods of the :any:`LinodeClient`. This
16+ should not be instantiated on its own, but should instead be used through
17+ an instance of :any:`LinodeClient`::
18+
19+ client = LinodeClient(token)
20+ instances = client.lke.clusters() # use the LKEGroup
21+
22+ This group contains all features beneath the `/lke` group in the API v4.
23+ """
24+
25+ def dashboards (self , * filters ):
26+ """
27+ Returns a list of dashboards on your account.
28+
29+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
30+
31+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
32+
33+ :param filters: Any number of filters to apply to this query.
34+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
35+ for more details on filtering.
36+
37+ :returns: A list of Dashboards.
38+ :rtype: PaginatedList of Dashboard
39+ """
40+ return self .client ._get_and_filter (Dashboard , * filters )
41+
42+ def dashboard_by_ID (self , dashboard_id : int , * filters ):
43+ """
44+ Returns a dashboards on your account based on the ID passed.
45+
46+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
47+
48+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards-by-id
49+
50+ :param filters: Any number of filters to apply to this query.
51+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
52+ for more details on filtering.
53+
54+ :returns: A Dashboards.
55+ :rtype: PaginatedList of the Dashboard
56+ """
57+ result = self .client .get (f"/monitor/dashboards/{ dashboard_id } " )
58+
59+ if not "id" in result :
60+ raise UnexpectedResponseError (
61+ "Unexpected response when getting Dashboard!" , json = result
62+ )
63+ return DashboardsByID (self .client , result ["id" ], result )
64+
65+
66+ def dashboard_by_service (self , service_type : str ,* filters ):
67+ """
68+ Returns a dashboards on your account based on the service passed.
69+
70+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
71+
72+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards
73+
74+ :param filters: Any number of filters to apply to this query.
75+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
76+ for more details on filtering.
77+
78+ :returns: A Dashboards filtered by Service Type.
79+ :rtype: PaginatedList of the Dashboards
80+ """
81+
82+ return self .client ._get_and_filter (
83+ DashboardByService ,
84+ * filters ,
85+ endpoint = f"/monitor/services/{ service_type } /dashboards" ,
86+ )
87+
88+
89+ def supported_services (self , * filters ):
90+ """
91+ Returns a list of services supported by ACLP.
92+
93+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
94+
95+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
96+
97+ :param filters: Any number of filters to apply to this query.
98+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
99+ for more details on filtering.
100+
101+ :returns: A list of Supported Services
102+ :rtype: PaginatedList of the Dashboards
103+ """
104+
105+ return self .client ._get_and_filter (MonitorServiceSupported , * filters )
106+
107+ def details_by_service (self , service_type : str ,* filters ):
108+ """
109+ Returns a details about a particular service.
110+
111+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
112+
113+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
114+
115+ :param filters: Any number of filters to apply to this query.
116+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
117+ for more details on filtering.
118+
119+ :returns: Details about a Supported Services
120+ :rtype: PaginatedList of the Service
121+ """
122+ return self .client ._get_and_filter (
123+ ServiceDetails ,
124+ * filters ,
125+ endpoint = f"/monitor/services/{ service_type } " ,
126+ )
127+
128+ def metric_definitions (self , service_type : str ,* filters ):
129+ """
130+ Returns metrics for a specific service type.
131+
132+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
133+
134+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
135+
136+ :param filters: Any number of filters to apply to this query.
137+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
138+ for more details on filtering.
139+
140+ :returns: Returns a List of metrics for a service
141+ :rtype: PaginatedList of metrics
142+ """
143+ return self .client ._get_and_filter (
144+ MetricDefinition ,
145+ * filters ,
146+ endpoint = f"/monitor/services/{ service_type } /metric-definitions" ,
147+ )
148+
149+ def create_token (self , service_type : str , entity_ids : list , * filters ):
150+ """
151+ Returns a JWE Token for a specific service type.
152+
153+ .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
154+
155+ API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
156+ :param filters: Any number of filters to apply to this query.
157+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`
158+ for more details on filtering.
159+
160+ :returns: Returns a token for a service
161+ :rtype: str
162+ """
163+
164+ params = {"entity_ids" : entity_ids }
165+
166+ result = self .client .post (f"/monitor/services/{ service_type } /token" , data = params )
167+
168+ if "token" not in result :
169+ raise UnexpectedResponseError (
170+ "Unexpected response when creating token!" , json = result
171+ )
172+ return CreateToken (self .client , result ["token" ], result )
173+
174+
175+
176+
177+
178+
179+
180+
181+
182+
0 commit comments