Skip to content

Commit 33e954f

Browse files
committed
updating with review comments
1 parent fe4a6bd commit 33e954f

File tree

8 files changed

+245
-152
lines changed

8 files changed

+245
-152
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 import *
13+
from .monitor_service import *
1414
from .networking import *
1515
from .nodebalancer import *
1616
from .object_storage import *
Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
from linode_api4.errors import UnexpectedResponseError
22
from linode_api4.groups import Group
33
from linode_api4.objects import (
4-
CreateToken,
5-
Dashboard,
6-
DashboardByService,
7-
MetricDefinition,
8-
MonitorServiceSupported,
9-
ServiceDetails,
4+
MonitorDashboard,
5+
MonitorMetricsDefinition,
6+
MonitorService,
7+
MonitorServiceToken,
108
)
119

1210

1311
class MonitorGroup(Group):
1412
"""
15-
Encapsulates Monitor-related methods of the :any:`LinodeClient`. This
16-
should not be instantiated on its own, but should instead be used through
17-
an instance of :any:`LinodeClient`::
18-
19-
client = LinodeClient(token)
20-
instances = client.monitor.dashboards() # use the LKEGroup
13+
Encapsulates Monitor-related methods of the :any:`LinodeClient`.
2114
2215
This group contains all features beneath the `/monitor` group in the API v4.
2316
"""
2417

25-
def dashboards(self, *filters):
18+
def list_monitor_dashboards(self, *filters) -> list[MonitorDashboard]:
2619
"""
27-
Returns a list of dashboards on your account.
20+
Returns a list of dashboards.
21+
22+
dashboards = client.monitor_service.list_monitor_dashboards()
23+
dashboard = client.load(Dashboard, 1)
2824
2925
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
3026
@@ -37,34 +33,41 @@ def dashboards(self, *filters):
3733
:returns: A list of Dashboards.
3834
:rtype: PaginatedList of Dashboard
3935
"""
40-
return self.client._get_and_filter(Dashboard, *filters)
4136

42-
def dashboards_by_service(self, service_type: str, *filters):
43-
"""
44-
Returns a dashboards on your account based on the service passed.
37+
return self.client._get_and_filter(MonitorDashboard, *filters)
4538

39+
def list_dashboards_by_service(self, service_type: str, *filters) -> list[MonitorDashboard]:
40+
"""
41+
Returns a list of dashboards for a particular service.
42+
43+
dashboard_by_service = client.monitor_service.list_dashboards_by_service(service_type="dbaas")
44+
4645
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
4746
4847
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards
4948
49+
:param service_type: The service type to get dashboards for.
50+
:type service_type: str
5051
:param filters: Any number of filters to apply to this query.
5152
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
5253
for more details on filtering.
5354
54-
:returns: A Dashboards filtered by Service Type.
55+
:returns: Dashboards filtered by Service Type.
5556
:rtype: PaginatedList of the Dashboards
5657
"""
5758

5859
return self.client._get_and_filter(
59-
DashboardByService,
60+
MonitorDashboard,
6061
*filters,
6162
endpoint=f"/monitor/services/{service_type}/dashboards",
6263
)
6364

64-
def supported_services(self, *filters):
65+
def list_supported_services(self, *filters) -> list[MonitorService]:
6566
"""
6667
Returns a list of services supported by ACLP.
6768
69+
supported_services = client.monitor_service.list_supported_services()
70+
6871
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
6972
7073
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
@@ -74,63 +77,74 @@ def supported_services(self, *filters):
7477
for more details on filtering.
7578
7679
:returns: A list of Supported Services
77-
:rtype: PaginatedList of the Dashboards
80+
:rtype: PaginatedList of Services
7881
"""
7982

80-
return self.client._get_and_filter(MonitorServiceSupported, *filters)
83+
return self.client._get_and_filter(MonitorService, *filters)
8184

82-
def details_by_service(self, service_type: str, *filters):
85+
def list_service_by_type(self, service_type: str, *filters) -> list[MonitorService]:
8386
"""
84-
Returns a details about a particular service.
87+
Lists monitor services by a given service_type
8588
89+
service_details = client.monitor_service.list_service_by_type(service_type="dbaas")
90+
8691
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
87-
92+
8893
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
89-
94+
95+
:param service_type: The service type to get details for.
96+
:type service_type: str
9097
:param filters: Any number of filters to apply to this query.
9198
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
9299
for more details on filtering.
93-
94-
:returns: Details about a Supported Services
95-
:rtype: PaginatedList of the Service
100+
101+
:returns: Lists monitor services by a given service_type
102+
:rtype: PaginatedList of the Services
96103
"""
97104
return self.client._get_and_filter(
98-
ServiceDetails,
105+
MonitorService,
99106
*filters,
100107
endpoint=f"/monitor/services/{service_type}",
101108
)
102109

103-
def metric_definitions(self, service_type: str, *filters):
110+
111+
def list_metric_definitions(self, service_type: str, *filters) -> list[MonitorMetricsDefinition]:
104112
"""
105113
Returns metrics for a specific service type.
106114
115+
metrics = client.monitor_service.list_metric_definitions(service_type="dbaas")
107116
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
108117
109118
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
110119
120+
:param service_type: The service type to get metrics for.
121+
:type service_type: str
111122
:param filters: Any number of filters to apply to this query.
112123
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
113124
for more details on filtering.
114125
115-
:returns: Returns a List of metrics for a service
126+
:returns: Returns a List of metrics for a service
116127
:rtype: PaginatedList of metrics
117128
"""
118129
return self.client._get_and_filter(
119-
MetricDefinition,
130+
MonitorMetricsDefinition,
120131
*filters,
121132
endpoint=f"/monitor/services/{service_type}/metric-definitions",
122133
)
123134

124-
def create_token(self, service_type: str, entity_ids: list, *filters):
135+
def create_token(self, service_type: str, entity_ids: list) -> MonitorServiceToken:
125136
"""
126137
Returns a JWE Token for a specific service type.
138+
token = client.monitor_service.create_token(service_type="dbaas", entity_ids=[1234])
127139
128140
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
129141
130142
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
131-
:param filters: Any number of filters to apply to this query.
132-
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
133-
for more details on filtering.
143+
144+
:param service_type: The service type to create token for.
145+
:type service_type: str
146+
:param entity_ids: The list of entity IDs for which the token is valid.
147+
:type entity_ids: list of int
134148
135149
:returns: Returns a token for a service
136150
:rtype: str
@@ -146,4 +160,5 @@ def create_token(self, service_type: str, entity_ids: list, *filters):
146160
raise UnexpectedResponseError(
147161
"Unexpected response when creating token!", json=result
148162
)
149-
return CreateToken(self.client, result["token"], result)
163+
return MonitorServiceToken(token=result["token"])
164+

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 = MonitorGroup(self)
205+
self.monitor_service = 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 import *
24+
from .monitor_service import *

linode_api4/objects/monitor.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)