Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2026-03-19T14:44:16Z",
"generated_at": "2026-04-07T04:40:35Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -65,6 +65,16 @@
}
],
"results": {
"README.md": [
{
"hashed_secret": "1f994725d7713ba16a295adc7d78dfa0e35a26f3",
"is_secret": false,
"is_verified": false,
"line_number": 1314,
"type": "Base64 High Entropy String",
"verified_result": null
}
],
"event_notifications_v1.env.hide": [
{
"hashed_secret": "98103a8f40de455136eef28078548666c9f789e3",
Expand Down Expand Up @@ -104,15 +114,15 @@
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
"is_secret": false,
"is_verified": false,
"line_number": 1377,
"line_number": 1396,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "3235b7f8d626cde63611d2e9ec43473f4e844c67",
"is_secret": false,
"is_verified": false,
"line_number": 2523,
"line_number": 2625,
"type": "Base64 High Entropy String",
"verified_result": null
}
Expand All @@ -122,23 +132,31 @@
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
"is_secret": false,
"is_verified": false,
"line_number": 628,
"line_number": 634,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "0cc20f91828bed53ddb6294968b7f9abd631a3ba",
"is_secret": false,
"is_verified": false,
"line_number": 1744,
"line_number": 1774,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "3235b7f8d626cde63611d2e9ec43473f4e844c67",
"is_secret": false,
"is_verified": false,
"line_number": 3711,
"line_number": 3849,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "1f994725d7713ba16a295adc7d78dfa0e35a26f3",
"is_secret": false,
"is_verified": false,
"line_number": 3854,
"type": "Base64 High Entropy String",
"verified_result": null
}
Expand All @@ -148,15 +166,15 @@
"hashed_secret": "7eeef8638d6f283c8d76d7811ec6e5f198e16021",
"is_secret": false,
"is_verified": false,
"line_number": 7928,
"line_number": 8069,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "b8473b86d4c2072ca9b08bd28e373e8253e865c4",
"is_secret": false,
"is_verified": false,
"line_number": 10935,
"line_number": 11162,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,20 @@ source_response = event_notifications_service.create_sources(
<instance-id>, # Event notifications service instance GUID
name=<source-name>,
description=<source-description>,
enabled=False
enabled=False,
store_notifications=True # Optional: Enable to view payload of incoming events for troubleshooting
).get_result()

print(json.dumps(source_response, indent=2))
```

**Parameters:**
- `instance_id` (required): Event Notifications service instance GUID
- `name` (required): Name of the source
- `description` (required): Description of the source
- `enabled` (optional): Whether the source is enabled or not (default: False)
- `store_notifications` (optional): Enable to view the payload of incoming events for troubleshooting (default: False)

### List Sources

```py
Expand Down Expand Up @@ -364,6 +372,7 @@ Among the supported destinations, if you need to create Push Notification destin
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.

**Note:** The `smtp_custom_sandbox` destination type is available for testing purposes in sandbox environments. It works similarly to `smtp_custom` but is intended for development and testing scenarios. Refer to https://cloud.ibm.com/apidocs/event-notifications#create-destination for examples.
### List Destinations

```py
Expand Down Expand Up @@ -1300,6 +1309,23 @@ 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)"

# Email attachments (optional)
email_attachment_1 = {
'content': 'VGhpcyBpcyBhIHRlc3QgYXR0YWNobWVudCBjb250ZW50', # Base64 encoded content
'filename': 'report.txt',
'content_type': 'text/plain',
'disposition': 'attachment'
}

email_attachment_2 = {
'content': 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
'filename': 'image.png',
'content_type': 'image/png',
'disposition': 'attachment'
}

email_attachments = [email_attachment_1, email_attachment_2]

notification_create_model = {
'ibmenseverity': notification_severity,
'ibmenfcmbody': json.dumps(notification_fcm_body_model),
Expand All @@ -1317,6 +1343,7 @@ notification_create_model = {
'ibmenslackto': slackto,
'ibmenmms': mms,
"ibmentemplates": templates,
'attachments': email_attachments, # Add email attachments
'id': notification_id,
'source': notifications_source,
'type': type_value,
Expand Down Expand Up @@ -1376,6 +1403,11 @@ send_notifications_response = event_notifications_service.send_notifications(
- **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.
- **attachments** (_Array of EmailAttachment objects_) - Array of email attachments to be sent with the notification. Each attachment object contains:
- **content** (_string_) - Base64 encoded file content.
- **filename** (_string_) - Name of the attachment file.
- **content_type** (_string_) - MIME type of the attachment (e.g., 'text/plain', 'application/pdf', 'image/png').
- **disposition** (_string_) - Content disposition, 'attachment'.

Note: variable with \* represents the mandatory attribute.

Expand Down
124 changes: 122 additions & 2 deletions examples/test_event_notifications_v1_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
destination_id19 = ""
destination_id20 = ""
destination_id22 = ""
destination_id_sandbox = ""
safariCertificatePath = ""
subscription_id = ""
subscription_id1 = ""
Expand All @@ -82,6 +83,7 @@
subscription_id9 = ""
subscription_id10 = ""
subscription_id22 = ""
subscription_id_sandbox = ""
fcmServerKey = ""
fcmSenderId = ""
integration_id = ""
Expand Down Expand Up @@ -239,6 +241,7 @@ def test_create_sources_example(self):
name="Event Notification Create Source Acme",
description="This source is used for Acme Bank",
enabled=False,
store_notifications=True,
).get_result()

print(json.dumps(source_response, indent=2))
Expand Down Expand Up @@ -429,7 +432,7 @@ def test_create_destination_example(self):
"""
create_destination request example
"""
global destination_id, destination_id3, destination_id4, destination_id5, destination_id6, destination_id8, destination_id9, destination_id10, destination_id11, destination_id12, destination_id13, destination_id14, destination_id15, destination_id16, destination_id17, destination_id18, destination_id19, destination_id20, destination_id22
global destination_id, destination_id3, destination_id4, destination_id5, destination_id6, destination_id8, destination_id9, destination_id10, destination_id11, destination_id12, destination_id13, destination_id14, destination_id15, destination_id16, destination_id17, destination_id18, destination_id19, destination_id20, destination_id_sandbox, destination_id22
try:
print("\ncreate_destination() result:")
# begin-create_destination
Expand Down Expand Up @@ -904,6 +907,21 @@ def test_create_destination_example(self):
destination = DestinationResponse.from_dict(destination_response)
destination_id22 = destination.id

name = "custom_email_sandbox_destination"
typeval = "smtp_custom_sandbox"
description = "Custom Email Sandbox Destination"

create_destination_response = self.event_notifications_service.create_destination(
instance_id,
name,
type=typeval,
description=description,
)

destination_response = create_destination_response.get_result()
destination: DestinationResponse = DestinationResponse.from_dict(destination_response)
destination_id_sandbox = destination.id

# end-create_destination

except ApiException as e:
Expand Down Expand Up @@ -1667,11 +1685,47 @@ def test_update_destination_example(self):

print(json.dumps(update_destination_response, indent=2))

name = "custom_email_sandbox_destination_update"
description = "Custom Email Sandbox Destination update"

update_destination_response = self.event_notifications_service.update_destination(
instance_id,
id=destination_id_sandbox,
name=name,
description=description,
).get_result()

print(json.dumps(update_destination_response, indent=2))

# end-update_destination

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_upgrade_sandbox_destination_example(self):
"""
upgrade_sandbox_destination request example
"""
try:
print("\nupgrade_sandbox_destination() result:")
# begin-upgrade_sandbox_destination

domain = "mailx.event-notifications.test.cloud.ibm.com"

upgrade_response = self.event_notifications_service.update_email_sandbox_destination(
instance_id,
id=destination_id_sandbox,
domain=domain,
).get_result()

print(json.dumps(upgrade_response, indent=2))

# end-upgrade_sandbox_destination

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_update_template_example(self):
"""
Expand Down Expand Up @@ -1853,7 +1907,7 @@ def test_create_subscription_example(self):
"""
create_subscription request example
"""
global subscription_id, subscription_id1, subscription_id2, subscription_id3, subscription_id4, subscription_id5, subscription_id6, subscription_id7, subscription_id8, subscription_id9, subscription_id10, subscription_id22
global subscription_id, subscription_id1, subscription_id2, subscription_id3, subscription_id4, subscription_id5, subscription_id6, subscription_id7, subscription_id8, subscription_id9, subscription_id10, subscription_id_sandbox, subscription_id22
try:
print("\ncreate_subscription() result:")
# begin-create_subscription
Expand Down Expand Up @@ -2114,6 +2168,27 @@ def test_create_subscription_example(self):
subscription_response = create_subscription_response.get_result()
subscription_id22 = subscription_response.get("id")

subscription_create_attributes_model = {
"invited": ["testuser@in.ibm.com"],
"add_notification_payload": True,
"reply_to_mail": "reply_to_mail@us.com",
"reply_to_name": "US News",
}

name = "subscription_custom_email_sandbox"
description = "Subscription for custom email sandbox"
create_subscription_response = self.event_notifications_service.create_subscription(
instance_id,
name,
destination_id=destination_id_sandbox,
topic_id=topic_id,
attributes=subscription_create_attributes_model,
description=description,
)

subscription_response = create_subscription_response.get_result()
subscription_id_sandbox = subscription_response.get("id")

except ApiException as e:
pytest.fail(str(e))

Expand Down Expand Up @@ -2427,6 +2502,32 @@ def test_update_subscription_example(self):
subscription_response = update_subscription_response.get_result()
print(json.dumps(subscription_response, indent=2))

custom_email_sandbox_update_attributes_invite_model = {"add": ["tester5@ibm.com"]}

custom_email_sandbox_update_attributes_to_remove_model = {"remove": ["testuser@in.ibm.com"]}

subscription_update_attributes_model = {
"invited": custom_email_sandbox_update_attributes_invite_model,
"add_notification_payload": True,
"reply_to_mail": "reply_to_mail@us.com",
"reply_to_name": "US News",
"subscribed": custom_email_sandbox_update_attributes_to_remove_model,
"unsubscribed": custom_email_sandbox_update_attributes_to_remove_model,
}

name = "subscription_custom_email_sandbox update"
description = "Subscription for custom email sandbox updated"
update_subscription_response = self.event_notifications_service.update_subscription(
instance_id,
id=subscription_id_sandbox,
name=name,
description=description,
attributes=subscription_update_attributes_model,
)

subscription_response = update_subscription_response.get_result()
print(json.dumps(subscription_response, indent=2))

# end-update_subscription
except ApiException as e:
pytest.fail(str(e))
Expand Down Expand Up @@ -2524,6 +2625,22 @@ def test_send_notifications_example(self):
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)"

email_attachment_model = {
'content': 'VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50', # Base64 encoded "This is a test file content"
'filename': 'test_document.txt',
'content_type': 'text/plain',
'disposition': 'attachment',
}

email_attachment_model_2 = {
'content': 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==', # Base64 encoded 1x1 pixel PNG
'filename': 'test_image.png',
'content_type': 'image/png',
'disposition': 'attachment',
}

email_attachments = [email_attachment_model, email_attachment_model_2]

notification_create_model = {
"ibmenseverity": notification_severity,
"ibmenfcmbody": json.dumps(notification_fcm_body_model),
Expand All @@ -2542,6 +2659,7 @@ def test_send_notifications_example(self):
"ibmenslackto": slackto,
"ibmenmms": mms,
"ibmentemplates": templates,
"attachments": email_attachments,
"id": notification_id,
"source": notifications_source,
"type": type_value,
Expand Down Expand Up @@ -2929,6 +3047,7 @@ def test_delete_subscription_example(self):
subscription_id9,
subscription_id10,
subscription_id22,
subscription_id_sandbox,
]:
delete_subscription_response = event_notifications_service.delete_subscription(instance_id, id)
print(
Expand Down Expand Up @@ -2990,6 +3109,7 @@ def test_delete_destination_example(self):
destination_id19,
destination_id20,
destination_id22,
destination_id_sandbox,
]:
delete_destination_response = event_notifications_service.delete_destination(instance_id, id)
print(
Expand Down
Loading
Loading