File tree Expand file tree Collapse file tree 5 files changed +35
-34
lines changed
integration/models/monitor Expand file tree Collapse file tree 5 files changed +35
-34
lines changed Original file line number Diff line number Diff line change @@ -62,32 +62,28 @@ def dashboards(
6262 )
6363
6464 def services (
65- self , * filters , service_type : Optional [str ] = None
66- ) -> list [MonitorService ]:
65+ self ,
66+ * filters ,
67+ ) -> PaginatedList :
6768 """
6869 Lists services supported by ACLP.
6970 supported_services = client.monitor.services()
70- service_details = client.monitor.services(service_type= "dbaas")
71+ service_details = client.monitor.load(MonitorService, "dbaas")
7172
7273 .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
7374
7475 API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
7576 API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
7677
77- :param service_type: The service type to get details for.
78- :type service_type: Optional[str]
7978 :param filters: Any number of filters to apply to this query.
8079 See :doc:`Filtering Collections</linode_api4/objects/filtering>`
8180 for more details on filtering.
8281
83- :returns: Lists monitor services by a given service_type
82+ :returns: Lists monitor services
8483 :rtype: PaginatedList of the Services
8584 """
86- endpoint = (
87- f"/monitor/services/{ service_type } "
88- if service_type
89- else "/monitor/services"
90- )
85+ endpoint = "/monitor/services"
86+
9187 return self .client ._get_and_filter (
9288 MonitorService ,
9389 * filters ,
Original file line number Diff line number Diff line change @@ -157,16 +157,19 @@ class MonitorDashboard(Base):
157157 }
158158
159159
160- @dataclass
161- class MonitorService (JSONObject ):
160+ class MonitorService (Base ):
162161 """
163162 Represents a single service type.
164163 API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
165164
166165 """
167166
168- service_type : ServiceType = ""
169- label : str = ""
167+ api_endpoint = "/monitor/services/{service_type}"
168+ id_attribute = "service_type"
169+ properties = {
170+ "service_type" : Property (ServiceType ),
171+ "label" : Property (),
172+ }
170173
171174
172175@dataclass
Original file line number Diff line number Diff line change 11{
2- "data" : [
3- {
4- "label" : " Databases" ,
5- "service_type" : " dbaas"
6- }
7- ],
8- "page" : 1 ,
9- "pages" : 1 ,
10- "results" : 1
11- }
2+ "service_type" : " dbaas" ,
3+ "label" : " Databases" ,
4+ "alert" : {
5+ "polling_interval_seconds" : [
6+ 300
7+ ],
8+ "evaluation_period_seconds" : [
9+ 300
10+ ],
11+ "scope" : [
12+ " entity"
13+ ]
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -44,11 +44,9 @@ def test_get_supported_services(test_linode_client):
4444 get_supported_service = supported_services [0 ].service_type
4545
4646 # Get details for a particular service
47- service_details = client .monitor .services (
48- service_type = get_supported_service
49- )
50- assert isinstance (service_details [0 ], MonitorService )
51- assert service_details [0 ].service_type == get_supported_service
47+ service_details = client .load (MonitorService , get_supported_service )
48+ assert isinstance (service_details , MonitorService )
49+ assert service_details .service_type == get_supported_service
5250
5351 # Get Metric definition details for that particular service
5452 metric_definitions = client .monitor .metric_definitions (
Original file line number Diff line number Diff line change 11import datetime
22from test .unit .base import ClientBaseCase
33
4- from linode_api4 .objects import MonitorDashboard
4+ from linode_api4 .objects import MonitorDashboard , MonitorService
55
66
77class MonitorTest (ClientBaseCase ):
@@ -85,9 +85,9 @@ def test_get_all_dashboards(self):
8585 self .assertEqual (dashboards [0 ].widgets [0 ].y_label , "cpu_usage" )
8686
8787 def test_specific_service_details (self ):
88- data = self .client .monitor . services ( service_type = "dbaas" )
89- self .assertEqual (data [ 0 ] .label , "Databases" )
90- self .assertEqual (data [ 0 ] .service_type , "dbaas" )
88+ data = self .client .load ( MonitorService , "dbaas" )
89+ self .assertEqual (data .label , "Databases" )
90+ self .assertEqual (data .service_type , "dbaas" )
9191
9292 def test_metric_definitions (self ):
9393
You can’t perform that action at this time.
0 commit comments