Messaging channels#

class dataikuapi.dss.messaging_channel.DSSMessagingChannelListItem(client, data)#

A generic messaging channel in DSS.

Important

Do not instantiate this class, use dataikuapi.DSSClient.list_messaging_channels()

property id#

ID of the messaging channel

Type:

str

property type#

Type of the messaging channel

Type:

str

property family#

Family of the messaging channel where relevant - e.g. “mail”

Type:

str

get_raw()#
Returns:

Gets the raw representation of this DSSMessagingChannelListItem, any edit is reflected in the object.

Return type:

dict

get_as_messaging_channel()#
Returns:

The same messaging channel but as the appropriate object type

Return type:

DSSMessagingChannel

class dataikuapi.dss.messaging_channel.DSSMessagingChannelSettings(channel, settings)#

Settings class for a DSS messaging channel.

Important

Do not instantiate this class directly, use DSSMessagingChannel.get_settings().

Use save() to save your changes.

get_raw()#

Get the messaging channel settings. Requires admin privileges.

Returns:

the settings (ie configuration), as a dict.

Return type:

dict

save()#

Save the changes to the settings on the messaging channel. Requires admin privileges.

Usage example:

channel = client.get_messaging_channel("my_channel_id")
channel_settings = channel.get_settings()
channel_settings.get_raw()["webhookUrl"] = "https://www.example.org/"
channel_settings.save()
class dataikuapi.dss.messaging_channel.DSSMessagingChannel(client, data=None)#

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

Important

Do not instantiate this class directly, use dataikuapi.DSSClient.get_messaging_channel()

property id#

ID of the messaging channel

Return type:

str

property type#

Type of the messaging channel

Return type:

str

property family#

Family of the messaging channel where relevant - e.g. “mail”

Type:

str

get_settings()#

Returns the settings of this messaging channel as a DSSMessagingChannelSettings.

You must use save() on the returned object to make your changes effective on the messaging channel.

# Example: change sender
channel = client.get_messaging_channel("my_channel_id")
channel_settings = channel.get_settings()
channel_settings.get_raw()["sender"] = "someone@example.org"
channel_settings.save()
Returns:

the settings of the messaging channel

Return type:

DSSMessagingChannelSettings

delete()#

Deletes this messaging channel. Requires admin privileges.

channel = client.get_messaging_channel("my_channel_id")
channel.delete()
class dataikuapi.dss.messaging_channel.DSSMailMessagingChannel(client, data)#

A handle to interact with an email messaging channel on the DSS instance - a subclass of DSSMessagingChannel

Important

Do not instantiate this class directly, use dataikuapi.DSSClient.get_messaging_channel()

property sender#

Sender for the messaging channel, if present

Return type:

str

property use_current_user_as_sender#

Indicates whether the messaging channel will use the address of the current user as sender. If True and the current user has no associated email address, the sender property is used instead.

Return type:

bool

send(project_key, to, subject, body, attachments=None, plain_text=False, sender=None, cc=None, bcc=None)#

Send an email with or without attachments to a list of recipients

channel = client.get_messaging_channel("mail-channel-id")
channel.send("PROJECT_KEY", ["john.doe@dataiku.com", "jane.doe@dataiku.com"], "Hello there!", "<html><body>Some HTML body</body></html>")

channel = client.get_messaging_channel("other-mail-channel-id")
for file in paths:
with open(file) as f:
    # Optionally include file type ("text/csv")
    attachments.append(file, f.read(), "text/csv")
channel.send("PROJECT_KEY", ["joe@dataiku.com"], "Subject", "Body in plain text",  attachments=attachments, False)
Parameters:
  • project_key (str) – project issuing the email. The user must have “Write content” permission on the specified project.

  • to (list[str]) – email addresses of recipients

  • subject (str) – email subject

  • body (str) – email body (in plain text or HTML format)

  • attachments (list[BufferedReader]) – files to be attached to the mail, defaults to None

  • plain_text (bool) – True to send email as plain text, False to send it as HTML. Defaults to False.

  • sender (str) – sender email address. Use None to use the sender defined at the channel level.

  • cc (list[str]) – email addresses of recipients in carbon copy

  • bcc (list[str]) – email addresses of recipients in blind carbon copy

class dataikuapi.dss.messaging_channel.DSSMessagingChannelCreator(channel_type, client)#

Helper to create new messaging channels.

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_id(channel_id)#

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

Parameters:

channel_id (string) – unique ID

create()#

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

Return type:

DSSMessagingChannel

Returns:

The created messaging channel object, such as DSSMessagingChannel, or a DSSMessagingChannel for a mail channel

class dataikuapi.dss.messaging_channel.MailMessagingChannelCreator(channel_type, client)#

Helper to create new mail messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_current_user_as_sender(use_current_user_as_sender)#

Add a “use current user as sender” option to the messaging-channel-to-be-created.

Parameters:

use_current_user_as_sender (bool) – True to use the email of the user triggering the action as sender, False otherwise. Has precedence over ‘sender’ property.

with_sender(sender)#

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

Parameters:

sender (string) – sender email, use an adhoc provided email if not provided.

with_authorized_domains(authorized_domains)#

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

Parameters:

authorized_domains (list[str]) – comma-separated list of authorized domains for “To” addresses.

