Messaging channels

Messaging channels define how to send notifications, for example by email or Slack. The Agent Management client creates and retrieves the shared messaging channel handles on its instance.

In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class. Channel creation and administration require instance administration rights.

Listing channels

for item in client.list_messaging_channels():
    print(item.id, item.type, item.family)

mail_channels = client.list_messaging_channels(
    as_type="objects", channel_family="mail"
)

Creating an SMTP channel

Use the creator to configure the channel before saving it. Replace the example server, sender, and credentials with your SMTP configuration.

import getpass

creator = client.new_messaging_channel("smtp")
creator.with_id("agent-notifications")
creator.with_sender("[email protected]")
creator.with_authorized_domains(["example.com"])
creator.with_host("smtp.example.com")
creator.with_port(587)
creator.with_tls(True)
creator.with_login("smtp-user")
creator.with_password(getpass.getpass("SMTP password: "))
creator.with_permissions(authorized_groups=["agent-operators"], authorized_users=[])
channel = creator.create()

Creation saves the channel configuration. It does not send a notification or attach the channel to an alert configuration. Other supported types include aws-ses-mail, microsoft-graph-mail, slack, msft-teams, and google-chat.

Retrieving settings and permissions

channel = client.get_messaging_channel("agent-notifications")
settings = channel.get_settings()
permissions = channel.get_permissions()
print(permissions)

Use settings.get_raw() and settings.save() to change the channel settings. Use channel.set_permissions() to change access. For the configuration and permission formats, see Messaging channels.

Deleting a channel

client.get_messaging_channel("unused-channel").delete()

Reference documentation

Classes

dataikuapi.dss.messaging_channel.DSSMessagingChannel(client)

A handle to interact with a messaging channel on the DSS instance.

dataikuapi.dss.messaging_channel.DSSMessagingChannelCreator(...)

Helper to create new messaging channels.

dataikuapi.dss.messaging_channel.SMTPMessagingChannelCreator(client)

Helper to create new SMTP messaging channels

Functions

create()

Creates the new messaging channel, and return a handle to interact with it.

delete()

Deletes this messaging channel.

get_messaging_channel(channel_id)

Get the messaging channel with the corresponding ID

get_permissions()

Get the permissions attached to this channel

get_raw()

Get the messaging channel settings.

get_settings()

Returns the settings of this messaging channel as a DSSMessagingChannelSettings.

list_messaging_channels([as_type, ...])

List all available messaging channels

new_messaging_channel(type)

Initializes the creation of a new messaging channel.

save()

Save the changes to the settings on the messaging channel.

set_permissions(permissions)

Sets the permissions on this channel

with_authorized_domains(authorized_domains)

Add authorized domains to the messaging-channel-to-be-created.

with_host(host)

Add a host to the messaging-channel-to-be-created.

with_id(channel_id)

Add an ID to the messaging-channel-to-be-created.

with_login(login)

Add a login to the messaging-channel-to-be-created.

with_password(password)

Add a password to the messaging-channel-to-be-created.

with_permissions(authorized_groups, ...)

Replace the permission configuration for this channel.

with_port(port)

Add a port to the messaging-channel-to-be-created.

with_sender(sender)

Add a sender to the messaging-channel-to-be-created.

with_tls(use_tls)

Add TLS option to the messaging-channel-to-be-created.