1+ from typing import Optional
2+
3+ from linode_api4 import (
4+ PaginatedList ,
5+ )
16from linode_api4 .errors import UnexpectedResponseError
27from linode_api4 .groups import Group
38from linode_api4 .objects import (
@@ -15,100 +20,75 @@ class MonitorGroup(Group):
1520 This group contains all features beneath the `/monitor` group in the API v4.
1621 """
1722
18- def dashboards (self , * filters ) -> list [MonitorDashboard ]:
23+ def dashboards (
24+ self , service_type : Optional [str ] = None , * filters
25+ ) -> PaginatedList :
1926 """
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.
2129
22- dashboards = client.monitor_service.list_monitor_dashboards ()
30+ dashboards = client.monitor_service.dashboards ()
2331 dashboard = client.load(MonitorDashboard, 1)
32+ dashboards_by_service = client.monitor_service.dashboards(service_type="dbaas")
2433
2534 .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
2635
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
2839
40+ :param service_type: The service type to get dashboards for.
41+ :type service_type: Optional[str]
2942 :param filters: Any number of filters to apply to this query.
3043 See :doc:`Filtering Collections</linode_api4/objects/filtering>`
3144 for more details on filtering.
3245
3346 :returns: A list of Dashboards.
3447 :rtype: PaginatedList of Dashboard
3548 """
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+ )
6054
6155 return self .client ._get_and_filter (
6256 MonitorDashboard ,
6357 * filters ,
64- endpoint = f"/monitor/services/ { service_type } /dashboards" ,
58+ endpoint = endpoint ,
6559 )
6660
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
8963 ) -> list [MonitorService ]:
9064 """
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")
9468
9569 .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
9670
71+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
9772 API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
9873
9974 :param service_type: The service type to get details for.
100- :type service_type: str
75+ :type service_type: Optional[ str]
10176 :param filters: Any number of filters to apply to this query.
10277 See :doc:`Filtering Collections</linode_api4/objects/filtering>`
10378 for more details on filtering.
10479
10580 :returns: Lists monitor services by a given service_type
10681 :rtype: PaginatedList of the Services
10782 """
83+ endpoint = (
84+ f"/monitor/services/{ service_type } "
85+ if service_type
86+ else "/monitor/services"
87+ )
10888 return self .client ._get_and_filter (
10989 MonitorService ,
11090 * filters ,
111- endpoint = f"/monitor/services/ { service_type } " ,
91+ endpoint = endpoint ,
11292 )
11393
11494 def metric_definitions (
0 commit comments