class dataikuapi.dss.messaging_channel.SMTPMessagingChannelCreator(client)#

Helper to create new SMTP messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_host(host)#

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

Parameters:

host (string) – host to connect to.

with_port(port)#

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

Parameters:

port (long) – port to connect to.

with_ssl(use_ssl)#

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

Parameters:

use_ssl (bool) – True to use SSL, False otherwise.

with_tls(use_tls)#

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

Parameters:

use_tls (bool) – True to use TLS, False otherwise.

with_session_properties(session_properties)#

Add session properties to the messaging-channel-to-be-created.

Parameters:

session_properties (list[dict]) – Array of dictionaries with “key” and “value” keys set for session extra properties.

with_login(login)#

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

Parameters:

login (string) – user login.

with_password(password)#

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

Parameters:

password (string) – user password.

class dataikuapi.dss.messaging_channel.AWSSESMailMessagingChannelCreator(client)#

Helper to create new AWS SES mail messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_access_key(access_key)#

Add an access key to the messaging-channel-to-be-created.

Parameters:

access_key (string) – AWS access key.

with_secret_key(secret_key)#

Add a secret key to the messaging-channel-to-be-created.

Parameters:

secret_key (string) – AWS secret key.

with_region_or_endpoint(region_or_endpoint)#

Add a region or an endpoint to the messaging-channel-to-be-created.

Parameters:

region_or_endpoint (string) – AWS region or custom endpoint.

class dataikuapi.dss.messaging_channel.MicrosoftGraphMailMessagingChannelCreator(client)#

Helper to create new Microsoft Graph mail messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_client_id(client_id)#

Add a client ID to the messaging-channel-to-be-created.

Parameters:

client_id (string) – Microsoft application ID.

with_tenant_id(tenant_id)#

Add a tenant ID to the messaging-channel-to-be-created.

Parameters:

tenant_id (string) – Microsoft directory ID.

with_client_secret(client_secret)#

Add a client secret to the messaging-channel-to-be-created.

Parameters:

client_secret (string) – Account used to sent mails with this channel. Must be a User Principal Name with a valid Microsoft 365 license.

class dataikuapi.dss.messaging_channel.ProxyableMessagingChannelCreator(channel_type, client)#

Helper to create new proxyable messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_proxy(use_proxy)#

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

Parameters:

use_proxy (bool) – True to use DSS’s proxy settings to connect, False otherwise.

class dataikuapi.dss.messaging_channel.WebhookMessagingChannelCreator(channel_type, client)#

Helper to create new webhook-using messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_webhook_url(webhook_url)#

Add a webhook url to the messaging-channel-to-be-created.

Parameters:

webhook_url (string) – webhook URL for “WEBHOOK” mode.

class dataikuapi.dss.messaging_channel.SlackMessagingChannelCreator(client)#

Helper to create new Slack messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_mode(mode)#

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

Parameters:

mode (string) – connection mode. Can be “WEBHOOK” or “API”.

with_authorization_token(authorization_token)#

Add an authorization token to the messaging-channel-to-be-created.

Parameters:

authorization_token (string) – authorization token for “API” mode.

with_channel(channel_id)#

Add a Slack channel ID to the messaging-channel-to-be-created.

Parameters:

channel_id (string) – Slack channel ID.

class dataikuapi.dss.messaging_channel.MSTeamsMessagingChannelCreator(client)#

Helper to create new Microsoft Teams messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_webhook_type(webhook_type)#

Add a webhook type to the messaging-channel-to-be-created.

Parameters:

webhook_type (string) – type of webhook to use. Can be “WORKFLOWS” or “OFFICE365” (legacy).

class dataikuapi.dss.messaging_channel.GoogleChatMessagingChannelCreator(client)#

Helper to create new Google Chat messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_webhook_key(webhook_key)#

Add a webhook key to the messaging-channel-to-be-created.

Parameters:

webhook_key (string) – key parameter for the webhook URL (mandatory if not included in the URL).

with_webhook_token(webhook_token)#

Add a webhook token to the messaging-channel-to-be-created.

Parameters:

webhook_token (string) – token parameter for the webhook URL (mandatory if not included in the URL).

class dataikuapi.dss.messaging_channel.TwilioMessagingChannelCreator(client)#

Helper to create new Twilio messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_account_sid(account_sid)#

Add an account SID to the messaging-channel-to-be-created.

Parameters:

account_sid (string) – Twilio account SID.

with_auth_token(auth_token)#

Add an authorization token to the messaging-channel-to-be-created.

Parameters:

auth_token (string) – authorization token.

with_from_number(from_number)#

Add a “from number” option to the messaging-channel-to-be-created.

Parameters:

from_number (long) – Twilio from number.

class dataikuapi.dss.messaging_channel.ShellMessagingChannelCreator(client)#

Helper to create new shell messaging channels

Important

Do not instantiate directly, use dataikuapi.DSSClient.new_messaging_channel() instead.

with_type(execution_type)#

Add an execution type to the messaging-channel-to-be-created.

Parameters:

execution_type (string) – Type of shell execution. Can be “COMMAND” or “FILE”.

with_command(command)#

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

Parameters:

command (string) – command to execute. In “FILE” mode this string will be passed to the -c switch.

with_script(script)#

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

Parameters:

script (string) – script content to execute for mode “FILE”.