1
+ from typing import Optional
2
+
3
+ from linode_api4 import (
4
+ PaginatedList ,
5
+ )
1
6
from linode_api4 .errors import UnexpectedResponseError
2
7
from linode_api4 .groups import Group
3
8
from linode_api4 .objects import (
@@ -15,100 +20,75 @@ class MonitorGroup(Group):
15
20
This group contains all features beneath the `/monitor` group in the API v4.
16
21
"""
17
22
18
- def dashboards (self , * filters ) -> list [MonitorDashboard ]:
23
+ def dashboards (
24
+ self , service_type : Optional [str ] = None , * filters
25
+ ) -> PaginatedList :
19
26
"""
20
- Returns a list of dashboards.
27
+ Returns a list of dashboards. If `service_type` is provided, it fetches dashboards
28
+ for the specific service type. If None, it fetches all dashboards.
21
29
22
- dashboards = client.monitor_service.list_monitor_dashboards ()
30
+ dashboards = client.monitor_service.dashboards ()
23
31
dashboard = client.load(MonitorDashboard, 1)
32
+ dashboards_by_service = client.monitor_service.dashboards(service_type="dbaas")
24
33
25
34
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
26
35
27
- API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
36
+ API Documentation:
37
+ - All Dashboards: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
38
+ - Dashboards by Service: https://techdocs.akamai.com/linode-api/reference/get-dashboards
28
39
40
+ :param service_type: The service type to get dashboards for.
41
+ :type service_type: Optional[str]
29
42
:param filters: Any number of filters to apply to this query.
30
43
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
31
44
for more details on filtering.
32
45
33
46
:returns: A list of Dashboards.
34
47
:rtype: PaginatedList of Dashboard
35
48
"""
36
-
37
- return self .client ._get_and_filter (MonitorDashboard , * filters )
38
-
39
- def dashboards_by_service (
40
- self , service_type : str , * filters
41
- ) -> list [MonitorDashboard ]:
42
- """
43
- Returns a list of dashboards for a particular service.
44
-
45
- dashboard_by_service = client.monitor_service.list_dashboards_by_service(service_type="dbaas")
46
-
47
- .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
48
-
49
- API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards
50
-
51
- :param service_type: The service type to get dashboards for.
52
- :type service_type: str
53
- :param filters: Any number of filters to apply to this query.
54
- See :doc:`Filtering Collections</linode_api4/objects/filtering>`
55
- for more details on filtering.
56
-
57
- :returns: Dashboards filtered by Service Type.
58
- :rtype: PaginatedList of the Dashboards
59
- """
49
+ endpoint = (
50
+ f"/monitor/services/{ service_type } /dashboards"
51
+ if service_type
52
+ else "/monitor/dashboards"
53
+ )
60
54
61
55
return self .client ._get_and_filter (
62
56
MonitorDashboard ,
63
57
* filters ,
64
- endpoint = f"/monitor/services/ { service_type } /dashboards" ,
58
+ endpoint = endpoint ,
65
59
)
66
60
67
- def services (self , * filters ) -> list [MonitorService ]:
68
- """
69
- Returns a list of services supported by ACLP.
70
-
71
- supported_services = client.monitor_service.list_supported_services()
72
-
73
- .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
74
-
75
- API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
76
-
77
- :param filters: Any number of filters to apply to this query.
78
- See :doc:`Filtering Collections</linode_api4/objects/filtering>`
79
- for more details on filtering.
80
-
81
- :returns: A list of Supported Services
82
- :rtype: PaginatedList of Services
83
- """
84
-
85
- return self .client ._get_and_filter (MonitorService , * filters )
86
-
87
- def service_by_type (
88
- self , service_type : str , * filters
61
+ def services (
62
+ self , service_type : Optional [str ] = None , * filters
89
63
) -> list [MonitorService ]:
90
64
"""
91
- Lists monitor services by a given service_type
92
-
93
- service_details = client.monitor_service.list_service_by_type (service_type="dbaas")
65
+ Lists services supported by ACLP.
66
+ supported_services = client.monitor_service.services()
67
+ service_details = client.monitor_service.services (service_type="dbaas")
94
68
95
69
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
96
70
71
+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
97
72
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
98
73
99
74
:param service_type: The service type to get details for.
100
- :type service_type: str
75
+ :type service_type: Optional[ str]
101
76
:param filters: Any number of filters to apply to this query.
102
77
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
103
78
for more details on filtering.
104
79
105
80
:returns: Lists monitor services by a given service_type
106
81
:rtype: PaginatedList of the Services
107
82
"""
83
+ endpoint = (
84
+ f"/monitor/services/{ service_type } "
85
+ if service_type
86
+ else "/monitor/services"
87
+ )
108
88
return self .client ._get_and_filter (
109
89
MonitorService ,
110
90
* filters ,
111
- endpoint = f"/monitor/services/ { service_type } " ,
91
+ endpoint = endpoint ,
112
92
)
113
93
114
94
def metric_definitions (
0 commit comments