Skip to content

Commit 21ef5c1

Browse files
committed
updating review comment fixes
1 parent 54d4efc commit 21ef5c1

3 files changed

Lines changed: 20 additions & 28 deletions

File tree

‎linode_api4/groups/monitor.py‎

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -347,33 +347,13 @@ def channel_create(
347347
email list) that can be associated with one or more alert definitions.
348348
Currently only ``email`` is supported as a ``channel_type``.
349349
350-
Example usage::
351-
352-
from linode_api4.objects.monitor import ChannelDetails, EmailDetails
353-
354-
client = LinodeClient(TOKEN)
355-
356-
new_channel = client.monitor.channel_create(
357-
label="Email channel for api change",
358-
channel_type="email",
359-
details=ChannelDetails(
360-
email=EmailDetails(
361-
recipient_type="user",
362-
usernames=["username-test"],
363-
)
364-
),
365-
)
366-
367-
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-alert-channel
350+
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-notification-channel
368351
369352
:param label: Human-readable name for the new alert channel.
370353
:type label: str
371354
:param channel_type: The type of notification channel (e.g. ``"email"``).
372355
:type channel_type: str
373-
:param details: Notification-type-specific configuration. Use
374-
:class:`~linode_api4.objects.monitor.ChannelDetails` with
375-
a nested :class:`~linode_api4.objects.monitor.EmailDetails`
376-
for email channels.
356+
:param details: Notification-type-specific configuration.
377357
:type details: ChannelDetails
378358
379359
:returns: The newly created :class:`AlertChannel`.

‎linode_api4/objects/monitor.py‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
__all__ = [
99
"AggregateFunction",
1010
"AlertChannel",
11+
"AlertChannelType",
1112
"AlertDefinition",
1213
"AlertDefinitionChannel",
1314
"AlertDefinitionEntity",
@@ -387,6 +388,15 @@ class AlertScope(StrEnum):
387388
account = "account"
388389

389390

391+
class AlertChannelType(StrEnum):
392+
"""
393+
Type values for alert channels.
394+
"""
395+
396+
system = "system"
397+
user = "user"
398+
399+
390400
@dataclass
391401
class AlertEntities(JSONObject):
392402
"""
@@ -490,11 +500,11 @@ class AlertChannel(Base):
490500
"""
491501
Represents an alert channel used to deliver notifications when alerts
492502
fire. Alert channels define a destination and configuration for
493-
notifications (for example: email lists, webhooks, PagerDuty, Slack, etc.).
503+
notifications (for example: email lists, webhooks, Slack, etc.).
494504
495505
API Documentation:
496-
List/Get: https://techdocs.akamai.com/linode-api/reference/get-alert-channels
497-
Create: https://techdocs.akamai.com/linode-api/reference/post-alert-channel
506+
List/Get: https://techdocs.akamai.com/linode-api/reference/get-notification-channel
507+
Create: https://techdocs.akamai.com/linode-api/reference/post-notification-channel
498508
499509
This class maps to the Monitor API's ``/monitor/alert-channels`` resource
500510
and is used by the SDK to list, load, create, and inspect channels.
@@ -505,7 +515,7 @@ class AlertChannel(Base):
505515
properties = {
506516
"id": Property(identifier=True),
507517
"label": Property(mutable=True),
508-
"type": Property(),
518+
"type": Property(AlertChannelType),
509519
"channel_type": Property(),
510520
"details": Property(mutable=True, json_object=ChannelDetails),
511521
"alerts": Property(mutable=False, json_object=AlertInfo),

‎test/integration/models/monitor/test_monitor.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,10 @@ def test_integration_create_get_update_delete_alert_channel(test_linode_client):
335335
# Get valid users to use for the email alert channel
336336
users = list(client.account.users())
337337
if len(users) == 0:
338-
pytest.skip("No account users available for creating alert channels")
339-
338+
pytest.skip(
339+
"No account users available for creating alert channels"
340+
)
341+
340342
# Use the first user, or first two if available
341343
usernames = [users[0].username]
342344
if len(users) > 1:

0 commit comments

Comments
 (0)