Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions 18 linode_api4/groups/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,28 @@ def dashboards(
)

def services(
self, *filters, service_type: Optional[str] = None
) -> list[MonitorService]:
self,
*filters,
) -> PaginatedList:
"""
Lists services supported by ACLP.
supported_services = client.monitor.services()
service_details = client.monitor.services(service_type="dbaas")
service_details = client.monitor.load(MonitorService, "dbaas")

.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type

:param service_type: The service type to get details for.
:type service_type: Optional[str]
:param filters: Any number of filters to apply to this query.
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
for more details on filtering.

:returns: Lists monitor services by a given service_type
:returns: Lists monitor services
:rtype: PaginatedList of the Services
"""
endpoint = (
f"/monitor/services/{service_type}"
if service_type
else "/monitor/services"
)
endpoint = "/monitor/services"

return self.client._get_and_filter(
MonitorService,
*filters,
Expand Down
11 changes: 7 additions & 4 deletions 11 linode_api4/objects/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,19 @@ class MonitorDashboard(Base):
}


@dataclass
class MonitorService(JSONObject):
class MonitorService(Base):
"""
Represents a single service type.
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services

"""

service_type: ServiceType = ""
label: str = ""
api_endpoint = "/monitor/services/{service_type}"
id_attribute = "service_type"
properties = {
"service_type": Property(ServiceType),
"label": Property(),
}


@dataclass
Expand Down
24 changes: 14 additions & 10 deletions 24 test/fixtures/monitor_services_dbaas.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"data": [
{
"label": "Databases",
"service_type": "dbaas"
}
],
"page": 1,
"pages": 1,
"results": 1
}
"service_type": "dbaas",
"label": "Databases",
"alert": {
"polling_interval_seconds": [
300
],
"evaluation_period_seconds": [
300
],
"scope": [
"entity"
]
}
}
8 changes: 3 additions & 5 deletions 8 test/integration/models/monitor/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ def test_get_supported_services(test_linode_client):
get_supported_service = supported_services[0].service_type

# Get details for a particular service
service_details = client.monitor.services(
service_type=get_supported_service
)
assert isinstance(service_details[0], MonitorService)
assert service_details[0].service_type == get_supported_service
service_details = client.load(MonitorService, get_supported_service)
assert isinstance(service_details, MonitorService)
assert service_details.service_type == get_supported_service

# Get Metric definition details for that particular service
metric_definitions = client.monitor.metric_definitions(
Expand Down
8 changes: 4 additions & 4 deletions 8 test/unit/objects/monitor_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from test.unit.base import ClientBaseCase

from linode_api4.objects import MonitorDashboard
from linode_api4.objects import MonitorDashboard, MonitorService


class MonitorTest(ClientBaseCase):
Expand Down Expand Up @@ -85,9 +85,9 @@ def test_get_all_dashboards(self):
self.assertEqual(dashboards[0].widgets[0].y_label, "cpu_usage")

def test_specific_service_details(self):
data = self.client.monitor.services(service_type="dbaas")
self.assertEqual(data[0].label, "Databases")
self.assertEqual(data[0].service_type, "dbaas")
data = self.client.load(MonitorService, "dbaas")
self.assertEqual(data.label, "Databases")
self.assertEqual(data.service_type, "dbaas")

def test_metric_definitions(self):

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.