Skip to content

Commit 6f7cefb

Browse files
committed
Remove content field from list alert channels response
1 parent d692eef commit 6f7cefb

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed

linode_api4/groups/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def alert_channels(self, *filters) -> PaginatedList:
202202
203203
.. note:: This endpoint is in beta and requires using the v4beta base URL.
204204
205-
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert-channels
205+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels
206206
207207
:param filters: Optional filter expressions to apply to the collection.
208208
See :doc:`Filtering Collections</linode_api4/objects/filtering>` for details.

linode_api4/objects/monitor.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -422,25 +422,6 @@ class AlertDefinition(DerivedBase):
422422
}
423423

424424

425-
@dataclass
426-
class EmailChannelContent(JSONObject):
427-
"""
428-
Represents the content for an email alert channel.
429-
"""
430-
431-
email_addresses: Optional[List[str]] = None
432-
433-
434-
@dataclass
435-
class ChannelContent(JSONObject):
436-
"""
437-
Represents the content block for an AlertChannel, which varies by channel type.
438-
"""
439-
440-
email: Optional[EmailChannelContent] = None
441-
# Other channel types like 'webhook', 'slack' could be added here as Optional fields.
442-
443-
444425
@dataclass
445426
class EmailDetails(JSONObject):
446427
"""
@@ -481,7 +462,7 @@ class AlertChannel(Base):
481462
fire. Alert channels define a destination and configuration for
482463
notifications (for example: email lists, webhooks, PagerDuty, Slack, etc.).
483464
484-
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert-channels
465+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels
485466
486467
This class maps to the Monitor API's `/monitor/alert-channels` resource
487468
and is used by the SDK to list, load, and inspect channels.
@@ -499,7 +480,6 @@ class AlertChannel(Base):
499480
"channel_type": Property(),
500481
"details": Property(mutable=False, json_object=ChannelDetails),
501482
"alerts": Property(mutable=False, json_object=AlertInfo),
502-
"content": Property(mutable=False, json_object=ChannelContent),
503483
"created": Property(is_datetime=True),
504484
"updated": Property(is_datetime=True),
505485
"created_by": Property(),
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"data": [
3+
{
4+
"id": 123,
5+
"label": "alert notification channel",
6+
"type": "user",
7+
"channel_type": "email",
8+
"details": {
9+
"email": {
10+
"usernames": [
11+
"admin-user1",
12+
"admin-user2"
13+
],
14+
"recipient_type": "user"
15+
}
16+
},
17+
"alerts": {
18+
"url": "/monitor/alert-channels/123/alerts",
19+
"type": "alerts-definitions",
20+
"alert_count": 0
21+
},
22+
"created": "2024-01-01T00:00:00",
23+
"updated": "2024-01-01T00:00:00",
24+
"created_by": "tester",
25+
"updated_by": "tester"
26+
}
27+
],
28+
"page": 1,
29+
"pages": 1,
30+
"results": 1
31+
}

test/unit/objects/monitor_test.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
from test.unit.base import ClientBaseCase
33

4-
from linode_api4.objects import MonitorDashboard, MonitorService
4+
from linode_api4.objects import AlertChannel, MonitorDashboard, MonitorService
55

66

77
class MonitorTest(ClientBaseCase):
@@ -146,3 +146,26 @@ def test_create_token(self):
146146
service_type="linode", entity_ids=["compute-instance-1"]
147147
)
148148
self.assertEqual(m.return_dct["token"], "abcdefhjigkfghh")
149+
150+
def test_alert_channels(self):
151+
channels = self.client.monitor.alert_channels()
152+
153+
self.assertEqual(len(channels), 1)
154+
self.assertIsInstance(channels[0], AlertChannel)
155+
self.assertEqual(channels[0].id, 123)
156+
self.assertEqual(channels[0].label, "alert notification channel")
157+
self.assertEqual(channels[0].type, "user")
158+
self.assertEqual(channels[0].channel_type, "email")
159+
self.assertIsNotNone(channels[0].details)
160+
self.assertIsNotNone(channels[0].details.email)
161+
self.assertEqual(
162+
channels[0].details.email.usernames,
163+
["admin-user1", "admin-user2"],
164+
)
165+
self.assertEqual(channels[0].details.email.recipient_type, "user")
166+
self.assertIsNotNone(channels[0].alerts)
167+
self.assertEqual(
168+
channels[0].alerts.url,
169+
"/monitor/alert-channels/123/alerts",
170+
)
171+
self.assertEqual(channels[0].alerts.alert_count, 0)

0 commit comments

Comments
 (0)