Skip to content

Commit cf185a3

Browse files
committed
review comments
1 parent bc8ef27 commit cf185a3

File tree

7 files changed

+27
-36
lines changed

7 files changed

+27
-36
lines changed

linode_api4/groups/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .lke import *
1111
from .lke_tier import *
1212
from .longview import *
13-
from .monitor_service import *
13+
from .monitor import *
1414
from .networking import *
1515
from .nodebalancer import *
1616
from .object_storage import *

linode_api4/groups/monitor_service.py renamed to linode_api4/groups/monitor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class MonitorGroup(Group):
2121
"""
2222

2323
def dashboards(
24-
self, service_type: Optional[str] = None, *filters
24+
self, *filters, service_type: Optional[str] = None
2525
) -> PaginatedList:
2626
"""
2727
Returns a list of dashboards. If `service_type` is provided, it fetches dashboards
2828
for the specific service type. If None, it fetches all dashboards.
2929
30-
dashboards = client.monitor_service.dashboards()
30+
dashboards = client.monitor_serv.dashboards()
3131
dashboard = client.load(MonitorDashboard, 1)
32-
dashboards_by_service = client.monitor_service.dashboards(service_type="dbaas")
32+
dashboards_by_service = client.monitor.dashboards(service_type="dbaas")
3333
3434
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
3535
@@ -59,12 +59,12 @@ def dashboards(
5959
)
6060

