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(
62
62
)
63
63
64
64
def services (
65
- self , * filters , service_type : Optional [str ] = None
66
- ) -> list [MonitorService ]:
65
+ self ,
66
+ * filters ,
67
+ ) -> PaginatedList :
67
68
"""
68
69
Lists services supported by ACLP.
69
70
supported_services = client.monitor.services()
70
- service_details = client.monitor.services(service_type= "dbaas")
71
+ service_details = client.monitor.load(MonitorService, "dbaas")
71
72
72
73
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
73
74
74
75
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
75
76
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
76
77
77
- :param service_type: The service type to get details for.
78
- :type service_type: Optional[str]
79
78
:param filters: Any number of filters to apply to this query.
80
79
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
81
80
for more details on filtering.
82
81
83
- :returns: Lists monitor services by a given service_type
82
+ :returns: Lists monitor services
84
83
:rtype: PaginatedList of the Services
85
84
"""
86
- endpoint = (
87
- f"/monitor/services/{ service_type } "
88
- if service_type
89
- else "/monitor/services"
90
- )
85
+ endpoint = "/monitor/services"
86
+
91
87
return self .client ._get_and_filter (
92
88
MonitorService ,
93
89
* filters ,
Original file line number Diff line number Diff line change @@ -157,16 +157,19 @@ class MonitorDashboard(Base):
157
157
}
158
158
159
159
160
- @dataclass
161
- class MonitorService (JSONObject ):
160
+ class MonitorService (Base ):
162
161
"""
163
162
Represents a single service type.
164
163
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
165
164
166
165
"""
167
166
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
+ }
170
173
171
174
172
175
@dataclass
Original file line number Diff line number Diff line change 1
1
{
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):
44
44
get_supported_service = supported_services [0 ].service_type
45
45
46
46
# 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
52
50
53
51
# Get Metric definition details for that particular service
54
52
metric_definitions = client .monitor .metric_definitions (
Original file line number Diff line number Diff line change 1
1
import datetime
2
2
from test .unit .base import ClientBaseCase
3
3
4
- from linode_api4 .objects import MonitorDashboard
4
+ from linode_api4 .objects import MonitorDashboard , MonitorService
5
5
6
6
7
7
class MonitorTest (ClientBaseCase ):
@@ -85,9 +85,9 @@ def test_get_all_dashboards(self):
85
85
self .assertEqual (dashboards [0 ].widgets [0 ].y_label , "cpu_usage" )
86
86
87
87
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" )
91
91
92
92
def test_metric_definitions (self ):
93
93
You can’t perform that action at this time.
0 commit comments