1
1
from linode_api4 .errors import UnexpectedResponseError
2
2
from linode_api4 .groups import Group
3
3
from linode_api4 .objects import (
4
- CreateToken ,
5
- Dashboard ,
6
- DashboardByService ,
7
- MetricDefinition ,
8
- MonitorServiceSupported ,
9
- ServiceDetails ,
4
+ MonitorDashboard ,
5
+ MonitorMetricsDefinition ,
6
+ MonitorService ,
7
+ MonitorServiceToken ,
10
8
)
11
9
12
10
13
11
class MonitorGroup (Group ):
14
12
"""
15
- Encapsulates Monitor-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.monitor.dashboards() # use the LKEGroup
13
+ Encapsulates Monitor-related methods of the :any:`LinodeClient`.
21
14
22
15
This group contains all features beneath the `/monitor` group in the API v4.
23
16
"""
24
17
25
- def dashboards (self , * filters ):
18
+ def list_monitor_dashboards (self , * filters ) -> list [ MonitorDashboard ] :
26
19
"""
27
- Returns a list of dashboards on your account.
20
+ Returns a list of dashboards.
21
+
22
+ dashboards = client.monitor_service.list_monitor_dashboards()
23
+ dashboard = client.load(Dashboard, 1)
28
24
29
25
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
30
26
@@ -37,34 +33,41 @@ def dashboards(self, *filters):
37
33
:returns: A list of Dashboards.
38
34
:rtype: PaginatedList of Dashboard
39
35
"""
40
- return self .client ._get_and_filter (Dashboard , * filters )
41
36
42
- def dashboards_by_service (self , service_type : str , * filters ):
43
- """
44
- Returns a dashboards on your account based on the service passed.
37
+ return self .client ._get_and_filter (MonitorDashboard , * filters )
45
38
39
+ def list_dashboards_by_service (self , service_type : str , * filters ) -> list [MonitorDashboard ]:
40
+ """
41
+ Returns a list of dashboards for a particular service.
42
+
43
+ dashboard_by_service = client.monitor_service.list_dashboards_by_service(service_type="dbaas")
44
+
46
45
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
47
46
48
47
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards
49
48
49
+ :param service_type: The service type to get dashboards for.
50
+ :type service_type: str
50
51
:param filters: Any number of filters to apply to this query.
51
52
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
52
53
for more details on filtering.
53
54
54
- :returns: A Dashboards filtered by Service Type.
55
+ :returns: Dashboards filtered by Service Type.
55
56
:rtype: PaginatedList of the Dashboards
56
57
"""
57
58
58
59
return self .client ._get_and_filter (
59
- DashboardByService ,
60
+ MonitorDashboard ,
60
61
* filters ,
61
62
endpoint = f"/monitor/services/{ service_type } /dashboards" ,
62
63
)
63
64
64
- def supported_services (self , * filters ):
65
+ def list_supported_services (self , * filters ) -> list [ MonitorService ] :
65
66
"""
66
67
Returns a list of services supported by ACLP.
67
68
69
+ supported_services = client.monitor_service.list_supported_services()
70
+
68
71
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
69
72
70
73
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
@@ -74,63 +77,74 @@ def supported_services(self, *filters):
74
77
for more details on filtering.
75
78
76
79
:returns: A list of Supported Services
77
- :rtype: PaginatedList of the Dashboards
80
+ :rtype: PaginatedList of Services
78
81
"""
79
82
80
- return self .client ._get_and_filter (MonitorServiceSupported , * filters )
83
+ return self .client ._get_and_filter (MonitorService , * filters )
81
84
82
- def details_by_service (self , service_type : str , * filters ):
85
+ def list_service_by_type (self , service_type : str , * filters ) -> list [ MonitorService ] :
83
86
"""
84
- Returns a details about a particular service.
87
+ Lists monitor services by a given service_type
85
88
89
+ service_details = client.monitor_service.list_service_by_type(service_type="dbaas")
90
+
86
91
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
87
-
92
+
88
93
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
89
-
94
+
95
+ :param service_type: The service type to get details for.
96
+ :type service_type: str
90
97
:param filters: Any number of filters to apply to this query.
91
98
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
92
99
for more details on filtering.
93
-
94
- :returns: Details about a Supported Services
95
- :rtype: PaginatedList of the Service
100
+
101
+ :returns: Lists monitor services by a given service_type
102
+ :rtype: PaginatedList of the Services
96
103
"""
97
104
return self .client ._get_and_filter (
98
- ServiceDetails ,
105
+ MonitorService ,
99
106
* filters ,
100
107
endpoint = f"/monitor/services/{ service_type } " ,
101
108
)
102
109
103
- def metric_definitions (self , service_type : str , * filters ):
110
+
111
+ def list_metric_definitions (self , service_type : str , * filters ) -> list [MonitorMetricsDefinition ]:
104
112
"""
105
113
Returns metrics for a specific service type.
106
114
115
+ metrics = client.monitor_service.list_metric_definitions(service_type="dbaas")
107
116
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
108
117
109
118
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
110
119
120
+ :param service_type: The service type to get metrics for.
121
+ :type service_type: str
111
122
:param filters: Any number of filters to apply to this query.
112
123
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
113
124
for more details on filtering.
114
125
115
- :returns: Returns a List of metrics for a service
126
+ :returns: Returns a List of metrics for a service
116
127
:rtype: PaginatedList of metrics
117
128
"""
118
129
return self .client ._get_and_filter (
119
- MetricDefinition ,
130
+ MonitorMetricsDefinition ,
120
131
* filters ,
121
132
endpoint = f"/monitor/services/{ service_type } /metric-definitions" ,
122
133
)
123
134
124
- def create_token (self , service_type : str , entity_ids : list , * filters ) :
135
+ def create_token (self , service_type : str , entity_ids : list ) -> MonitorServiceToken :
125
136
"""
126
137
Returns a JWE Token for a specific service type.
138
+ token = client.monitor_service.create_token(service_type="dbaas", entity_ids=[1234])
127
139
128
140
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
129
141
130
142
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
131
- :param filters: Any number of filters to apply to this query.
132
- See :doc:`Filtering Collections</linode_api4/objects/filtering>`
133
- for more details on filtering.
143
+
144
+ :param service_type: The service type to create token for.
145
+ :type service_type: str
146
+ :param entity_ids: The list of entity IDs for which the token is valid.
147
+ :type entity_ids: list of int
134
148
135
149
:returns: Returns a token for a service
136
150
:rtype: str
@@ -146,4 +160,5 @@ def create_token(self, service_type: str, entity_ids: list, *filters):
146
160
raise UnexpectedResponseError (
147
161
"Unexpected response when creating token!" , json = result
148
162
)
149
- return CreateToken (self .client , result ["token" ], result )
163
+ return MonitorServiceToken (token = result ["token" ])
164
+
0 commit comments