6161
def services(
62-
self, service_type: Optional[str] = None, *filters
62+
self, *filters, service_type: Optional[str] = None
6363
) -> list[MonitorService]:
6464
"""
6565
Lists services supported by ACLP.
66-
supported_services = client.monitor_service.services()
67-
service_details = client.monitor_service.services(service_type="dbaas")
66+
supported_services = client.monitor.services()
67+
service_details = client.monitor.services(service_type="dbaas")
6868
6969
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
7070
@@ -97,7 +97,7 @@ def metric_definitions(
9797
"""
9898
Returns metrics for a specific service type.
9999
100-
metrics = client.monitor_service.list_metric_definitions(service_type="dbaas")
100+
metrics = client.monitor.list_metric_definitions(service_type="dbaas")
101101
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
102102
103103
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
@@ -122,7 +122,7 @@ def create_token(
122122
) -> MonitorServiceToken:
123123
"""
124124
Returns a JWE Token for a specific service type.
125-
token = client.monitor_service.create_token(service_type="dbaas", entity_ids=[1234])
125+
token = client.monitor.create_token(service_type="dbaas", entity_ids=[1234])
126126
127127
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
128128

linode_api4/linode_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def __init__(
202202
#: Access methods related to VM placement - See :any:`PlacementAPIGroup` for more information.
203203
self.placement = PlacementAPIGroup(self)
204204

205-
self.monitor_service = MonitorGroup(self)
205+
self.monitor = MonitorGroup(self)
206206

207207
@property
208208
def _user_agent(self):

linode_api4/objects/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
from .vpc import *
2222
from .beta import *
2323
from .placement import *
24-
from .monitor_service import *
24+
from .monitor import *

linode_api4/objects/monitor_service.py renamed to linode_api4/objects/monitor.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,16 @@ class MonitorDashboard(Base):
151151
}
152152

153153

154-
class MonitorService(Base):
154+
@dataclass
155+
class MonitorService(JSONObject):
155156
"""
156157
Represents a single service type.
157158
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
158159
159160
"""
160161

161-
api_endpoint = "/monitor/services/{service_type}"
162-
id_attribute = "service_type"
163-
properties = {
164-
"service_type": Property(ServiceType, identifier=True),
165-
"label": Property(),
166-
}
162+
service_type: ServiceType = ""
163+
label: str = ""
167164

168165

169166
@dataclass

test/integration/models/monitor/test_monitor.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# List all dashboards
1919
def test_get_all_dashboards(test_linode_client):
2020
client = test_linode_client
21-
dashboards = client.monitor_service.dashboards()
21+
dashboards = client.monitor.dashboards()
2222
assert isinstance(dashboards[0], MonitorDashboard)
2323

2424
dashboard_get = dashboards[0]
@@ -30,30 +30,28 @@ def test_get_all_dashboards(test_linode_client):
3030
assert dashboard_by_id.id == 1
3131

3232
# #Fetch Dashboard by service_type
33-
dashboards_by_svc = client.monitor_service.dashboards(
34-
service_type=get_service_type
35-
)
33+
dashboards_by_svc = client.monitor.dashboards(service_type=get_service_type)
3634
assert isinstance(dashboards_by_svc[0], MonitorDashboard)
3735
assert dashboards_by_svc[0].service_type == get_service_type
3836

3937

4038
# List supported services
4139
def test_get_supported_services(test_linode_client):
4240
client = test_linode_client
43-
supported_services = client.monitor_service.services()
41+
supported_services = client.monitor.services()
4442
assert isinstance(supported_services[0], MonitorService)
4543

4644
get_supported_service = supported_services[0].service_type
4745

4846
# Get details for a particular service
49-
service_details = client.monitor_service.services(
47+
service_details = client.monitor.services(
5048
service_type=get_supported_service
5149
)
5250
assert isinstance(service_details[0], MonitorService)
5351
assert service_details[0].service_type == get_supported_service
5452

5553
# Get Metric definition details for that particular service
56-
metric_definitions = client.monitor_service.metric_definitions(
54+
metric_definitions = client.monitor.metric_definitions(
5755
service_type=get_supported_service
5856
)
5957
assert isinstance(metric_definitions[0], MonitorMetricsDefinition)
@@ -103,7 +101,7 @@ def test_my_db_functionality(test_linode_client, test_create_and_test_db):
103101
entity_id = test_create_and_test_db.id
104102

105103
# create token for the particular service
106-
token = client.monitor_service.create_token(
104+
token = client.monitor.create_token(
107105
service_type="dbaas", entity_ids=[entity_id]
108106
)
109107
assert isinstance(token, MonitorServiceToken)

test/unit/objects/monitor_service_test.py renamed to test/unit/objects/monitor.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_supported_services(self):
1313
"""
1414
Test the services supported by monitor
1515
"""
16-
service = self.client.monitor_service.services()
16+
service = self.client.monitor.services()
1717
self.assertEqual(len(service), 1)
1818
self.assertEqual(service[0].label, "Databases")
1919
self.assertEqual(service[0].service_type, "dbaas")
@@ -43,9 +43,7 @@ def test_dashboard_by_ID(self):
4343
self.assertEqual(dashboard.widgets[0].y_label, "cpu_usage")
4444

4545
def test_dashboard_by_service_type(self):
46-
dashboards = self.client.monitor_service.dashboards(
47-
service_type="dbaas"
48-
)
46+
dashboards = self.client.monitor.dashboards(service_type="dbaas")
4947
self.assertEqual(dashboards[0].type, "standard")
5048
self.assertEqual(
5149
dashboards[0].created, datetime.datetime(2024, 10, 10, 5, 1, 58)
@@ -66,7 +64,7 @@ def test_dashboard_by_service_type(self):
6664
self.assertEqual(dashboards[0].widgets[0].y_label, "cpu_usage")
6765

6866
def test_get_all_dashboards(self):
69-
dashboards = self.client.monitor_service.dashboards()
67+
dashboards = self.client.monitor.dashboards()
7068
self.assertEqual(dashboards[0].type, "standard")
7169
self.assertEqual(
7270
dashboards[0].created, datetime.datetime(2024, 10, 10, 5, 1, 58)
@@ -87,15 +85,13 @@ def test_get_all_dashboards(self):
8785
self.assertEqual(dashboards[0].widgets[0].y_label, "cpu_usage")
8886

8987
def test_specific_service_details(self):
90-
data = self.client.monitor_service.services(service_type="dbaas")
88+
data = self.client.monitor.services(service_type="dbaas")
9189
self.assertEqual(data[0].label, "Databases")
9290
self.assertEqual(data[0].service_type, "dbaas")
9391

9492
def test_metric_definitions(self):
9593

96-
metrics = self.client.monitor_service.metric_definitions(
97-
service_type="dbaas"
98-
)
94+
metrics = self.client.monitor.metric_definitions(service_type="dbaas")
9995
self.assertEqual(
10096
metrics[0].available_aggregate_functions,
10197
["max", "avg", "min", "sum"],
@@ -115,7 +111,7 @@ def test_metric_definitions(self):
115111
def test_create_token(self):
116112

117113
with self.mock_post("/monitor/services/dbaas/token") as m:
118-
self.client.monitor_service.create_token(
114+
self.client.monitor.create_token(
119115
service_type="dbaas", entity_ids=[189690, 188020]
120116
)
121117
self.assertEqual(m.return_dct["token"], "abcdefhjigkfghh")

0 commit comments

Comments
 (0)