Skip to content

Commit 69de940

Browse files
committed
updating code with review comments
1 parent 9084a05 commit 69de940

File tree

4 files changed

+14
-55
lines changed

4 files changed

+14
-55
lines changed

linode_api4/groups/monitor.py

+1-26
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
Dashboard,
88
MonitorServiceSupported,
99
MetricDefinition,
10-
DashboardsByID,
1110
)
1211

13-
__all__ = [
14-
"MonitorGroup",
15-
]
12+
1613
class MonitorGroup(Group):
1714
"""
1815
Encapsulates Monitor-related methods of the :any:`LinodeClient`. This
@@ -42,28 +39,6 @@ def dashboards(self, *filters):
4239
"""
4340
return self.client._get_and_filter(Dashboard, *filters)
4441

45-
def dashboard_by_ID(self, dashboard_id: int, *filters):
46-
"""
47-
Returns a dashboards on your account based on the ID passed.
48-
49-
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
50-
51-
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards-by-id
52-
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: A Dashboards.
58-
:rtype: PaginatedList of the Dashboard
59-
"""
60-
result = self.client.get(f"/monitor/dashboards/{dashboard_id}")
61-
62-
if not "id" in result:
63-
raise UnexpectedResponseError(
64-
"Unexpected response when getting Dashboard!", json=result
65-
)
66-
return DashboardsByID(self.client, result["id"], result)
6742

6843

6944
def dashboards_by_service(self, service_type: str, *filters):

linode_api4/objects/monitor.py

+1-17
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
Property,
44
)
55

6-
__all__ = ['Dashboard', 'DashboardsByID', 'DashboardByService', 'MonitorServiceSupported', 'ServiceDetails', 'MetricDefinition', 'CreateToken']
76
class Dashboard(Base):
87
"""
98
List dashboards: https://techdocs.akamai.com/linode-api/get-dashboards-all
109
"""
1110

12-
api_endpoint = "/monitor/dashboards/"
11+
api_endpoint = "/monitor/dashboards/{id}"
1312
properties = {
1413
"id": Property(identifier=True),
1514
"created": Property(is_datetime=True),
@@ -21,23 +20,8 @@ class Dashboard(Base):
2120

2221
}
2322

24-
class DashboardsByID(Base):
25-
"""
26-
Get a dashboard: https://techdocs.akamai.com/linode-api/reference/get-dashboards-by-id
27-
"""
2823

2924

30-
properties = {
31-
"id": Property(identifier=True),
32-
"created": Property(is_datetime=True),
33-
"label": Property(),
34-
"service_type": Property(),
35-
"type": Property(),
36-
"widgets": Property(mutable=True),
37-
"updated": Property(is_datetime=True),
38-
39-
}
40-
4125
class DashboardByService(Base):
4226
"""
4327
Get a dashboard: https://techdocs.akamai.com/linode-api/reference/get-dashboards

test/integration/models/monitor/test_monitor.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from linode_api4.objects import (
22
MonitorServiceSupported,
33
Dashboard,
4-
DashboardsByID,
54
DashboardByService,
65
ServiceDetails,
76
MetricDefinition,
@@ -26,17 +25,15 @@ def test_get_all_dashboards(test_linode_client):
2625
assert isinstance(dashboards[0],Dashboard)
2726

2827
dashboard_get = dashboards[0]
29-
dashboard_id = dashboard_get.id
3028
get_service_type = dashboard_get.service_type
31-
print(f"printing svc {get_service_type}")
3229

3330
#Fetch Dashboard by ID
34-
dashboard_by_id = client.monitor.dashboard_by_ID(dashboard_id=dashboard_id)
35-
assert isinstance(dashboard_by_id, DashboardsByID)
36-
assert dashboard_by_id.id == dashboard_id
31+
dashboard_by_id = client.load(Dashboard, 1)
32+
assert isinstance(dashboard_by_id, Dashboard)
33+
assert dashboard_by_id.id == 1
3734

38-
#Fetch Dashboard by service_type
39-
dashboards_by_svc = client.monitor.dashboard_by_service(service_type=get_service_type)
35+
# #Fetch Dashboard by service_type
36+
dashboards_by_svc = client.monitor.dashboards_by_service(service_type=get_service_type)
4037
assert isinstance(dashboards_by_svc[0], DashboardByService)
4138
assert dashboards_by_svc[0].service_type == get_service_type
4239

test/unit/objects/monitor_test.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from test.unit.base import ClientBaseCase
2+
from linode_api4.objects import (
3+
Dashboard,
4+
)
25
import datetime
36

4-
class MonitorSupportedServicesTest(ClientBaseCase):
7+
class MonitorTest(ClientBaseCase):
58
"""
69
Tests the methods of MonitorServiceSupported class
710
"""
@@ -19,7 +22,7 @@ def test_dashboard_by_ID(self):
1922
"""
2023
Test the dashboard by ID API
2124
"""
22-
dashboard = self.client.monitor.dashboard_by_ID(dashboard_id=1)
25+
dashboard = self.client.load(Dashboard, 1)
2326
self.assertEqual(dashboard.type, "standard")
2427
self.assertEqual(dashboard.created, datetime.datetime(2024, 10, 10, 5, 1, 58))
2528
self.assertEqual(dashboard.id, 1)
@@ -37,7 +40,7 @@ def test_dashboard_by_ID(self):
3740

3841

3942
def test_dashboard_by_service_type(self):
40-
dashboards = self.client.monitor.dashboard_by_service(service_type="dbaas")
43+
dashboards = self.client.monitor.dashboards_by_service(service_type="dbaas")
4144
self.assertEqual(dashboards[0].type, "standard")
4245
self.assertEqual(dashboards[0].created, datetime.datetime(2024, 10, 10, 5, 1, 58))
4346
self.assertEqual(dashboards[0].id, 1)
@@ -89,7 +92,7 @@ def test_metric_definitions(self):
8992
self.assertEqual(metrics[0].dimensions[0].label, "Node Type")
9093
self.assertEqual(metrics[0].dimensions[0].values,["primary", "secondary"])
9194

92-
def create_token(self):
95+
def test_create_token(self):
9396

9497
with self.mock_post("/monitor/services/dbaas/token") as m:
9598
self.client.monitor.create_token(service_type="dbaas", entity_ids=[189690,188020])

0 commit comments

Comments
 (0)