# IBM Cloud Event Notifications Python Admin SDK 0.21.0
Python client library to interact with various [IBM Cloud Event Notifications APIs](https://cloud.ibm.com/apidocs?category=event-notifications).
## Table of Contents
<!-- toc -->
- [Overview](#overview)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Initialize SDK](#initialize-sdk)
- [Using the SDK](#using-the-sdk)
- [Set Environment](#set-environment)
- [Questions](#questions)
- [Issues](#issues)
- [Open source @ IBM](#open-source--ibm)
- [Contributing](#contributing)
- [License](#license)
<!-- tocstop -->
## Overview
The IBM Cloud Event Notifications Python SDK allows developers to programmatically interact with Event Notifications service in IBM cloud.
| Service Name | Module Name | Imported Class Name |
| -------------------------------------------------------------------------------- | ---------------------- | -------------------- |
| [Event Notifications Service](https://cloud.ibm.com/apidocs/event-notifications) | ibm_eventnotifications | EventNotificationsV1 |
## Prerequisites
[ibm-cloud-onboarding]: https://cloud.ibm.com/registration
- An [IBM Cloud][ibm-cloud-onboarding] account.
- An Event Notifications Instance
- Python 3.6 or above.
## Installation
To install, use pip or easy_install:
```bash
pip install --upgrade "ibm_eventnotifications>=0.21.0"
```
or
```bash
easy_install --upgrade "ibm_eventnotifications>=0.21.0"
```
## Initialize SDK
Initialize the sdk to connect with your Event Notifications service instance.
```py
from ibm_eventnotifications.event_notifications_v1 import EventNotificationsV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
# Create an IAM authenticator.
authenticator = IAMAuthenticator('<iam-api-key>')
# Construct the service client.
event_notifications_service = EventNotificationsV1(authenticator=authenticator)
# Set our custom service URL (optional)
event_notifications_service.set_service_url('https://' + region + '.event-notifications.cloud.ibm.com/event-notifications')
```
**To configure service URL for Private Endpoint**
If you enabled service endpoints in your account, you can send API requests over the IBM Cloud private network. In the initialisation, the base endpoint URLs of the IAM(authenticator) & Event Notification(service) should be modified to point to private endpoints.
1. Setting client options programmatically
```py
# Create an IAM authenticator.
authenticator = IAMAuthenticator('<iam-api-key>', 'https://private.iam.cloud.ibm.com')
# Construct the service client.
event_notifications_service = EventNotificationsV1(authenticator=authenticator)
# To configure service URL for Private Endpoint
event_notifications_service.set_service_url('https://private.' + region + '.event-notifications.cloud.ibm.com/event-notifications')
```
2. Using external configuration properties
```py
EVENT_NOTIFICATIONS_AUTH_URL = https://private.iam.cloud.ibm.com/identity/token
```
- region : Region of the Event Notifications Instance
## Using the SDK
SDK Methods to consume
- [Source](#source)
- [Create Source](#create-source)
- [List Sources](#list-sources)
- [Get Source](#get-source)
- [Update Source](#update-source)
- [Delete Source](#delete-source)
- [Topics](#topics)
- [Create Topics](#create-topic)
- [List Topics](#list-topics)
- [Get Topic](#get-topic)
- [Update Topics](#update-topic)
- [Delete Topics](#delete-topic)
- [Destinations](#destinations)
- [Create Destination](#create-destination)
- [List Destinations](#list-destinations)
- [Get Destination](#get-destination)
- [Update Destination](#update-destination)
- [Delete Destination](#delete-destination)
- [Custom Domain_Name_verification](#custom-domain-name-verification)
- [Test Destination](#test-destination)
- [Templates](#templates)
- [Create Template](#create-template)
- [List Templates](#list-templates)
- [Get Template](#get-template)
- [Update Template](#update-template)
- [Delete Template](#delete-template)
- [List Predefined Templates](#list-predefined-templates)
- [Get Predefined Template](#get-predefined-template)
- [Push Destination APIs](#push-destination-apis)
- [Create Destination tag subscription](#create-destination-tag-subscription)
- [List Destination tag subscription](#list-destination-tag-subscription)
- [Delete Destination device tag subscription](#delete-destination-device-tag-subscription)
- [Subscriptions](#subscriptions)
- [Create Subscription](#create-subscription)
- [List Subscriptions](#list-subscriptions)
- [Get Subscription](#get-subscription)
- [Update Subscription](#update-subscription)
- [Delete Subscription](#delete-subscription)
- [Integration](#integration)
- [Create Integration](#create-integration)
- [List Integrations](#list-integrations)
- [Get Integrations](#get-integration)
- [Update Integration](#update-integration)
- [SMTP Configurations](#SMTPConfigurations)
- [Create SMTP Configuration](#create-smtp-configuration)
- [Create SMTP User](#create-smtp-user)
- [Clone SMTP User](#clone-smtp-user)
- [Get SMTP Configuration](#get-smtp-configuration)
- [Get SMTP User](#get-smtp-user)
- [Get SMTP Allowed Ips](#get-smtp-allowed-ips)
- [List SMTP Configurations](#list-smtp-configurations)
- [List SMTP Users](#list-smtp-users)
- [Update SMTP Configuration](#update-smtp-configuration)
- [Update SMTP User](#update-smtp-user)
- [Delete SMTP User](#delete-smtp-user)
- [Delete SMTP Configuration](#delete-smtp-user)
- [Verify SMTP](#verify-smtp)
- [Metrics](#Metrics)
- [Get Metrics](#get-metrics)
- [Send Notifications](#send-notifications)
## Source
### Create Source
```py
source_response = event_notifications_service.create_sources(
<instance-id>, # Event notifications service instance GUID
name=<source-name>,
description=<source-description>,
enabled=False
).get_result()
print(json.dumps(source_response, indent=2))
```
### List Sources
```py
source_list = event_notifications_service.list_sources(
<instance-id>, # Event notifications service instance GUID
).get_result()
print(json.dumps(source_list, indent=2))
```
### Get Source
```py
source = event_notifications_service.get_source(
<instance-id>, # Event notifications service instance GUID
id=<source-id>, # Event notifications service instance Source ID
).get_result()
print(json.dumps(source, indent=2))
```
### Update Source
```py
source = event_notifications_service.update_source(
<instance-id>, # Event notifications service instance GUID
id=<source-id>, # Event notifications service instance Source ID
name=<source-name>,
description=<source-description>,
enabled=True
).get_result()
print(json.dumps(source, indent=2))
```
### Delete Source
```py
response = event_notifications_service.delete_source(
<instance-id>, # Event notifications service instance GUID
id=<source-id>, # Event notifications service instance Source ID
)
```
## Topics
### Create Topic
Filters applied in case of periodic-timer as source. EventTypeFilter, NotificationFilter are mutually exclusive with EventScheduleFilter
```py
event_schedule_filter_attributes_model = {
'starts_at': '2025-01-01T05:15:00.000Z',
'ends_at': '2025-01-01T05:15:00.000Z',
'expression': '* * * * *'
}
rules_model = {
"enabled": True,
"event_schedule_filter": event_schedule_filter_attributes_model,
}
```
```py
rules_model = {
'enabled': False,
'event_type_filter': '$.notification_event_info.event_type == \'cert_manager\'', #Add your event type filter here.
'notification_filter': '$.notification.findings[0].severity == \'MODERATE\'', #Add your notification filter here.
}
# Construct a dict representation of a TopicUpdateSourcesItem model
topic_update_sources_item_model = {
'id': <source_id>,
'rules': [rules_model],
}
topic_response = event_notifications_service.create_topic(
<instance_id>,
name=<topic-name>,
description=<topic-description>,
sources=[topic_update_sources_item_model]
)
print(json.dumps(topic_response, indent=2))
```
### List Topics
```py
topic_list = event_notifications_service.list_topics(
<instance-id>,
).get_result()
print(json.dumps(topic_list, indent=2))
```
### Get Topic
```py
topic = event_notifications_service.get_topic(
<instance-id>, # Event notifications service instance GUID
id=<topic-id>, # Event notifications service instance Topic ID
).get_result()
print(json.dumps(topic, indent=2))
```
### Update Topic
```py
rules_model = {
'enabled': True,
'event_type_filter': '$.notification_event_info.event_type == \'core_cert_manager\'',
'notification_filter': '$.notification.findings[0].severity == \'SEVERE\'',
}
# Construct a dict representation of a TopicUpdateSourcesItem model
topic_update_sources_item_model = {
'id': <source-id>, # Event notifications service instance Source ID
'rules': [rules_model],
}
description = "Updated Topic for GCM notifications"
name = 'Updated Admin Topic Compliance'
topic = event_notifications_service.replace_topic(
<instance-id>, # Event notifications service instance GUID
id=<topic-id>, # Event notifications service instance Topic ID
name=<topic-update-name> # Event notifications service instance Topic Name
description=<topic-update-description> # Event notifications service instance Topic description
sources=[topic_update_sources_item_model]
)
print(json.dumps(topic, indent=2))
rulesModel := &eventnotificationsv1.Rules{
Enabled: core.BoolPtr(true),
EventTypeFilter: core.StringPtr("$.notification_event_info.event_type == 'core_cert_manager'"), # Add your event type filter here.
NotificationFilter: core.StringPtr("$.notification.findings[0].severity == 'SEVERE'"), # Add your notification filter here.
}
```
### Delete Topic
```py
response = event_notifications_service.delete_topic(
<instance-id>,
id=<topic-id>,
)
```
## Destinations
### Create Destination
```py
destination_config_params_model = {
'url': '<destination-config-url>',
'verb': '<destination-config-verb>',
'custom_headers': {'<header-key>': '<header-value>', },
'sensitive_headers': ['<header-key>'],
}
# Construct a dict representation of a DestinationConfig model
destination_config_model = {
'params': destination_config_params_model,
}
destination = event_notifications_service.create_destination(
<instance-id>,
<destination-name>,
type=<destination-type>,
description=description,
config=destination_config_model
).get_result()
print(json.dumps(destination, indent=2))
```
Among the supported destinations, if you need to create Push Notification destinations, you have the additional option of choosing a destination of production type or pre-production type.
Set `pre_prod` boolean parameter to _true_ to configure destination as pre-production destination else set the value as _false_.
Supported destinations are Android, iOS, Chrome, Firefox, and Safari.
### List Destinations
```py
destination_list = event_notifications_service.list_destinations(
<instance-id>,
).get_result()
print(json.dumps(destination_list, indent=2))
```
### Get Destination
```py
destination = event_notifications_service.get_destination(
<instance-id>, # Event notifications service instance GUID
id=<destination-id>, # Event notifications service instance Destination ID
).get_result()
print(json.dumps(destination, indent=2))
```
### Update Destination
```py
# Construct a dict representation of a DestinationConfigParamsWebhookDestinationConfig model
destination_config_params_model = {
'url': '<destination-config-update-url>',
'verb': '<destination-config-update-verb>',
'sensitive_headers': ['<header-key>'],
}
# Construct a dict representation of a DestinationConfig model
destination_config_model = {
'params': destination_config_params_model,
}
destination = event_notifications_service.update_destination(
<instance-id>, # Event notifications service instance GUID
id=<destination-id>, # Event notifications service instance Destination ID
name=<destination-update-name>,
description=<destination-update-description>,
config=destination_config_model
).get_result()
print(json.dumps(destination, indent=2))
```
### Delete Destination
```py
response = event_notifications_service.delete_destination(
<instance-id>, # Event notifications service instance GUID
id=<destination-id>, # Event notifications service instance Destination ID
)
```
### Test Destination
This functionality allows you to test a destination. The feature simplifies the process of verifying whether a destination is functioning correctly.
Currently, this functionality supports following destinations:
1. Slack
2. PagerDuty
3. ServiceNow
4. Microsoft® Teams
5. IBM Cloud Code Engine
6. IBM Cloud Object Storage
7. Webhook
```py
test_destination_response = event_notifications_service.test_destination(
<instance-id>,
id=<destination-id>
)
```
Once the test is completed, you will be presented with the results. These results will typically include:
- **Status**: Whether the test is successful or failed
- **Response Code**: If test fails, then the response code sent from the end destination client is returned
- **Response Message**: If test fails, then the response message sent from the end destination client is returned
In case of `webhook` destination test response also returns notification_id, the status of notification_id will represent the webhook test result. Follow below additional steps to get status result of webhook destination test
```python
webhook_notification_status = event_notifications_service.get_notifications_status(
instance_id,
id=<notification-id>
)
webhook_status = webhook_notification_status.get_result()
```
The response of `get_notifications_status` will have success, failed or inprogress status. The Notification ID will be valid only for 1 minute to fetch the status of test. The status response as **success** will conclude successful test of webhook destination
### Custom Domain Name Verification
After creation of the custom email destination with your domain name, make sure its validated for the right ownership.
This can be done with SPF and DKIM verification.
- Sender Policy Framework (SPF), which is used to authenticate the sender of an email. SPF specifies the mail servers that are allowed to send email for your domain.
- DomainKeys Identified Mail (DKIM), which allows an organization to take responsibility for transmitting a message by signing it. DKIM allows
the receiver to check the email that claimed to have come from a specific domain, is authorized by the owner of that domain.
```py
verification_response = event_notifications_service.update_verify_destination(
<instance-id>, # Event notifications service instance GUID
id=<destination-id>, # Event notifications service instance Destination ID
type=<verification-type>, # verification type spf/dkim
).get_result()
```
## Templates
Template is a pre-defined layout, that may include content like images, text and dynamic content based on event. Rather than creating a new content from scratch each time, you can use a template as a base and configure them in subscription.
supports the following templates:
- Custom Email notification
- Custom Email invitation
### Create Template
#### Custom Email Template
```py
template_config_model = {
'body': 'base 64 encoded html content',
'subject': 'Hi this is invitation for invitation message',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For custom email supported template type values: smtp_custom.invitation, smtp_custom.notification
#### Slack Template
```py
template_config_model = {
'body': 'base 64 encoded json body',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For slack template supported template type value: slack.notification
#### Webhook Template
```py
template_config_model = {
'body': 'base 64 encoded json body',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For webhook template supported template type value: webhook.notification
#### PagerDuty Template
```py
template_config_model = {
'body': 'base 64 encoded json body',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For pagerduty template supported template type value: pagerduty.notification
#### EventStreams Template
```py
template_config_model = {
'body': 'base 64 encoded json body',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For Event Streams template supported template type value: event_streams.notification
#### CodeEngine Template
```py
template_config_model = {
'body': 'base 64 encoded json body',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For Code Engine template supported template type values: ibmceapp.notification and ibmcejob.notification
#### App Configuration Template
```py
template_config_model = {
'body': 'base 64 encoded json body',
}
create_template_response = event_notifications_service.create_template(
instance_id=<instance-id>,
name=<template-name>,
type=<template-type>,
params=template_config_model,
description=<template-description>
).get_result()
```
For App Configuration template supported template type values: app_configuration.notification
### List Templates
```py
list_templates_response = event_notifications_service.list_templates(
instance_id=<instance-id>,
limit=<limit>,
offset=<offset>,
search=<search>
)
templates_list = list_templates_response.get_result()
```
### Get Template
```py
get_template_response = event_notifications_service.get_template(
instance_id=<instance-id>,
id=<template_id>
).get_result()
```
### List Predefined Templates
```py
list_predefined_templates_response = self.event_notifications_service.list_pre_defined_templates(
instance_id=<instance-id>,
source=<source-type>,
type=<destination-type>,
)
list_predefined_templates = list_predefined_templates_response.get_result()
```
### Get Predefined Template
```py
get_predefined_template_response = self.event_notifications_service.get_pre_defined_template(
instance_id=<instance-id>,
id=<template_id>,
)
get_predefined_template = get_predefined_template_response.get_result()
```
### Update Template
#### Update Email Template
```py
template_config_model = {
'body': 'base 64 encode html content',
'subject': 'Hi this is invitation for invitation message',
}
replace_template_response = event_notifications_service.replace_template(
instance_id=<instance-id>,
id=<template_id>
name=<template_name>,
type=<template-type>,
description=<template-description>,
params=template_config_model
).get_result()
```
#### Update slack/webhook Template/PagerDuty Template
```py
template_config_model = {
'body': 'base 64 encode json content',
}
replace_template_response = event_notifications_service.replace_template(
instance_id=<instance-id>,
id=<template_id>
name=<template_name>,
type=<template-type>,
description=<template-description>,
params=template_config_model
).get_result()
```
For webhook template supported template type value: webhook.notification
For pagerduty template supported template type value: pagerduty.notification
#### Update EventStreams Template
```py
template_config_model = {
'body': 'base 64 encode json content',
}
replace_template_response = event_notifications_service.replace_template(
instance_id=<instance-id>,
id=<template_id>
name=<template_name>,
type=<template-type>,
description=<template-description>,
params=template_config_model
).get_result()
```
For Event Streams template supported template type value: event_streams.notification
#### Update CodeEngine Template
```py
template_config_model = {
'body': 'base 64 encode json content',
}
replace_template_response = event_notifications_service.replace_template(
instance_id=<instance-id>,
id=<template_id>
name=<template_name>,
type=<template-type>,
description=<template-description>,
params=template_config_model
).get_result()
```
For Code Engine template supported template type values: ibmceapp.notification and ibmcejob.notification
#### Update App Configuration Template
```py
template_config_model = {
'body': 'base 64 encode json content',
}
replace_template_response = event_notifications_service.replace_template(
instance_id=<instance-id>,
id=<template_id>
name=<template_name>,
type=<template-type>,
description=<template-description>,
params=template_config_model
).get_result()
```
For App Configuration template supported template type values: app_configuration.notification
### Delete Template
```py
delete_template_response = event_notifications_service.delete_template(
instance_id=<instance-id>,
id=<template_id>
).get_result()
```
## Push Destination APIs
### Create Destination tag subscription
```py
tag_subscription = _event_notifications_service.create_tags_subscription(
<instance-id>, # Event notifications service instance GUID
<destination-id>, # Event notifications service Destintaion ID
<device_id>, # Event notifications service Device ID
<tag_name> # Event notifications service Tag Name
).get_result()
print(json.dumps(tag_subscription, indent=2))
```
### List Destination tag subscription
```py
subscription = _event_notifications_service.list_tags_subscription(
<instance-id>, # Event notifications service instance GUID
<destination-id> # Event notifications service Destintaion ID
).get_result()
print(json.dumps(subscription, indent=2))
```
### Delete Destination device tag subscription
```py
response = _event_notifications_service.delete_tags_subscription(
<instance-id>, # Event notifications service instance GUID
<destination-id>, # Event notifications service Destintaion ID
<device_id>, # Event notifications service Device ID
<tag_name> # Event notifications service Tag Name
).get_result()
print(json.dumps(response, indent=2))
```
## Subscriptions
### Create Subscription
```py
#`While Creating Subscription use any of one option from webhook, or email`
subscription_create_attributes_model = {
'signing_enabled': False,
'template_id_notification': '<webhook-template-id>',
}
subscription = event_notifications_service.create_subscription(
<instance-id>, # Event notifications service instance GUID
name,
<destination-id>, # Event notifications service instance Destination ID
<topic-id> # Event notifications service instance Topic ID
attributes=subscription_create_attributes_model,
description=<subscription-description>
).get_result()
print(json.dumps(subscription, indent=2))
```
### ⚠️ Special Consideration for App Configuration Destination
When creating or updating a subscription for an **App Configuration** destination, the `attributes` object has a specific rule:
- You must include **either** `feature_flag_enabled` **or** `template_id_notification`
- You **cannot** include both properties together
This ensures that a subscription is created for the correct use case — either **feature flag evaluation** or **notification templating**, but not both at once.
#### ✅ Valid Example (Feature Flag Evaluation)
```py
subscription_create_attributes_model_json = {
'feature_flag_enabled': True,
}
subscription_create_attributes_model = SubscriptionCreateAttributesAppConfigurationAttributes.from_dict(
subscription_create_attributes_model_json
)
```
#### ✅ Valid Example (template association)
```py
subscription_create_attributes_model_json = {
'template_id_notification': <template-id>,
}
subscription_create_attributes_model = SubscriptionCreateAttributesAppConfigurationAttributes.from_dict(
subscription_create_attributes_model_json
)
```
#### ❌ Invalid Example (Not Allowed)
```py
subscription_create_attributes_model_json = {
'template_id_notification': <template-id>,
'feature_flag_enabled': True,
}
subscription_create_attributes_model = SubscriptionCreateAttributesAppConfigurationAttributes.from_dict(
subscription_create_attributes_model_json
)
```
### List Subscriptions
```py
subscription_list = event_notifications_service.list_subscriptions(
<instance-id>, # Event notifications service instance GUID
).get_result()
print(json.dumps(subscription_list, indent=2))
```
### Get Subscription
```py
subscription = event_notifications_service.get_subscription(
<instance-id>, # Event notifications service instance GUID
id=<subscription-id>, # Event notifications service instance Subscription ID
).get_result()
print(json.dumps(subscription, indent=2))
```
### Update Subscription
```py
subscription_update_attributes_model = {
'signing_enabled': True,
'template_id_notification': '<webhook-template-id>',
}
subscription = event_notifications_service.update_subscription(
<instance-id>, # Event notifications service instance GUID
id=<subscription-id>, # Event notifications service instance Subscription ID
name=<subscription-update-name>,
description=<subscription-update-description>,
attributes=subscription_update_attributes_model
).get_result()
print(json.dumps(subscription, indent=2))
```
### Delete Subscription
```py
response = event_notifications_service.delete_subscription(
<instance-id>, # Event notifications service instance GUID
id=<subscription-id>, # Event notifications service instance Subscriptions ID
)
```
# Integration
### Create Integration
```py
integration_metadata = {
"endpoint": cos_end_point,
"crn": cos_instance_crn,
"bucket_name": cos_bucket_name,
}
create_integration_response = self.event_notifications_service.create_integration(
instance_id,
type="collect_failed_events",
metadata=integration_metadata,
)
integration_response = create_integration_response.get_result()
```
### List Integrations
```py
list_integrations_response = event_notifications_service.list_integrations(
<instance-id>,
<limit>,
<offset>,
<search>,
)
integration_response = list_integrations_response.get_result()
```
### Get Integration
```py
get_integration_response = event_notifications_service.get_integration(
<instance_id>,
id=<integration_id>
)
integration_response = get_integration_response.get_result()
```
### Update Integration
For kms/hs-crypto
```py
integration_metadata = {
'endpoint': '<end-point>',
'crn': '<crn>',
'root_key_id': '<root-key-id>'
}
update_integration_response = event_notifications_service.replace_integration(
<instance_id>,
type="kms/hs-crypto",
id=<integration_id>,
metadata=integration_metadata
)
integration_response = update_integration_response.get_result()
```
For Cloud Object Storage
```py
integration_metadata = {
'endpoint': '<end-point>',
'crn': '<crn>',
'bucket-name': '<cos-bucket-name>'
}
update_integration_response = event_notifications_service.replace_integration(
<instance_id>,
type="collect_failed_events",
id=<integration_id>,
metadata=integration_metadata
)
integration_response = update_integration_response.get_result()
```
## SMTPConfigurations
### Create SMTP Configuration
```py
create_smtp_config_response = self.event_notifications_service.create_smtp_configuration(
instance_id=<instance_id>,
name=<smtp-config-name>,
domain=<smtp-domain-name>,
description=<smtp-description>
)
smtp_response = create_smtp_config_response.get_result()
```
### Create SMTP User
```py
create_smtp_user_response = self.event_notifications_service.create_smtp_user(
instance_id=<instance-id>,
id=<smtp-config-id>,
description=<smtp-description>
)
create_user_response = create_smtp_user_response.get_result()
```
### Clone SMTP User
```py
clone_smtp_user_response = self.event_notifications_service.create_smtp_user(
instance_id=<instance-id>,
id=<smtp-config-id>,
username_to_clone=<smtp_user_to_clone>,
)
clone_user_response = create_smtp_user_response.get_result()
```
### Get SMTP Configuration
```py
get_smtp_config_response = self.event_notifications_service.get_smtp_configuration(
instance_id=<instance-id>,
id=<smtp_config_id>,
)
get_smtp_config_response = get_smtp_config_response.get_result()
```
### Get SMTP User
```py
get_smtp_user_response = self.event_notifications_service.get_smtp_user(
instance_id=<instance-id>,
id=<smtp_config_id>,
user_id=<smtp_user_id>
)
get_smtp_user_response = get_smtp_user_response.get_result()
```
### Get SMTP Allowed Ips
```py
get_smtp_allowed_ip_response = self.event_notifications_service.get_smtp_allowed_ips(
instance_id=<instance-id>,
id=<smtp_config_id>,
)
get_smtp_allowed_ip_response = get_smtp_allowed_ip_response.get_result()
```
### List SMTP Configurations
```py
list_smtp_config_response = self.event_notifications_service.list_smtp_configurations(
instance_id=<instance-id>,
limit=<limit>,
offset=<offset>,
search=<search>,
)
list_smtp_config_response = list_smtp_config_response.get_result()
```
### List SMTP Users
```py
list_smtp_user_response = self.event_notifications_service.list_smtp_users(
instance_id=<instance-id>,
id=<smtp_config_id>,
limit=<limit>,
offset=<offset>,
search=<search>,
)
list_smtp_user_response = list_smtp_user_response.get_result()
```
### Update SMTP Configuration
```py
update_smtp_config_response = self.event_notifications_service.update_smtp_configuration(
instance_id=<instance-id>,
id=<smtp_config_id>,
name=<smtp-name>,
description=<smtp-description>,
)
update_smtp_config_response = update_smtp_config_response.get_result()
```
### Update SMTP User
```py
update_smtp_user_response = self.event_notifications_service.update_smtp_user(
instance_id=<instance-id>,
id=<smtp_config_id>,
user_id=<smtp_user_id>,
description=<smtp-description>,
)
update_smtp_user_response = update_smtp_user_response.get_result()
```
### Delete SMTP User
```py
delete_smtp_user_response = self.event_notifications_service.delete_smtp_user(
instance_id=<instance-id>,
id=<smtp_config_id>,
user_id=<user-id>
)
print(json.dumps(delete_smtp_user_response, indent=2))
```
### Delete SMTP Configuration
```py
delete_smtp_config_response = self.event_notifications_service.delete_smtp_configuration(
instance_id=<instance-id>,
id=<smtp_config_id>,
)
print(json.dumps(delete_smtp_config_response, indent=2))
```
### Verify SMTP
```py
update_verify_smtp_response = self.event_notifications_service.update_verify_smtp(
instance_id=<instance-id>,
type=<verification-type>,
id=<smtp_config_id>
)
verify_response = update_verify_smtp_response.get_result()
```
supported verification types are dkim,spf and en_authorization.
## Metrics
### Get Metrics
```py
get_metrics_response = self.event_notifications_service.get_metrics(
instance_id=<instance-id>,
destination_type="smtp_custom",
gte=<gte-timestamp>,
lte=<lte-timestamp>,
destination_id=<destination-id>,
email_to=<email-to>,
notification_id=<notification-id>,
subject=<subject>
)
metric_response = get_metrics_response.get_result()
```
### Send Notifications
```py
notification_devices_model = {
'fcm_devices': ['<fcm-device-ids>'],
'apns_devices': ['<apns-device-ids>'],
'user_ids': ['<user-ids>'],
'tags': ['<tag-names>'],
'platforms': ['<device-platforms>'],
}
notification_apns_body_model = {
"aps": {
"alert": "<notification-message>",
"badge": 5,
},
}
notification_fcm_body_model = {
'message': {
'android': {
'notification': {
'title': '<notification-title>',
'body': '<notification-message>',
},
'data': {
'name': 'Robert',
'description': 'notification for the Poker',
},
},
},
}
message_apns_headers = {
"apns-collapse-id": "<apns-apns-collapse-id-value>",
}
notificationSafariBodymodel = {
'saf': {
'alert': 'Game Request',
'badge': 5,
},
}
notification_id = "<notification-id>"
notification_severity = "<notification-severity>"
type_value = "<notification-type>"
notifications_source = "<notification-source>"
htmlbody = '"Hi ,<br/>Certificate expiring in 90 days.<br/><br/>Please login to ' \
'<a href="https: //cloud.ibm.com/security-compliance/dashboard">' \
'Security and Complaince dashboard</a> to find more information<br/>"'
mailto = '[\"abc@ibm.com\", \"def@us.ibm.com\"]'
smsto = '[\"+911234567890\", \"+911224567890\"]'
slackto = '[\"C07FALXBH4G\"]'
mms = '{"content": "akajdklahl", "content_type": "image/png"}'
templates = '["149b0e11-8a7c-4fda-a847-5d79e01b71dc"]'
markdown_content = "**Event Summary** \n\n**Toolchain ID:** `4414af34-a5c7-47d3-8f05-add4af6d78a6` \n**Content Type:** `application/json`\n\n---\n\n *Pipeline Run Details*\n\n- **Namespace:** `PR`\n- **Trigger Name:** `manual`\n- **Triggered By:** `nitish.kulkarni3@ibm.com`\n- **Build Number:** `343`\n- **Pipeline Link:** [View Pipeline Run](https://cloud.ibm.com/devops/pipelines/tekton/e9cd5aa3-a3f2-4776-8acc-26a35922386e/runs/f29ac6f5-bd2f-4a26-abb8-4249be8dbab7?env_id=ibm:yp:us-south)"
notification_create_model = {
'ibmenseverity': notification_severity,
'ibmenfcmbody': json.dumps(notification_fcm_body_model),
'ibmenpushto': json.dumps(notification_devices_model),
'ibmenapnsbody': json.dumps(notification_apns_body_model),
'ibmensourceid': source_id,
'ibmendefaultshort': 'short info',
'ibmendefaultlong': 'long info',
'ibmensafaribody': json.dumps(notificationSafariBodymodel),
'ibmenhtmlbody': htmlbody,
"ibmenmarkdown": markdown_content,
'ibmensubject': 'Findings on IBM Cloud Security Advisor',
'ibmenmailto': mailto,
'ibmensmsto': smsto,
'ibmenslackto': slackto,
'ibmenmms': mms,
"ibmentemplates": templates,
'id': notification_id,
'source': notifications_source,
'type': type_value,
'specversion': '1.0',
'time': '2019-01-01T12:00:00.000Z',
}
send_notifications_response = event_notifications_service.send_notifications(
instance_id,
body=notification_create_model
).get_result()
```
<details open>
<summary>Send Notifications Variables</summary>
<br>
- **ibmenpushto** - Set up the push notifications targets.
- **user_ids** (_Array of String_) - Send notification to the specified userIds.
- **fcm_devices** (_Array of String_) - Send notification to the list of specified Android devices.
- **apns_devices** (_Array of String_) - Send notification to the list of specified iOS devices.
- **chrome_devices** (_Array of String_) - Send notification to the list of specified Chrome devices.
- **firefox_devices** (_Array of string_) - Send notification to the list of specified Firefox devices.
- **tags** (_Array of string_) - Send notification to the devices that have subscribed to any of these tags.
- **platforms** (_Array of string_) - Send notification to the devices of the specified platforms.
- Pass 'G' for google (Android) devices.
- Pass 'A' for iOS devices.
- Pass 'WEB_FIREFOX' for Firefox browser.
- Pass 'WEB_CHROME' for Chrome browser.
- **Event Notifications SendNotificationsOptions** - Event Notifications Send Notifications method.
- **instance_id\*** (_string_) - Unique identifier for IBM Cloud Event Notifications instance.
- **ibmenseverity** (_string_) - Severity for the notifications. Some sources can have the concept of an Event severity. Hence a handy way is provided to specify a severity of the event. example: LOW, HIGH, MEDIUM
- **id\*** (_string_) - A unique identifier that identifies each event. source+id must be unique. The backend should be able to uniquely track this id in logs and other records. Send unique ID for each send notification. Same ID can be sent in case of failure of send notification. source+id will be logged in IBM Cloud Logging service. Using this combination we will be able to trace the event movement from one system to another and will aid in debugging and tracing.
- **source\*** (_string_) - Source of the notifications. This is the identifier of the event producer. A way to uniquely identify the source of the event. For IBM Cloud services this is the crn of the service instance producing the events. For API sources this can be something the event producer backend can uniquely identify itself with.
- **ibmensourceid\*** (_string_) - This is the ID of the source created in EN. This is available in the EN UI in the "Sources" section.
- **type** (_string_) - This describes the type of event. It is of the form <event-type-name>:<sub-type> This type is defined by the producer. The event type name has to be prefixed with the reverse DNS names so the event type is uniquely identified. The same event type can be produced by 2 different sources. It is highly recommended to use hyphen - as a separator instead of \_.
- **data** (_string_) - The payload for webhook notification. If data is added as part of payload then its mandatory to add **datacontenttype**.
- **datacontenttype** - The notification content type. example: application/json
- **time** (_string_) - Time of the notifications. UTC time stamp when the event occurred. Must be in the RFC 3339 format.
- **ibmenpushto** (_string_) - Targets for the FCM notifications. This contains details about the destination where you want to send push notification. This attribute is mandatory for successful delivery from an Android FCM or APNS destination.
- **ibmenfcmbody** (_string_) - Set payload string specific to Android platform [Refer this FCM official [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support)].
- **ibmenhuaweibody** (_string_) - Set payload string specific to Android platform [Refer this FCM official [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support)].
- **ibmenapnsbody** (_string_) - Set payload string specific to iOS platform [Refer this APNs official doc [link](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html)].
- **ibmensafaribody** (_string_) - Set payload string specific to safari platform [Refer this Safari official doc [link](https://developer.huawei.com/consumer/en/hms/huawei-pushkit)].
- **ibmenapnsheaders** (_string_) - Set headers required for the APNs message [Refer this APNs official [link](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns)(Table 1 Header fields for a POST request)]
- **ibmenchromebody** (_string_) - Message body for the Chrome notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
- **ibmenfirefoxbody** (_string_) - Message body for the Firefox notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
- **ibmenchromeheaders** (_string_) - Headers for the Chrome notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
- **ibmenfirefoxheaders** (_string_) - Headers for the Firefox notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
- **ibmendefaultshort\*** (_string_) - Default short text for the message.
- **ibmendefaultlong\*** (_string_) - Default long text for the message.
- **specversion\*** (_string_) - Spec version of the Event Notifications. Default value is `1.0`.
- **ibmenhtmlbody** (_string_) - The html body of notification for email.
- **ibmenmailto** (_Array of string_) - Array of email ids to which the notification to be sent.
- **ibmensmsto** (_Array of string_) - Array of SMS numbers to which the notification to be sent.
- **ibmensmstext** (_string_) - SMS text to be sent.
- **ibmenslackto** (_Array of string_) - Array of Slack channel/member ids to which the notification to be sent.
- **ibmentemplates** (_Array of string_) - Array of template IDs that needs to be applied while sending notificatin for custom domain email and slack destination.
- **ibmenmarkdown** (_string_) - The markdown content of pretty formatting.
Note: variable with \* represents the mandatory attribute.
</details>
## Set Environment
Find `event_notifications_v1.env.hide` in the repo and rename it to `event_notifications_v1.env`. After that add the values for,
- `EVENT_NOTIFICATIONS_URL` - Add the Event Notifications service instance Url.
- `EVENT_NOTIFICATIONS_APIKEY` - Add the Event Notifications service instance apikey.
- `EVENT_NOTIFICATIONS_GUID` - Add the Event Notifications service instance GUID.
**Optional**
- `EVENT_NOTIFICATIONS_AUTH_URL` - Add the IAM url if you are using IBM test cloud.
- `EVENT_NOTIFICATIONS_FCM_KEY` - Add firebase server key for Android FCM destination.
- `EVENT_NOTIFICATIONS_FCM_ID` - Add firebase sender Id for Android FCM destination.
- `EVENT_NOTIFICATIONS_FCM_PROJECT_ID` - fcm project id
- `EVENT_NOTIFICATIONS_FCM_CLIENT_EMAIL` - fcm client email
- `EVENT_NOTIFICATIONS_FCM_PRIVATE_KEY` - fcm private key
- `EVENT_NOTIFICATIONS_SAFARI_CERTIFICATE` - safari certificate path
- `EVENT_NOTIFICATIONS_SNOW_CLIENT_ID` - service now client id
- `EVENT_NOTIFICATIONS_SNOW_CLIENT_SECRET` - service now client secret
- `EVENT_NOTIFICATIONS_SNOW_USER_NAME` - service now user name
- `EVENT_NOTIFICATIONS_SNOW_PASSWORD` - service now password
- `EVENT_NOTIFICATIONS_SNOW_INSTANCE_NAME` - service now instance name
- `EVENT_NOTIFICATIONS_COS_BUCKET_NAME` - cloud object storage bucket name
- `EVENT_NOTIFICATIONS_COS_INSTANCE` - cloud object storage instance id
- `EVENT_NOTIFICATIONS_COS_INSTANCE_CRN` - cloud object storage instance crn
- `EVENT_NOTIFICATIONS_COS_ENDPOINT` - cloud object storage end point
- `EVENT_NOTIFICATIONS_CODE_ENGINE_URL` - code engine app url
- `EVENT_NOTIFICATIONS_CODE_ENGINE_PROJECT_CRN` - code engine project crn
- `EVENT_NOTIFICATIONS_HUAWEI_CLIENT_SECRET` - huawei client secret
- `EVENT_NOTIFICATIONS_HUAWEI_CLIENT_ID` - huawei client id
- `EVENT_NOTIFICATIONS_SLACK_URL` - slack webhook url
- `EVENT_NOTIFICATIONS_MS_TEAMS_URL` - msteams webhook url
- `EVENT_NOTIFICATIONS_PD_ROUTING_KEY` - pagerduty routing key
- `EVENT_NOTIFICATIONS_PD_API_KEY` - pagerduty api key
- `EVENT_NOTIFICATIONS_TEMPLATE_BODY` - base 64 encoded html content
- `EVENT_NOTIFICATIONS_SLACK_TEMPLATE_BODY` - base 64 encoded json body
- `EVENT_NOTIFICATIONS_WEBHOOK_TEMPLATE_BODY` - base 64 encoded json body
- `EVENT_NOTIFICATIONS_SCHEDULER_SOURCE_ID` - periodic timer source id
- `EVENT_NOTIFICATIONS_PAGERDUTY_TEMPLATE_BODY` - base 64 encoded json body for pagerduty destination
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_TEMPLATE_BODY` - base 64 encoded json body for event streams destination
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_CRN` - Event Streams instance CRN
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_TOPIC` - Event Streams instance Topic name
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_ENDPOINT` - Event streams end point
- `EVENT_NOTIFICATIONS_CODE_ENGINE_APP_TEMPLATE_BODY` - base 64 encoded json body for Code Engine Application
- `EVENT_NOTIFICATIONS_CODE_ENGINE_JOB_TEMPLATE_BODY` - base 64 encoded json body for Code Engine Job
- `EVENT_NOTIFICATIONS_APP_CONFIG_CRN` - CRN of App Configuration instance
- `EVENT_NOTIFICATIONS_APP_CONFIG_TEMPLATE_BODY` - base 64 encoded json body for App Configuration
- `EVENT_NOTIFICATIONS_SMTP_USER_TO_CLONE` - SMTP username to be cloned
## Questions
If you are having difficulties using this SDK or have a question about the IBM Cloud services,
please ask a question
[Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-cloud).
## Issues
If you encounter an issue with the project, you are welcome to submit a
[bug report](https://github.com/IBM/event-notifications-python-admin-sdk/issues).
Before that, please search for similar issues. It's possible that someone has already reported the problem.
## ⚠️ Deprecation Notice (Attributes)
### Pagerduty Destination Configuration
> The following attribute from interface DestinationConfigOneOfPagerDutyDestinationConfig is **deprecated** and will be removed in a future release:
- `api_key`
This attribute no longer recommended for use and may not be supported in upcoming versions of the SDK. Only `routing_key` is expected to be passed.
## Open source @ IBM
Find more open source projects on the [IBM Github Page](http://ibm.github.io/)
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md).
## License
This SDK is released under the Apache 2.0 license.
The license's full text can be found in [LICENSE](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/IBM/event-notifications-python-admin-sdk",
"name": "ibm-eventnotifications",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "ibm_eventnotifications",
"author": "IBM",
"author_email": "Notifications-prod@ibm.com",
"download_url": "https://files.pythonhosted.org/packages/72/4d/fd00a91f71ee1ff2e4127c063214f0baa4a3a96b6ea8186559d80345f0b8/ibm_eventnotifications-0.21.0.tar.gz",
"platform": null,
"description": "# IBM Cloud Event Notifications Python Admin SDK 0.21.0\n\nPython client library to interact with various [IBM Cloud Event Notifications APIs](https://cloud.ibm.com/apidocs?category=event-notifications).\n\n## Table of Contents\n\n<!-- toc -->\n\n- [Overview](#overview)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Initialize SDK](#initialize-sdk)\n- [Using the SDK](#using-the-sdk)\n- [Set Environment](#set-environment)\n- [Questions](#questions)\n- [Issues](#issues)\n- [Open source @ IBM](#open-source--ibm)\n- [Contributing](#contributing)\n- [License](#license)\n\n<!-- tocstop -->\n\n## Overview\n\nThe IBM Cloud Event Notifications Python SDK allows developers to programmatically interact with Event Notifications service in IBM cloud.\n\n| Service Name | Module Name | Imported Class Name |\n| -------------------------------------------------------------------------------- | ---------------------- | -------------------- |\n| [Event Notifications Service](https://cloud.ibm.com/apidocs/event-notifications) | ibm_eventnotifications | EventNotificationsV1 |\n\n## Prerequisites\n\n[ibm-cloud-onboarding]: https://cloud.ibm.com/registration\n\n- An [IBM Cloud][ibm-cloud-onboarding] account.\n- An Event Notifications Instance\n- Python 3.6 or above.\n\n## Installation\n\nTo install, use pip or easy_install:\n\n```bash\npip install --upgrade \"ibm_eventnotifications>=0.21.0\"\n```\n\nor\n\n```bash\neasy_install --upgrade \"ibm_eventnotifications>=0.21.0\"\n```\n\n## Initialize SDK\n\nInitialize the sdk to connect with your Event Notifications service instance.\n\n```py\nfrom ibm_eventnotifications.event_notifications_v1 import EventNotificationsV1\nfrom ibm_cloud_sdk_core.authenticators import IAMAuthenticator\n\n # Create an IAM authenticator.\nauthenticator = IAMAuthenticator('<iam-api-key>')\n\n# Construct the service client.\nevent_notifications_service = EventNotificationsV1(authenticator=authenticator)\n\n# Set our custom service URL (optional)\nevent_notifications_service.set_service_url('https://' + region + '.event-notifications.cloud.ibm.com/event-notifications')\n\n```\n\n**To configure service URL for Private Endpoint**\n\nIf you enabled service endpoints in your account, you can send API requests over the IBM Cloud private network. In the initialisation, the base endpoint URLs of the IAM(authenticator) & Event Notification(service) should be modified to point to private endpoints.\n\n1. Setting client options programmatically\n\n```py\n # Create an IAM authenticator.\nauthenticator = IAMAuthenticator('<iam-api-key>', 'https://private.iam.cloud.ibm.com')\n\n# Construct the service client.\nevent_notifications_service = EventNotificationsV1(authenticator=authenticator)\n# To configure service URL for Private Endpoint\nevent_notifications_service.set_service_url('https://private.' + region + '.event-notifications.cloud.ibm.com/event-notifications')\n```\n\n2. Using external configuration properties\n\n```py\n EVENT_NOTIFICATIONS_AUTH_URL = https://private.iam.cloud.ibm.com/identity/token\n```\n\n- region : Region of the Event Notifications Instance\n\n## Using the SDK\n\nSDK Methods to consume\n\n- [Source](#source)\n - [Create Source](#create-source)\n - [List Sources](#list-sources)\n - [Get Source](#get-source)\n - [Update Source](#update-source)\n - [Delete Source](#delete-source)\n- [Topics](#topics)\n - [Create Topics](#create-topic)\n - [List Topics](#list-topics)\n - [Get Topic](#get-topic)\n - [Update Topics](#update-topic)\n - [Delete Topics](#delete-topic)\n- [Destinations](#destinations)\n - [Create Destination](#create-destination)\n - [List Destinations](#list-destinations)\n - [Get Destination](#get-destination)\n - [Update Destination](#update-destination)\n - [Delete Destination](#delete-destination)\n - [Custom Domain_Name_verification](#custom-domain-name-verification)\n - [Test Destination](#test-destination)\n- [Templates](#templates)\n - [Create Template](#create-template)\n - [List Templates](#list-templates)\n - [Get Template](#get-template)\n - [Update Template](#update-template)\n - [Delete Template](#delete-template)\n - [List Predefined Templates](#list-predefined-templates)\n - [Get Predefined Template](#get-predefined-template)\n- [Push Destination APIs](#push-destination-apis)\n - [Create Destination tag subscription](#create-destination-tag-subscription)\n - [List Destination tag subscription](#list-destination-tag-subscription)\n - [Delete Destination device tag subscription](#delete-destination-device-tag-subscription)\n- [Subscriptions](#subscriptions)\n - [Create Subscription](#create-subscription)\n - [List Subscriptions](#list-subscriptions)\n - [Get Subscription](#get-subscription)\n - [Update Subscription](#update-subscription)\n - [Delete Subscription](#delete-subscription)\n- [Integration](#integration)\n - [Create Integration](#create-integration)\n - [List Integrations](#list-integrations)\n - [Get Integrations](#get-integration)\n - [Update Integration](#update-integration)\n- [SMTP Configurations](#SMTPConfigurations)\n - [Create SMTP Configuration](#create-smtp-configuration)\n - [Create SMTP User](#create-smtp-user)\n - [Clone SMTP User](#clone-smtp-user)\n - [Get SMTP Configuration](#get-smtp-configuration)\n - [Get SMTP User](#get-smtp-user)\n - [Get SMTP Allowed Ips](#get-smtp-allowed-ips)\n - [List SMTP Configurations](#list-smtp-configurations)\n - [List SMTP Users](#list-smtp-users)\n - [Update SMTP Configuration](#update-smtp-configuration)\n - [Update SMTP User](#update-smtp-user)\n - [Delete SMTP User](#delete-smtp-user)\n - [Delete SMTP Configuration](#delete-smtp-user)\n - [Verify SMTP](#verify-smtp)\n- [Metrics](#Metrics)\n - [Get Metrics](#get-metrics)\n- [Send Notifications](#send-notifications)\n\n## Source\n\n### Create Source\n\n```py\nsource_response = event_notifications_service.create_sources(\n <instance-id>, # Event notifications service instance GUID\n name=<source-name>,\n description=<source-description>,\n enabled=False\n ).get_result()\n\nprint(json.dumps(source_response, indent=2))\n```\n\n### List Sources\n\n```py\nsource_list = event_notifications_service.list_sources(\n <instance-id>, # Event notifications service instance GUID\n ).get_result()\n\nprint(json.dumps(source_list, indent=2))\n```\n\n### Get Source\n\n```py\n\nsource = event_notifications_service.get_source(\n <instance-id>, # Event notifications service instance GUID\n id=<source-id>, # Event notifications service instance Source ID\n ).get_result()\n\nprint(json.dumps(source, indent=2))\n\n```\n\n### Update Source\n\n```py\nsource = event_notifications_service.update_source(\n <instance-id>, # Event notifications service instance GUID\n id=<source-id>, # Event notifications service instance Source ID\n name=<source-name>,\n description=<source-description>,\n enabled=True\n ).get_result()\n\nprint(json.dumps(source, indent=2))\n```\n\n### Delete Source\n\n```py\n\nresponse = event_notifications_service.delete_source(\n <instance-id>, # Event notifications service instance GUID\n id=<source-id>, # Event notifications service instance Source ID\n )\n\n```\n\n## Topics\n\n### Create Topic\n\nFilters applied in case of periodic-timer as source. EventTypeFilter, NotificationFilter are mutually exclusive with EventScheduleFilter\n\n```py\n event_schedule_filter_attributes_model = {\n 'starts_at': '2025-01-01T05:15:00.000Z',\n 'ends_at': '2025-01-01T05:15:00.000Z',\n 'expression': '* * * * *'\n}\n\nrules_model = {\n \"enabled\": True,\n \"event_schedule_filter\": event_schedule_filter_attributes_model,\n}\n```\n\n```py\n\nrules_model = {\n 'enabled': False,\n 'event_type_filter': '$.notification_event_info.event_type == \\'cert_manager\\'', #Add your event type filter here.\n 'notification_filter': '$.notification.findings[0].severity == \\'MODERATE\\'', #Add your notification filter here.\n}\n\n# Construct a dict representation of a TopicUpdateSourcesItem model\ntopic_update_sources_item_model = {\n 'id': <source_id>,\n 'rules': [rules_model],\n}\n\ntopic_response = event_notifications_service.create_topic(\n <instance_id>,\n name=<topic-name>,\n description=<topic-description>,\n sources=[topic_update_sources_item_model]\n)\n\nprint(json.dumps(topic_response, indent=2))\n```\n\n### List Topics\n\n```py\ntopic_list = event_notifications_service.list_topics(\n <instance-id>,\n).get_result()\n\nprint(json.dumps(topic_list, indent=2))\n```\n\n### Get Topic\n\n```py\ntopic = event_notifications_service.get_topic(\n <instance-id>, # Event notifications service instance GUID\n id=<topic-id>, # Event notifications service instance Topic ID\n ).get_result()\n\nprint(json.dumps(topic, indent=2))\n```\n\n### Update Topic\n\n```py\n\nrules_model = {\n 'enabled': True,\n 'event_type_filter': '$.notification_event_info.event_type == \\'core_cert_manager\\'',\n 'notification_filter': '$.notification.findings[0].severity == \\'SEVERE\\'',\n}\n\n# Construct a dict representation of a TopicUpdateSourcesItem model\ntopic_update_sources_item_model = {\n 'id': <source-id>, # Event notifications service instance Source ID\n 'rules': [rules_model],\n}\n\ndescription = \"Updated Topic for GCM notifications\"\nname = 'Updated Admin Topic Compliance'\ntopic = event_notifications_service.replace_topic(\n <instance-id>, # Event notifications service instance GUID\n id=<topic-id>, # Event notifications service instance Topic ID\n name=<topic-update-name> # Event notifications service instance Topic Name\n description=<topic-update-description> # Event notifications service instance Topic description\n sources=[topic_update_sources_item_model]\n)\n\nprint(json.dumps(topic, indent=2))\n\nrulesModel := &eventnotificationsv1.Rules{\n\tEnabled: core.BoolPtr(true),\n\tEventTypeFilter: core.StringPtr(\"$.notification_event_info.event_type == 'core_cert_manager'\"), # Add your event type filter here.\n\tNotificationFilter: core.StringPtr(\"$.notification.findings[0].severity == 'SEVERE'\"), # Add your notification filter here.\n}\n```\n\n### Delete Topic\n\n```py\nresponse = event_notifications_service.delete_topic(\n <instance-id>,\n id=<topic-id>,\n )\n\n```\n\n## Destinations\n\n### Create Destination\n\n```py\n\ndestination_config_params_model = {\n 'url': '<destination-config-url>',\n 'verb': '<destination-config-verb>',\n 'custom_headers': {'<header-key>': '<header-value>', },\n 'sensitive_headers': ['<header-key>'],\n }\n\n# Construct a dict representation of a DestinationConfig model\ndestination_config_model = {\n 'params': destination_config_params_model,\n}\n\ndestination = event_notifications_service.create_destination(\n <instance-id>,\n <destination-name>,\n type=<destination-type>,\n description=description,\n config=destination_config_model\n).get_result()\n\nprint(json.dumps(destination, indent=2))\n```\n\nAmong the supported destinations, if you need to create Push Notification destinations, you have the additional option of choosing a destination of production type or pre-production type.\nSet `pre_prod` boolean parameter to _true_ to configure destination as pre-production destination else set the value as _false_.\nSupported destinations are Android, iOS, Chrome, Firefox, and Safari.\n\n### List Destinations\n\n```py\ndestination_list = event_notifications_service.list_destinations(\n <instance-id>,\n).get_result()\n\nprint(json.dumps(destination_list, indent=2))\n```\n\n### Get Destination\n\n```py\ndestination = event_notifications_service.get_destination(\n <instance-id>, # Event notifications service instance GUID\n id=<destination-id>, # Event notifications service instance Destination ID\n ).get_result()\n\nprint(json.dumps(destination, indent=2))\n```\n\n### Update Destination\n\n```py\n# Construct a dict representation of a DestinationConfigParamsWebhookDestinationConfig model\ndestination_config_params_model = {\n 'url': '<destination-config-update-url>',\n 'verb': '<destination-config-update-verb>',\n 'sensitive_headers': ['<header-key>'],\n}\n\n# Construct a dict representation of a DestinationConfig model\ndestination_config_model = {\n 'params': destination_config_params_model,\n}\n\ndestination = event_notifications_service.update_destination(\n <instance-id>, # Event notifications service instance GUID\n id=<destination-id>, # Event notifications service instance Destination ID\n name=<destination-update-name>,\n description=<destination-update-description>,\n config=destination_config_model\n).get_result()\n\nprint(json.dumps(destination, indent=2))\n\n```\n\n### Delete Destination\n\n```py\nresponse = event_notifications_service.delete_destination(\n <instance-id>,\t\t# Event notifications service instance GUID\n id=<destination-id>,\t# Event notifications service instance Destination ID\n )\n```\n\n### Test Destination\n\nThis functionality allows you to test a destination. The feature simplifies the process of verifying whether a destination is functioning correctly.\nCurrently, this functionality supports following destinations:\n\n1. Slack\n2. PagerDuty\n3. ServiceNow\n4. Microsoft® Teams\n5. IBM Cloud Code Engine\n6. IBM Cloud Object Storage\n7. Webhook\n\n```py\ntest_destination_response = event_notifications_service.test_destination(\n <instance-id>,\n id=<destination-id>\n)\n```\n\nOnce the test is completed, you will be presented with the results. These results will typically include:\n\n- **Status**: Whether the test is successful or failed\n- **Response Code**: If test fails, then the response code sent from the end destination client is returned\n- **Response Message**: If test fails, then the response message sent from the end destination client is returned\n\nIn case of `webhook` destination test response also returns notification_id, the status of notification_id will represent the webhook test result. Follow below additional steps to get status result of webhook destination test\n\n```python \nwebhook_notification_status = event_notifications_service.get_notifications_status(\n instance_id, \n id=<notification-id>\n)\n\nwebhook_status = webhook_notification_status.get_result()\n```\nThe response of `get_notifications_status` will have success, failed or inprogress status. The Notification ID will be valid only for 1 minute to fetch the status of test. The status response as **success** will conclude successful test of webhook destination\n\n### Custom Domain Name Verification\n\nAfter creation of the custom email destination with your domain name, make sure its validated for the right ownership.\nThis can be done with SPF and DKIM verification.\n\n- Sender Policy Framework (SPF), which is used to authenticate the sender of an email. SPF specifies the mail servers that are allowed to send email for your domain.\n- DomainKeys Identified Mail (DKIM), which allows an organization to take responsibility for transmitting a message by signing it. DKIM allows\n the receiver to check the email that claimed to have come from a specific domain, is authorized by the owner of that domain.\n\n```py\nverification_response = event_notifications_service.update_verify_destination(\n <instance-id>,\t\t # Event notifications service instance GUID\n id=<destination-id>, # Event notifications service instance Destination ID\n type=<verification-type>, # verification type spf/dkim\n ).get_result()\n```\n\n## Templates\n\nTemplate is a pre-defined layout, that may include content like images, text and dynamic content based on event. Rather than creating a new content from scratch each time, you can use a template as a base and configure them in subscription.\nsupports the following templates:\n\n- Custom Email notification\n- Custom Email invitation\n\n### Create Template\n\n#### Custom Email Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded html content',\n 'subject': 'Hi this is invitation for invitation message',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor custom email supported template type values: smtp_custom.invitation, smtp_custom.notification\n\n#### Slack Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded json body',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor slack template supported template type value: slack.notification\n\n#### Webhook Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded json body',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor webhook template supported template type value: webhook.notification\n\n#### PagerDuty Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded json body',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor pagerduty template supported template type value: pagerduty.notification\n\n#### EventStreams Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded json body',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor Event Streams template supported template type value: event_streams.notification\n\n#### CodeEngine Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded json body',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor Code Engine template supported template type values: ibmceapp.notification and ibmcejob.notification\n\n#### App Configuration Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encoded json body',\n}\n\ncreate_template_response = event_notifications_service.create_template(\n instance_id=<instance-id>,\n name=<template-name>,\n type=<template-type>,\n params=template_config_model,\n description=<template-description>\n).get_result()\n```\n\nFor App Configuration template supported template type values: app_configuration.notification\n\n### List Templates\n\n```py\nlist_templates_response = event_notifications_service.list_templates(\n instance_id=<instance-id>,\n limit=<limit>,\n offset=<offset>,\n search=<search>\n)\n\ntemplates_list = list_templates_response.get_result()\n```\n\n### Get Template\n\n```py\nget_template_response = event_notifications_service.get_template(\n instance_id=<instance-id>,\n id=<template_id>\n).get_result()\n```\n\n### List Predefined Templates\n\n```py\nlist_predefined_templates_response = self.event_notifications_service.list_pre_defined_templates(\n instance_id=<instance-id>,\n source=<source-type>,\n type=<destination-type>,\n)\nlist_predefined_templates = list_predefined_templates_response.get_result()\n```\n\n### Get Predefined Template\n\n```py\nget_predefined_template_response = self.event_notifications_service.get_pre_defined_template(\n instance_id=<instance-id>,\n id=<template_id>,\n)\n\nget_predefined_template = get_predefined_template_response.get_result()\n```\n\n### Update Template\n\n#### Update Email Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encode html content',\n 'subject': 'Hi this is invitation for invitation message',\n}\n\nreplace_template_response = event_notifications_service.replace_template(\n instance_id=<instance-id>,\n id=<template_id>\n name=<template_name>,\n type=<template-type>,\n description=<template-description>,\n params=template_config_model\n).get_result()\n```\n\n#### Update slack/webhook Template/PagerDuty Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encode json content',\n}\n\nreplace_template_response = event_notifications_service.replace_template(\n instance_id=<instance-id>,\n id=<template_id>\n name=<template_name>,\n type=<template-type>,\n description=<template-description>,\n params=template_config_model\n).get_result()\n```\nFor webhook template supported template type value: webhook.notification\nFor pagerduty template supported template type value: pagerduty.notification\n\n#### Update EventStreams Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encode json content',\n}\n\nreplace_template_response = event_notifications_service.replace_template(\n instance_id=<instance-id>,\n id=<template_id>\n name=<template_name>,\n type=<template-type>,\n description=<template-description>,\n params=template_config_model\n).get_result()\n```\nFor Event Streams template supported template type value: event_streams.notification\n\n#### Update CodeEngine Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encode json content',\n}\n\nreplace_template_response = event_notifications_service.replace_template(\n instance_id=<instance-id>,\n id=<template_id>\n name=<template_name>,\n type=<template-type>,\n description=<template-description>,\n params=template_config_model\n).get_result()\n```\nFor Code Engine template supported template type values: ibmceapp.notification and ibmcejob.notification\n\n#### Update App Configuration Template\n\n```py\ntemplate_config_model = {\n 'body': 'base 64 encode json content',\n}\n\nreplace_template_response = event_notifications_service.replace_template(\n instance_id=<instance-id>,\n id=<template_id>\n name=<template_name>,\n type=<template-type>,\n description=<template-description>,\n params=template_config_model\n).get_result()\n```\nFor App Configuration template supported template type values: app_configuration.notification\n\n### Delete Template\n\n```py\ndelete_template_response = event_notifications_service.delete_template(\n instance_id=<instance-id>,\n id=<template_id>\n).get_result()\n```\n\n## Push Destination APIs\n\n### Create Destination tag subscription\n\n```py\ntag_subscription = _event_notifications_service.create_tags_subscription(\n <instance-id>, # Event notifications service instance GUID\n <destination-id>, # Event notifications service Destintaion ID\n <device_id>, # Event notifications service Device ID\n <tag_name> # Event notifications service Tag Name\n).get_result()\n\nprint(json.dumps(tag_subscription, indent=2))\n```\n\n### List Destination tag subscription\n\n```py\nsubscription = _event_notifications_service.list_tags_subscription(\n <instance-id>, # Event notifications service instance GUID\n <destination-id> # Event notifications service Destintaion ID\n).get_result()\n\nprint(json.dumps(subscription, indent=2))\n```\n\n### Delete Destination device tag subscription\n\n```py\nresponse = _event_notifications_service.delete_tags_subscription(\n <instance-id>, # Event notifications service instance GUID\n <destination-id>, # Event notifications service Destintaion ID\n <device_id>, # Event notifications service Device ID\n <tag_name> # Event notifications service Tag Name\n).get_result()\n\nprint(json.dumps(response, indent=2))\n```\n\n## Subscriptions\n\n### Create Subscription\n\n```py\n#`While Creating Subscription use any of one option from webhook, or email`\n\nsubscription_create_attributes_model = {\n 'signing_enabled': False,\n 'template_id_notification': '<webhook-template-id>',\n}\n\n\nsubscription = event_notifications_service.create_subscription(\n <instance-id>,\t# Event notifications service instance GUID\n name,\n <destination-id>, # Event notifications service instance Destination ID\n <topic-id> # Event notifications service instance Topic ID\n attributes=subscription_create_attributes_model,\n description=<subscription-description>\n).get_result()\n\nprint(json.dumps(subscription, indent=2))\n```\n\n### \u26a0\ufe0f Special Consideration for App Configuration Destination\n\nWhen creating or updating a subscription for an **App Configuration** destination, the `attributes` object has a specific rule:\n\n- You must include **either** `feature_flag_enabled` **or** `template_id_notification`\n- You **cannot** include both properties together\n\nThis ensures that a subscription is created for the correct use case \u2014 either **feature flag evaluation** or **notification templating**, but not both at once.\n\n#### \u2705 Valid Example (Feature Flag Evaluation)\n\n```py\nsubscription_create_attributes_model_json = {\n 'feature_flag_enabled': True,\n}\n\nsubscription_create_attributes_model = SubscriptionCreateAttributesAppConfigurationAttributes.from_dict(\n subscription_create_attributes_model_json\n)\n```\n\n#### \u2705 Valid Example (template association)\n\n```py\nsubscription_create_attributes_model_json = {\n 'template_id_notification': <template-id>,\n}\n\nsubscription_create_attributes_model = SubscriptionCreateAttributesAppConfigurationAttributes.from_dict(\n subscription_create_attributes_model_json\n)\n```\n\n#### \u274c Invalid Example (Not Allowed)\n\n```py\nsubscription_create_attributes_model_json = {\n 'template_id_notification': <template-id>,\n 'feature_flag_enabled': True,\n}\n\nsubscription_create_attributes_model = SubscriptionCreateAttributesAppConfigurationAttributes.from_dict(\n subscription_create_attributes_model_json\n)\n```\n\n### List Subscriptions\n\n```py\nsubscription_list = event_notifications_service.list_subscriptions(\n <instance-id>,\t# Event notifications service instance GUID\n ).get_result()\n\nprint(json.dumps(subscription_list, indent=2))\n\n```\n\n### Get Subscription\n\n```py\n subscription = event_notifications_service.get_subscription(\n <instance-id>,\t# Event notifications service instance GUID\n id=<subscription-id>,\t# Event notifications service instance Subscription ID\n ).get_result()\n\nprint(json.dumps(subscription, indent=2))\n```\n\n### Update Subscription\n\n```py\n\n subscription_update_attributes_model = {\n 'signing_enabled': True,\n 'template_id_notification': '<webhook-template-id>',\n }\n\n subscription = event_notifications_service.update_subscription(\n <instance-id>,\t# Event notifications service instance GUID\n id=<subscription-id>,\t# Event notifications service instance Subscription ID\n name=<subscription-update-name>,\n description=<subscription-update-description>,\n attributes=subscription_update_attributes_model\n ).get_result()\n\n print(json.dumps(subscription, indent=2))\n```\n\n### Delete Subscription\n\n```py\nresponse = event_notifications_service.delete_subscription(\n <instance-id>,\t# Event notifications service instance GUID\n id=<subscription-id>,\t# Event notifications service instance Subscriptions ID\n )\n```\n\n# Integration\n\n### Create Integration\n\n```py\n\nintegration_metadata = {\n \"endpoint\": cos_end_point,\n \"crn\": cos_instance_crn,\n \"bucket_name\": cos_bucket_name,\n}\n\ncreate_integration_response = self.event_notifications_service.create_integration(\n instance_id,\n type=\"collect_failed_events\",\n metadata=integration_metadata,\n)\n\nintegration_response = create_integration_response.get_result()\n```\n\n### List Integrations\n\n```py\nlist_integrations_response = event_notifications_service.list_integrations(\n <instance-id>,\n <limit>,\n <offset>,\n <search>,\n)\n\nintegration_response = list_integrations_response.get_result()\n\n```\n\n### Get Integration\n\n```py\nget_integration_response = event_notifications_service.get_integration(\n <instance_id>,\n id=<integration_id>\n)\n\nintegration_response = get_integration_response.get_result()\n```\n\n### Update Integration\n\nFor kms/hs-crypto\n\n```py\n\nintegration_metadata = {\n 'endpoint': '<end-point>',\n 'crn': '<crn>',\n 'root_key_id': '<root-key-id>'\n}\n\nupdate_integration_response = event_notifications_service.replace_integration(\n <instance_id>,\n type=\"kms/hs-crypto\",\n id=<integration_id>,\n metadata=integration_metadata\n)\n\nintegration_response = update_integration_response.get_result()\n```\n\nFor Cloud Object Storage\n\n```py\n\nintegration_metadata = {\n 'endpoint': '<end-point>',\n 'crn': '<crn>',\n 'bucket-name': '<cos-bucket-name>'\n}\n\nupdate_integration_response = event_notifications_service.replace_integration(\n <instance_id>,\n type=\"collect_failed_events\",\n id=<integration_id>,\n metadata=integration_metadata\n)\n\nintegration_response = update_integration_response.get_result()\n```\n\n## SMTPConfigurations\n\n### Create SMTP Configuration\n\n```py\n\ncreate_smtp_config_response = self.event_notifications_service.create_smtp_configuration(\n instance_id=<instance_id>,\n name=<smtp-config-name>,\n domain=<smtp-domain-name>,\n description=<smtp-description>\n)\n\nsmtp_response = create_smtp_config_response.get_result()\n\n```\n\n### Create SMTP User\n\n```py\n\ncreate_smtp_user_response = self.event_notifications_service.create_smtp_user(\n instance_id=<instance-id>,\n id=<smtp-config-id>,\n description=<smtp-description>\n)\n\ncreate_user_response = create_smtp_user_response.get_result()\n\n```\n\n### Clone SMTP User\n\n```py\n\nclone_smtp_user_response = self.event_notifications_service.create_smtp_user(\n instance_id=<instance-id>,\n id=<smtp-config-id>,\n username_to_clone=<smtp_user_to_clone>,\n)\n\nclone_user_response = create_smtp_user_response.get_result()\n\n```\n\n### Get SMTP Configuration\n\n```py\n\nget_smtp_config_response = self.event_notifications_service.get_smtp_configuration(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n)\n\nget_smtp_config_response = get_smtp_config_response.get_result()\n\n```\n\n### Get SMTP User\n\n```py\n\nget_smtp_user_response = self.event_notifications_service.get_smtp_user(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n user_id=<smtp_user_id>\n)\n\nget_smtp_user_response = get_smtp_user_response.get_result()\n\n```\n\n### Get SMTP Allowed Ips\n\n```py\n\nget_smtp_allowed_ip_response = self.event_notifications_service.get_smtp_allowed_ips(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n)\n\nget_smtp_allowed_ip_response = get_smtp_allowed_ip_response.get_result()\n\n```\n\n### List SMTP Configurations\n\n```py\n\nlist_smtp_config_response = self.event_notifications_service.list_smtp_configurations(\n instance_id=<instance-id>,\n limit=<limit>,\n offset=<offset>,\n search=<search>,\n)\n\nlist_smtp_config_response = list_smtp_config_response.get_result()\n\n```\n\n### List SMTP Users\n\n```py\n\nlist_smtp_user_response = self.event_notifications_service.list_smtp_users(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n limit=<limit>,\n offset=<offset>,\n search=<search>,\n)\n\nlist_smtp_user_response = list_smtp_user_response.get_result()\n\n```\n\n### Update SMTP Configuration\n\n```py\n\nupdate_smtp_config_response = self.event_notifications_service.update_smtp_configuration(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n name=<smtp-name>,\n description=<smtp-description>,\n)\n\nupdate_smtp_config_response = update_smtp_config_response.get_result()\n\n```\n\n### Update SMTP User\n\n```py\n\nupdate_smtp_user_response = self.event_notifications_service.update_smtp_user(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n user_id=<smtp_user_id>,\n description=<smtp-description>,\n)\n\nupdate_smtp_user_response = update_smtp_user_response.get_result()\n\n```\n\n### Delete SMTP User\n\n```py\n\ndelete_smtp_user_response = self.event_notifications_service.delete_smtp_user(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n user_id=<user-id>\n)\n\nprint(json.dumps(delete_smtp_user_response, indent=2))\n\n```\n\n### Delete SMTP Configuration\n\n```py\n\ndelete_smtp_config_response = self.event_notifications_service.delete_smtp_configuration(\n instance_id=<instance-id>,\n id=<smtp_config_id>,\n)\n\nprint(json.dumps(delete_smtp_config_response, indent=2))\n\n```\n\n### Verify SMTP\n\n```py\n\nupdate_verify_smtp_response = self.event_notifications_service.update_verify_smtp(\n instance_id=<instance-id>,\n type=<verification-type>,\n id=<smtp_config_id>\n)\n\nverify_response = update_verify_smtp_response.get_result()\n\n```\n\nsupported verification types are dkim,spf and en_authorization.\n\n## Metrics\n\n### Get Metrics\n\n```py\n\nget_metrics_response = self.event_notifications_service.get_metrics(\n instance_id=<instance-id>,\n destination_type=\"smtp_custom\",\n gte=<gte-timestamp>,\n lte=<lte-timestamp>,\n destination_id=<destination-id>,\n email_to=<email-to>,\n notification_id=<notification-id>,\n subject=<subject>\n)\n\nmetric_response = get_metrics_response.get_result()\n\n```\n\n### Send Notifications\n\n```py\nnotification_devices_model = {\n 'fcm_devices': ['<fcm-device-ids>'],\n 'apns_devices': ['<apns-device-ids>'],\n 'user_ids': ['<user-ids>'],\n 'tags': ['<tag-names>'],\n 'platforms': ['<device-platforms>'],\n}\n\nnotification_apns_body_model = {\n \"aps\": {\n \"alert\": \"<notification-message>\",\n \"badge\": 5,\n },\n}\nnotification_fcm_body_model = {\n 'message': {\n 'android': {\n 'notification': {\n 'title': '<notification-title>',\n 'body': '<notification-message>',\n },\n 'data': {\n 'name': 'Robert',\n 'description': 'notification for the Poker',\n },\n },\n },\n}\n\nmessage_apns_headers = {\n \"apns-collapse-id\": \"<apns-apns-collapse-id-value>\",\n}\n\nnotificationSafariBodymodel = {\n 'saf': {\n 'alert': 'Game Request',\n 'badge': 5,\n },\n}\n\nnotification_id = \"<notification-id>\"\nnotification_severity = \"<notification-severity>\"\ntype_value = \"<notification-type>\"\nnotifications_source = \"<notification-source>\"\nhtmlbody = '\"Hi ,<br/>Certificate expiring in 90 days.<br/><br/>Please login to ' \\\n '<a href=\"https: //cloud.ibm.com/security-compliance/dashboard\">' \\\n 'Security and Complaince dashboard</a> to find more information<br/>\"'\nmailto = '[\\\"abc@ibm.com\\\", \\\"def@us.ibm.com\\\"]'\nsmsto = '[\\\"+911234567890\\\", \\\"+911224567890\\\"]'\nslackto = '[\\\"C07FALXBH4G\\\"]'\nmms = '{\"content\": \"akajdklahl\", \"content_type\": \"image/png\"}'\ntemplates = '[\"149b0e11-8a7c-4fda-a847-5d79e01b71dc\"]'\nmarkdown_content = \"**Event Summary** \\n\\n**Toolchain ID:** `4414af34-a5c7-47d3-8f05-add4af6d78a6` \\n**Content Type:** `application/json`\\n\\n---\\n\\n *Pipeline Run Details*\\n\\n- **Namespace:** `PR`\\n- **Trigger Name:** `manual`\\n- **Triggered By:** `nitish.kulkarni3@ibm.com`\\n- **Build Number:** `343`\\n- **Pipeline Link:** [View Pipeline Run](https://cloud.ibm.com/devops/pipelines/tekton/e9cd5aa3-a3f2-4776-8acc-26a35922386e/runs/f29ac6f5-bd2f-4a26-abb8-4249be8dbab7?env_id=ibm:yp:us-south)\"\n\nnotification_create_model = {\n 'ibmenseverity': notification_severity,\n 'ibmenfcmbody': json.dumps(notification_fcm_body_model),\n 'ibmenpushto': json.dumps(notification_devices_model),\n 'ibmenapnsbody': json.dumps(notification_apns_body_model),\n 'ibmensourceid': source_id,\n 'ibmendefaultshort': 'short info',\n 'ibmendefaultlong': 'long info',\n 'ibmensafaribody': json.dumps(notificationSafariBodymodel),\n 'ibmenhtmlbody': htmlbody,\n \"ibmenmarkdown\": markdown_content,\n 'ibmensubject': 'Findings on IBM Cloud Security Advisor',\n 'ibmenmailto': mailto,\n 'ibmensmsto': smsto,\n 'ibmenslackto': slackto,\n 'ibmenmms': mms,\n \"ibmentemplates\": templates,\n 'id': notification_id,\n 'source': notifications_source,\n 'type': type_value,\n 'specversion': '1.0',\n 'time': '2019-01-01T12:00:00.000Z',\n}\n\nsend_notifications_response = event_notifications_service.send_notifications(\n instance_id,\n body=notification_create_model\n ).get_result()\n\n```\n<details open>\n<summary>Send Notifications Variables</summary>\n<br>\n\n- **ibmenpushto** - Set up the push notifications targets.\n - **user_ids** (_Array of String_) - Send notification to the specified userIds.\n - **fcm_devices** (_Array of String_) - Send notification to the list of specified Android devices.\n - **apns_devices** (_Array of String_) - Send notification to the list of specified iOS devices.\n - **chrome_devices** (_Array of String_) - Send notification to the list of specified Chrome devices.\n - **firefox_devices** (_Array of string_) - Send notification to the list of specified Firefox devices.\n - **tags** (_Array of string_) - Send notification to the devices that have subscribed to any of these tags.\n - **platforms** (_Array of string_) - Send notification to the devices of the specified platforms.\n - Pass 'G' for google (Android) devices.\n - Pass 'A' for iOS devices.\n - Pass 'WEB_FIREFOX' for Firefox browser.\n - Pass 'WEB_CHROME' for Chrome browser.\n- **Event Notifications SendNotificationsOptions** - Event Notifications Send Notifications method.\n - **instance_id\\*** (_string_) - Unique identifier for IBM Cloud Event Notifications instance.\n - **ibmenseverity** (_string_) - Severity for the notifications. Some sources can have the concept of an Event severity. Hence a handy way is provided to specify a severity of the event. example: LOW, HIGH, MEDIUM\n - **id\\*** (_string_) - A unique identifier that identifies each event. source+id must be unique. The backend should be able to uniquely track this id in logs and other records. Send unique ID for each send notification. Same ID can be sent in case of failure of send notification. source+id will be logged in IBM Cloud Logging service. Using this combination we will be able to trace the event movement from one system to another and will aid in debugging and tracing.\n - **source\\*** (_string_) - Source of the notifications. This is the identifier of the event producer. A way to uniquely identify the source of the event. For IBM Cloud services this is the crn of the service instance producing the events. For API sources this can be something the event producer backend can uniquely identify itself with.\n - **ibmensourceid\\*** (_string_) - This is the ID of the source created in EN. This is available in the EN UI in the \"Sources\" section.\n - **type** (_string_) - This describes the type of event. It is of the form <event-type-name>:<sub-type> This type is defined by the producer. The event type name has to be prefixed with the reverse DNS names so the event type is uniquely identified. The same event type can be produced by 2 different sources. It is highly recommended to use hyphen - as a separator instead of \\_.\n - **data** (_string_) - The payload for webhook notification. If data is added as part of payload then its mandatory to add **datacontenttype**.\n - **datacontenttype** - The notification content type. example: application/json\n - **time** (_string_) - Time of the notifications. UTC time stamp when the event occurred. Must be in the RFC 3339 format.\n - **ibmenpushto** (_string_) - Targets for the FCM notifications. This contains details about the destination where you want to send push notification. This attribute is mandatory for successful delivery from an Android FCM or APNS destination.\n - **ibmenfcmbody** (_string_) - Set payload string specific to Android platform [Refer this FCM official [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support)].\n - **ibmenhuaweibody** (_string_) - Set payload string specific to Android platform [Refer this FCM official [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support)].\n - **ibmenapnsbody** (_string_) - Set payload string specific to iOS platform [Refer this APNs official doc [link](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html)].\n - **ibmensafaribody** (_string_) - Set payload string specific to safari platform [Refer this Safari official doc [link](https://developer.huawei.com/consumer/en/hms/huawei-pushkit)].\n - **ibmenapnsheaders** (_string_) - Set headers required for the APNs message [Refer this APNs official [link](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns)(Table 1 Header fields for a POST request)]\n - **ibmenchromebody** (_string_) - Message body for the Chrome notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.\n - **ibmenfirefoxbody** (_string_) - Message body for the Firefox notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.\n - **ibmenchromeheaders** (_string_) - Headers for the Chrome notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.\n - **ibmenfirefoxheaders** (_string_) - Headers for the Firefox notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.\n - **ibmendefaultshort\\*** (_string_) - Default short text for the message.\n - **ibmendefaultlong\\*** (_string_) - Default long text for the message.\n - **specversion\\*** (_string_) - Spec version of the Event Notifications. Default value is `1.0`.\n - **ibmenhtmlbody** (_string_) - The html body of notification for email.\n - **ibmenmailto** (_Array of string_) - Array of email ids to which the notification to be sent.\n - **ibmensmsto** (_Array of string_) - Array of SMS numbers to which the notification to be sent.\n - **ibmensmstext** (_string_) - SMS text to be sent.\n - **ibmenslackto** (_Array of string_) - Array of Slack channel/member ids to which the notification to be sent.\n - **ibmentemplates** (_Array of string_) - Array of template IDs that needs to be applied while sending notificatin for custom domain email and slack destination.\n - **ibmenmarkdown** (_string_) - The markdown content of pretty formatting.\n\nNote: variable with \\* represents the mandatory attribute.\n\n</details>\n\n## Set Environment\n\nFind `event_notifications_v1.env.hide` in the repo and rename it to `event_notifications_v1.env`. After that add the values for,\n\n- `EVENT_NOTIFICATIONS_URL` - Add the Event Notifications service instance Url.\n- `EVENT_NOTIFICATIONS_APIKEY` - Add the Event Notifications service instance apikey.\n- `EVENT_NOTIFICATIONS_GUID` - Add the Event Notifications service instance GUID.\n\n**Optional**\n\n- `EVENT_NOTIFICATIONS_AUTH_URL` - Add the IAM url if you are using IBM test cloud.\n- `EVENT_NOTIFICATIONS_FCM_KEY` - Add firebase server key for Android FCM destination.\n- `EVENT_NOTIFICATIONS_FCM_ID` - Add firebase sender Id for Android FCM destination.\n- `EVENT_NOTIFICATIONS_FCM_PROJECT_ID` - fcm project id\n- `EVENT_NOTIFICATIONS_FCM_CLIENT_EMAIL` - fcm client email\n- `EVENT_NOTIFICATIONS_FCM_PRIVATE_KEY` - fcm private key\n- `EVENT_NOTIFICATIONS_SAFARI_CERTIFICATE` - safari certificate path\n\n- `EVENT_NOTIFICATIONS_SNOW_CLIENT_ID` - service now client id\n- `EVENT_NOTIFICATIONS_SNOW_CLIENT_SECRET` - service now client secret\n- `EVENT_NOTIFICATIONS_SNOW_USER_NAME` - service now user name\n- `EVENT_NOTIFICATIONS_SNOW_PASSWORD` - service now password\n- `EVENT_NOTIFICATIONS_SNOW_INSTANCE_NAME` - service now instance name\n\n- `EVENT_NOTIFICATIONS_COS_BUCKET_NAME` - cloud object storage bucket name\n- `EVENT_NOTIFICATIONS_COS_INSTANCE` - cloud object storage instance id\n- `EVENT_NOTIFICATIONS_COS_INSTANCE_CRN` - cloud object storage instance crn\n- `EVENT_NOTIFICATIONS_COS_ENDPOINT` - cloud object storage end point\n\n- `EVENT_NOTIFICATIONS_CODE_ENGINE_URL` - code engine app url\n- `EVENT_NOTIFICATIONS_CODE_ENGINE_PROJECT_CRN` - code engine project crn\n- `EVENT_NOTIFICATIONS_HUAWEI_CLIENT_SECRET` - huawei client secret\n- `EVENT_NOTIFICATIONS_HUAWEI_CLIENT_ID` - huawei client id\n\n- `EVENT_NOTIFICATIONS_SLACK_URL` - slack webhook url\n- `EVENT_NOTIFICATIONS_MS_TEAMS_URL` - msteams webhook url\n- `EVENT_NOTIFICATIONS_PD_ROUTING_KEY` - pagerduty routing key\n- `EVENT_NOTIFICATIONS_PD_API_KEY` - pagerduty api key\n- `EVENT_NOTIFICATIONS_TEMPLATE_BODY` - base 64 encoded html content\n- `EVENT_NOTIFICATIONS_SLACK_TEMPLATE_BODY` - base 64 encoded json body\n- `EVENT_NOTIFICATIONS_WEBHOOK_TEMPLATE_BODY` - base 64 encoded json body\n- `EVENT_NOTIFICATIONS_SCHEDULER_SOURCE_ID` - periodic timer source id\n- `EVENT_NOTIFICATIONS_PAGERDUTY_TEMPLATE_BODY` - base 64 encoded json body for pagerduty destination\n- `EVENT_NOTIFICATIONS_EVENT_STREAMS_TEMPLATE_BODY` - base 64 encoded json body for event streams destination\n- `EVENT_NOTIFICATIONS_EVENT_STREAMS_CRN` - Event Streams instance CRN\n- `EVENT_NOTIFICATIONS_EVENT_STREAMS_TOPIC` - Event Streams instance Topic name\n- `EVENT_NOTIFICATIONS_EVENT_STREAMS_ENDPOINT` - Event streams end point\n- `EVENT_NOTIFICATIONS_CODE_ENGINE_APP_TEMPLATE_BODY` - base 64 encoded json body for Code Engine Application\n- `EVENT_NOTIFICATIONS_CODE_ENGINE_JOB_TEMPLATE_BODY` - base 64 encoded json body for Code Engine Job\n- `EVENT_NOTIFICATIONS_APP_CONFIG_CRN` - CRN of App Configuration instance\n- `EVENT_NOTIFICATIONS_APP_CONFIG_TEMPLATE_BODY` - base 64 encoded json body for App Configuration\n- `EVENT_NOTIFICATIONS_SMTP_USER_TO_CLONE` - SMTP username to be cloned\n\n## Questions\n\nIf you are having difficulties using this SDK or have a question about the IBM Cloud services,\nplease ask a question\n[Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-cloud).\n\n## Issues\n\nIf you encounter an issue with the project, you are welcome to submit a\n[bug report](https://github.com/IBM/event-notifications-python-admin-sdk/issues).\nBefore that, please search for similar issues. It's possible that someone has already reported the problem.\n\n## \u26a0\ufe0f Deprecation Notice (Attributes)\n\n### Pagerduty Destination Configuration\n\n> The following attribute from interface DestinationConfigOneOfPagerDutyDestinationConfig is **deprecated** and will be removed in a future release:\n\n- `api_key`\n\nThis attribute no longer recommended for use and may not be supported in upcoming versions of the SDK. Only `routing_key` is expected to be passed.\n\n## Open source @ IBM\n\nFind more open source projects on the [IBM Github Page](http://ibm.github.io/)\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nThis SDK is released under the Apache 2.0 license.\nThe license's full text can be found in [LICENSE](LICENSE).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Python server SDK for IBM Cloud Event Notifications service",
"version": "0.21.0",
"project_urls": {
"Homepage": "https://github.com/IBM/event-notifications-python-admin-sdk"
},
"split_keywords": [
"ibm_eventnotifications"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d5592b8c9374c1567e77c650cfded98b67b034a471673c1a8c87e21cd5e533d1",
"md5": "617740aea8084471a01ff24fa5f6ff11",
"sha256": "62f80d15a3d319f3a7c2da8b0af08957e737b416856e3d9f695e24f0a9f636dc"
},
"downloads": -1,
"filename": "ibm_eventnotifications-0.21.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "617740aea8084471a01ff24fa5f6ff11",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 63221,
"upload_time": "2025-10-30T10:54:37",
"upload_time_iso_8601": "2025-10-30T10:54:37.226080Z",
"url": "https://files.pythonhosted.org/packages/d5/59/2b8c9374c1567e77c650cfded98b67b034a471673c1a8c87e21cd5e533d1/ibm_eventnotifications-0.21.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "724dfd00a91f71ee1ff2e4127c063214f0baa4a3a96b6ea8186559d80345f0b8",
"md5": "7199d806a6061cc0a0d311a34c2ad7c5",
"sha256": "6aaa47728a7c9c2abe19a7d9f4ef87aa4c622d1736163ce93e8eb8eb1471a8b5"
},
"downloads": -1,
"filename": "ibm_eventnotifications-0.21.0.tar.gz",
"has_sig": false,
"md5_digest": "7199d806a6061cc0a0d311a34c2ad7c5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 82485,
"upload_time": "2025-10-30T10:54:38",
"upload_time_iso_8601": "2025-10-30T10:54:38.215952Z",
"url": "https://files.pythonhosted.org/packages/72/4d/fd00a91f71ee1ff2e4127c063214f0baa4a3a96b6ea8186559d80345f0b8/ibm_eventnotifications-0.21.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-30 10:54:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "IBM",
"github_project": "event-notifications-python-admin-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "ibm_cloud_sdk_core",
"specs": [
[
">=",
"3.20.6"
],
[
"<",
"4.0.0"
]
]
}
],
"tox": true,
"lcname": "ibm-eventnotifications"
}