Skip to content

Commit

Permalink
Merge pull request #79 from TeskaLabs/Enhancement/Update-Readme
Browse files Browse the repository at this point in the history
Update Readme with Notification examples
  • Loading branch information
mithunbharadwaj authored Oct 17, 2024
2 parents 26f949a + 5cd30de commit 84ecc7c
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 56 deletions.
52 changes: 0 additions & 52 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,6 @@
- test
- build

test py37:
stage: test
image: pcr.teskalabs.com/python:3.7
tags:
- amd64
- docker
script:
- apt-get update
- pip install --upgrade pip
- pip install -U git+https://github.com/TeskaLabs/asab
- pip install flake8
- pip install jinja2
- pip install reportlab==3.6.6 # Freeze reportlab version because of https://github.com/xhtml2pdf/xhtml2pdf/issues/589
- pip install xhtml2pdf
- pip install Markdown
- pip install Pillow
- pip install aiosmtplib
- pip install aiohttp
- pip install requests
- pip install temp
- pip install aiokafka
- pip install slack-sdk
- pip install sentry-sdk
- pip install pytz
- python3 -m unittest test


test py38:
stage: test
image: pcr.teskalabs.com/python:3.8
tags:
- amd64
- docker
script:
- apt-get update
- pip install --upgrade pip
- pip install -U git+https://github.com/TeskaLabs/asab
- pip install flake8
- pip install jinja2
- pip install aiosmtplib
- pip install Markdown
- pip install reportlab==3.6.6 # Freeze reportlab version because of https://github.com/xhtml2pdf/xhtml2pdf/issues/589
- pip install xhtml2pdf
- pip install Pillow
- pip install requests
- pip install aiohttp
- pip install temp
- pip install aiokafka
- pip install slack-sdk
- pip install sentry-sdk
- pip install pytz
- python3 -m unittest test

test py39:
stage: test
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,11 @@

### 24.04.2024

- Change SMTP status code
- Change SMTP status code


### Maintenance

#### 17. 10. 2024

- Drop support for python 3.7 and 3.8
88 changes: 87 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,90 @@ Here are some common format strings you can use with the `datetimeformat` filter
- `%A, %d %B %Y` - Outputs as `Monday, 17 June 2024`
- `%I:%M %p` - Outputs as `02:45 PM`
- `%B %d, %Y` - Outputs as `June 17, 2024`
- `%Y-%m-%d` - Outputs as `2024-06-17`
- `%Y-%m-%d` - Outputs as `2024-06-17`


### 🚀 5. Sending Notifications to Kafka

**Overview**

ASAB Iris supports sending notifications to various communication channels such as email, Slack, and Microsoft Teams via Kafka. Each notification is structured using templates and parameters to ensure customizable content.

#### Kafka Message Structure

- Notifications are sent to Kafka in JSON format.
- Each notification contains a `type` field specifying the channel (e.g., `email`, `slack`, `msteams`), and a `body` that includes the template and its parameters.

#### 1. Sending Email Notifications

**Example Kafka Message:**

```json
{
"type": "email",
"to": ["Shivashankar <mithunshivashankar@gmail.com>"],
"from": "info@teskalabs.com",
"body": {
"template": "/Templates/Email/message.md",
"params": {
"name": "I am testing a template",
"error": "None"
}
}
}
```

**Explanation:**

- `type`: Defines the notification type as `email`.
- `to`: List of recipients.
- `from`: The sender's email address.
- `template`: Path to the template used for the email content.
- `params`: Parameters for populating the email template.

#### 2. Sending Slack Notifications

**Example Kafka Message:**

```json
{
"type": "slack",
"body": {
"template": "/Templates/Slack/Slack example.md",
"params": {
"name": "I am testing a template",
"error": "None"
}
}
}
```

**Explanation:**

- `type`: Defines the notification type as `slack`.
- `body.template`: Path to the Slack message template.
- `params`: Parameters for populating the Slack template.

#### 3. Sending Microsoft Teams Notifications

**Example Kafka Message:**

```json
{
"type": "msteams",
"body": {
"template": "/Templates/MSTeams/Teams example.md",
"params": {
"name": "I am testing a template",
"error": "None"
}
}
}
```

**Explanation:**

- `type`: Defines the notification type as `msteams`.
- `body.template`: Path to the Microsoft Teams message template.
- `params`: Parameters for populating the Teams template.
```
8 changes: 6 additions & 2 deletions qa.md
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,10 @@ EXPECTED RESPONSE:
{"type":"email", "to": ["Shivashankar <mithunshivashankar@gmail.com>"], "from": "info@teskalabs.com", "body":{"template":"/Templates/Export.md", "params":{"name": "I am testing a template", "error": "None" }}}
'WITHOUT FROM'
{"type":"email", "to": ["Shivashankar <mithunshivashankar@gmail.com>"], "body":{"template":"/Templates/Export.md", "params":{"name": "I am testing a template", "error": "None" }}}
'MARKDOWN-WRAPPER'
{"type":"email", "to": ["Shivashankar <mithunshivashankar@gmail.com>"], "from": "info@teskalabs.com", "body":{"template":"/Templates/Email/message.md", "params":{"name": "I am testing a template", "error": "None" }}}
Expand Down Expand Up @@ -1507,9 +1511,9 @@ EXPECTED RESPONSE:
`MSTEAMS`

```
{"type":"msteams", "body":{"template":"/Templates/MSTeams/Slack example.txt", "params":{"name": "I am testing a template", "error": "None" }}}
{"type":"msteams", "body":{"template":"/Templates/MSTeams/Teams example.txt", "params":{"name": "I am testing a template", "error": "None" }}}
{"type":"msteams", "body":{"template":"/Templates/MSTeams/Slack example.txt", "params":{"name": "I am testing a template", "error": "None" }}}
{"type":"msteams", "body":{"template":"/Templates/MSTeams/Teams example.txt", "params":{"name": "I am testing a template", "error": "None" }}}
'Bad template path'
{"type":"msteams", "body":{"template":"/Templates/MSTeamss/message.md", "params":{"name": "I am testing a template", "error": "None" }}}
Expand Down

0 comments on commit 84ecc7c

Please sign in to comment.