diff --git a/linode_api4/groups/monitor.py b/linode_api4/groups/monitor.py index 66943ade5..4c36f2e9c 100644 --- a/linode_api4/groups/monitor.py +++ b/linode_api4/groups/monitor.py @@ -202,7 +202,7 @@ def alert_channels(self, *filters) -> PaginatedList: .. note:: This endpoint is in beta and requires using the v4beta base URL. - API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert-channels + API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels :param filters: Optional filter expressions to apply to the collection. See :doc:`Filtering Collections` for details. diff --git a/linode_api4/objects/monitor.py b/linode_api4/objects/monitor.py index ca8f83921..fea81c211 100644 --- a/linode_api4/objects/monitor.py +++ b/linode_api4/objects/monitor.py @@ -422,25 +422,6 @@ class AlertDefinition(DerivedBase): } -@dataclass -class EmailChannelContent(JSONObject): - """ - Represents the content for an email alert channel. - """ - - email_addresses: Optional[List[str]] = None - - -@dataclass -class ChannelContent(JSONObject): - """ - Represents the content block for an AlertChannel, which varies by channel type. - """ - - email: Optional[EmailChannelContent] = None - # Other channel types like 'webhook', 'slack' could be added here as Optional fields. - - @dataclass class EmailDetails(JSONObject): """ @@ -481,7 +462,7 @@ class AlertChannel(Base): fire. Alert channels define a destination and configuration for notifications (for example: email lists, webhooks, PagerDuty, Slack, etc.). - API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert-channels + API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels This class maps to the Monitor API's `/monitor/alert-channels` resource and is used by the SDK to list, load, and inspect channels. @@ -499,7 +480,6 @@ class AlertChannel(Base): "channel_type": Property(), "details": Property(mutable=False, json_object=ChannelDetails), "alerts": Property(mutable=False, json_object=AlertInfo), - "content": Property(mutable=False, json_object=ChannelContent), "created": Property(is_datetime=True), "updated": Property(is_datetime=True), "created_by": Property(), diff --git a/test/fixtures/monitor_alert-channels.json b/test/fixtures/monitor_alert-channels.json new file mode 100644 index 000000000..753c53431 --- /dev/null +++ b/test/fixtures/monitor_alert-channels.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "id": 123, + "label": "alert notification channel", + "type": "user", + "channel_type": "email", + "details": { + "email": { + "usernames": [ + "admin-user1", + "admin-user2" + ], + "recipient_type": "user" + } + }, + "alerts": { + "url": "/monitor/alert-channels/123/alerts", + "type": "alerts-definitions", + "alert_count": 0 + }, + "created": "2024-01-01T00:00:00", + "updated": "2024-01-01T00:00:00", + "created_by": "tester", + "updated_by": "tester" + } + ], + "page": 1, + "pages": 1, + "results": 1 +} \ No newline at end of file diff --git a/test/unit/objects/monitor_test.py b/test/unit/objects/monitor_test.py index 329a09063..2a229f902 100644 --- a/test/unit/objects/monitor_test.py +++ b/test/unit/objects/monitor_test.py @@ -1,7 +1,7 @@ import datetime from test.unit.base import ClientBaseCase -from linode_api4.objects import MonitorDashboard, MonitorService +from linode_api4.objects import AlertChannel, MonitorDashboard, MonitorService class MonitorTest(ClientBaseCase): @@ -146,3 +146,27 @@ def test_create_token(self): service_type="linode", entity_ids=["compute-instance-1"] ) self.assertEqual(m.return_dct["token"], "abcdefhjigkfghh") + + def test_alert_channels(self): + channels = self.client.monitor.alert_channels() + + self.assertEqual(len(channels), 1) + self.assertIsInstance(channels[0], AlertChannel) + self.assertEqual(channels[0].id, 123) + self.assertEqual(channels[0].label, "alert notification channel") + self.assertEqual(channels[0].type, "user") + self.assertEqual(channels[0].channel_type, "email") + self.assertIsNotNone(channels[0].details) + self.assertIsNotNone(channels[0].details.email) + self.assertEqual( + channels[0].details.email.usernames, + ["admin-user1", "admin-user2"], + ) + self.assertEqual(channels[0].details.email.recipient_type, "user") + self.assertIsNotNone(channels[0].alerts) + self.assertEqual( + channels[0].alerts.url, + "/monitor/alert-channels/123/alerts", + ) + self.assertEqual(channels[0].alerts.alert_count, 0) + self.assertFalse(hasattr(channels[0], "content"))