Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stdlib/contrib): add teams package #2866

Merged
merged 5 commits into from
Jun 18, 2020
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
1 change: 1 addition & 0 deletions libflux/go/libflux/buildinfo.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var sourceHashes = map[string]string{
"libflux/src/flux/build.rs": "31a4f825297f9b79d1c8692a5fa3ff9211cb87d01650d147128d061588f75abd",
"libflux/src/flux/lib.rs": "2ba8ed60affa0dc1a060b3cc86e94308ecdf644d282352cbefabaa4496c7fb24",
"stdlib/contrib/chobbs/discord/discord.flux": "8fd42ce1b459969ec3254dc0215a21b3669e01960a203e93c05284384f3eb49a",
"stdlib/contrib/sranka/teams/teams.flux": "57d5656dcb2db79f173e84d551efdbeefb643d028eaaecfff8ee7d2a033f9f50",
"stdlib/contrib/sranka/telegram/telegram.flux": "37d1614a215c6ca523e4efa5642ec9104936755a403e5bc4481d82a602f7719b",
"stdlib/csv/csv.flux": "1951875e6e55fb63d0df75937f38b5051fc7bff5ab0a1bdaf8793bd70329c9a2",
"stdlib/date/date.flux": "4eef9579c89bb8b302ce9b78737c6b370638c021c36825744b89917be1e38bd2",
Expand Down
69 changes: 69 additions & 0 deletions stdlib/contrib/sranka/teams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Teams Package

Use this Flux Package to send a message to a Microsoft Teams channel using an incoming webhook. See https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using#setting-up-a-custom-incoming-webhook .

## teams.message

`message` sends a single message to Microsoft Teams via incoming web hook. Arguments:

| Name | Type | Description |
| ---- | ---- | ----------- |
| url | string | Incoming web hook URL. |
| title | string | Message card title. |
| text | string | Message card text. |
| summary | string | Message card summary, it can be an empty string to generate summary from text. |

All text fields can be formatted using basic [Markdown ](https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#text-formatting).

Basic Example:

import "contrib/sranka/teams"

lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> tableFind(fn: (key) => true)
|> getRecord(idx: 0)

teams.message(
url: "https://outlook.office.com/webhook/12345678-1234-...",
title: "Disk Usage"
text: "Great Scott!- Disk usage is: *${lastReported.status}*.",
summary: "Disk Usage is ${lastReported.status}"
)

## teams.endpoint

`endpoint` function creates a factory function that accepts a mapping function `mapFn` and creates a target function for pipeline `|>` operator that sends messages from table rows. The `mapFn` accepts a table row and returns an object with `title`, `text`, and `summary` as defined in the `teams.message` function arguments. Arguments:

| Name | Type | Description |
| ---- | ---- | ----------- |
| url | string | Incoming web hook URL. |

Basic Example:

import "contrib/sranka/teams"

url = "https://outlook.office.com/webhook/12345678-1234-..."

lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> tableFind(fn: (key) => true)
|> teams.endpoint(url: url)(mapFn: (r) => ({
title: "Disk Usage"
text: "Great Scott!- Disk usage is: **${r.status}**.",
summary: "Disk Usage is ${r.status}"
})
)

## Contact

- Author: Pavel Zavora
- Email: pavel.zavora@bonitoo.io
- Github: [@sranka](https://github.com/sranka)
- Influx Slack: [@sranka](https://influxdata.com/slack)
Loading