emberpost 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: emberpost
3
- Version: 0.2.0
4
- Summary: Dispatch PagerDuty on-call schedules to Slack.
3
+ Version: 0.3.0
4
+ Summary: Dispatch PagerDuty on-call schedules to notification providers.
5
5
  Author: JSChronicles
6
6
  License-Expression: MIT
7
7
  License-File: LICENSE
@@ -56,9 +56,9 @@ Description-Content-Type: text/markdown
56
56
 
57
57
  ## Introduction
58
58
 
59
- `emberpost` keeps Slack aligned with the current PagerDuty on-call rotation. It reads a YAML schedule definition, resolves the active on-call users from PagerDuty, maps them to Slack users by email, and then updates the configured Slack channel.
59
+ `emberpost` keeps Slack and Microsoft Teams aligned with the current PagerDuty on-call rotation. It reads a YAML schedule definition, resolves the active on-call users from PagerDuty, and publishes each schedule group to its effective provider destination.
60
60
 
61
- Use it to post an on-call summary, update a channel topic, or keep a Slack user group in sync with the people currently carrying the pager. Schedule files can be marked as `daily`, `weekly`, or `manual`, which makes the same command safe to run from automation while only processing the rotations due for that run.
61
+ Use it to post an on-call summary to Slack or Microsoft Teams, update a Slack channel topic, or keep a Slack user group in sync with the people currently carrying the pager. Schedule files can be marked as `daily`, `weekly`, or `manual`, which makes the same command safe to run from automation while only processing the rotations due for that run.
62
62
 
63
63
  Start with [examples/01-minimal.yaml](examples/01-minimal.yaml) for the smallest working schedule shape, then add channel topics, user groups, headers, or footers as needed.
64
64
 
@@ -70,15 +70,15 @@ Install the project and its dependencies with [uv](https://docs.astral.sh/uv/):
70
70
  uv sync
71
71
  ```
72
72
 
73
- Commands can then be run through `uv run`, which uses the project environment automatically. The `--frequency` flag is an automation guardrail: a `weekly` schedule is skipped during a `daily` run. Set `slack.set_channel_topic: true` to update a channel topic instead of posting a message.
73
+ Commands can then be run through `uv run`, which uses the project environment automatically. The `--frequency` flag is an automation guardrail: a `weekly` schedule is skipped during a `daily` run. For a Slack provider, set `destination.provider.options.set_channel_topic: true` to update a channel topic instead of posting a message.
74
74
 
75
- Run a dry run before writing to Slack:
75
+ Run a dry run before writing to a destination provider:
76
76
 
77
77
  ```console
78
78
  uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run
79
79
  ```
80
80
 
81
- Run the weekly schedule and update Slack:
81
+ Run the weekly schedule and update its configured destinations:
82
82
 
83
83
  ```console
84
84
  uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly
@@ -102,50 +102,68 @@ Run with more logging while troubleshooting:
102
102
  uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run --log-level DEBUG
103
103
  ```
104
104
 
105
- Add `slack_group_id` under a schedule group heading to sync that heading's resolved users to a Slack user group:
105
+ The top-level `destination` is used by every schedule group that does not define a complete override. Provider-specific settings live under `provider.options`:
106
106
 
107
107
  ```yaml
108
- pagerduty:
109
- tenant: example.pagerduty.com
110
- schedule_groups:
111
- Platform Coverage:
112
- slack_group_id: S0123456789
113
- entries:
114
- - schedule_id: PEXAMPLE1
115
- label: "Primary Responder"
116
- - schedule_id: PEXAMPLE2
117
- label: "Backup Responder"
108
+ pagerduty_tenant: example.pagerduty.com
109
+
110
+ destination:
111
+ provider:
112
+ name: slack
113
+ options:
114
+ space: example.slack.com
115
+ channel_id: C0123456789
116
+ set_channel_topic: false
117
+
118
+ schedule_groups:
119
+ Platform Coverage:
120
+ entries:
121
+ - schedule_id: PEXAMPLE1
122
+ label: "Primary Responder"
118
123
  ```
119
124
 
120
- The top-level `slack` block is the default destination for every schedule group.
121
- Any group can override `slack_space`, `slack_channel_id`, or
122
- `set_channel_topic`; values omitted from the group inherit from the top-level
123
- block:
125
+ Add `slack_group_id` to a group using an effective Slack destination to synchronize that group's resolved users to a Slack user group. A group may replace the default with another complete Slack or Microsoft Teams destination:
124
126
 
125
127
  ```yaml
126
- pagerduty:
127
- tenant: example.pagerduty.com
128
- schedule_groups:
129
- Platform Coverage:
130
- entries:
131
- - schedule_id: PEXAMPLE1
132
- label: "Primary Responder"
133
- Database Coverage:
134
- slack_space: database-team.slack.com
135
- slack_channel_id: C0987654321
136
- set_channel_topic: true
137
- entries:
138
- - schedule_id: PEXAMPLE2
139
- label: "Database Responder"
140
-
141
- slack:
142
- slack_space: example.slack.com
143
- slack_channel_id: C0123456789
144
- set_channel_topic: false
128
+ pagerduty_tenant: example.pagerduty.com
129
+
130
+ destination:
131
+ provider:
132
+ name: slack
133
+ options:
134
+ space: example.slack.com
135
+ channel_id: C0123456789
136
+ set_channel_topic: false
137
+
138
+ schedule_groups:
139
+ Platform Coverage:
140
+ slack_group_id: S0123456789
141
+ entries:
142
+ - schedule_id: PEXAMPLE1
143
+ label: "Primary Responder"
144
+ Database Coverage:
145
+ destination:
146
+ provider:
147
+ name: slack
148
+ options:
149
+ space: database-team.slack.com
150
+ channel_id: C0987654321
151
+ set_channel_topic: true
152
+ entries:
153
+ - schedule_id: PEXAMPLE2
154
+ label: "Database Responder"
155
+ Incident Coverage:
156
+ destination:
157
+ provider:
158
+ name: msteams
159
+ options:
160
+ webhook_env: MSTEAMS_WEBHOOK_INCIDENT
161
+ entries:
162
+ - schedule_id: PEXAMPLE3
163
+ label: "Incident Commander"
145
164
  ```
146
165
 
147
- Here, `Platform Coverage` uses all three top-level defaults. `Database Coverage`
148
- uses its own workspace and channel and updates that channel's topic.
166
+ Here, `Platform Coverage` uses the default Slack destination, `Database Coverage` replaces it with another Slack channel topic, and `Incident Coverage` posts through a Microsoft Teams Workflows webhook.
149
167
 
150
168
  ## Setting up your Slack Bot
151
169
 
@@ -210,13 +228,31 @@ settings:
210
228
  1. You’ll receive a Bot User OAuth Token once approved
211
229
  1. save this securely.
212
230
 
213
- ### Setup GitHub Repository Slack Notification
214
- 1. Create a slack app, if you haven't already
215
- 1. Go to the GitHub repository → Select Settings → select Secrets and variables → Select Actions → Add these three secrets under New repository secret and under Dependabot
216
- 1. `SLACK_BOT_TOKEN` - This is the authentication token you receive after creating and installing your Slack app. It allows your app to interact with the Slack API and post messages as a bot.
217
- 1. `SLACK_CHANNEL_ID` - The ID of the primary Slack channel where you want production alerts or notifications to be sent.
218
- 1. To find a channel ID, right-click on any Slack channel you have access to and select Copy then Copy link. The URL will look something like this: `https://xxxxx.slack.com/archives/Cxxxxx`. The part at the end that starts with a 'C' is the channel ID you’ll need.
219
- 1. `SLACK_CHANNEL_ID_TEST` - An optional separate channel ID used for testing purposes. It's recommended to use this during development to avoid cluttering your main channel with test messages.
231
+ ### Configure Slack credentials
232
+
233
+ For each configured Slack workspace, uppercase the hostname and replace non-alphanumeric characters with underscores. Store its bot token in the resulting environment variable:
234
+
235
+ ```text
236
+ example.slack.com -> SLACK_API_KEY_EXAMPLE_SLACK_COM
237
+ ```
238
+
239
+ To find a channel ID, copy the Slack channel link. The final path segment beginning with `C` is the channel ID.
240
+
241
+ ## Setting up Microsoft Teams
242
+
243
+ In Teams, open **Workflows**, search for an incoming-webhook template, and choose the template that posts to your intended channel or chat. Microsoft provides separate templates for channels, chats, and different authentication modes; these Teams webhook templates do not require a premium license. Select **Anyone** as the trigger authentication mode because Emberpost authenticates with the secret webhook URL and does not send an OAuth token. Choose the destination, save the workflow, add co-owners for operational continuity, and copy the generated webhook URL.
244
+
245
+ Store the URL in the environment variable named by `webhook_env`:
246
+
247
+ ```yaml
248
+ destination:
249
+ provider:
250
+ name: msteams
251
+ options:
252
+ webhook_env: MSTEAMS_WEBHOOK_INCIDENT
253
+ ```
254
+
255
+ Do not store a Teams webhook URL directly in schedule YAML. Each Teams Workflows webhook is bound to the chat or channel selected in its workflow, so no separate Team or channel ID is required. See Microsoft's [incoming webhook setup guide](https://support.microsoft.com/en-us/workflows/send-messages-in-teams-using-incoming-webhooks) for the current template flow.
220
256
 
221
257
 
222
258
 
@@ -29,9 +29,9 @@
29
29
 
30
30
  ## Introduction
31
31
 
32
- `emberpost` keeps Slack aligned with the current PagerDuty on-call rotation. It reads a YAML schedule definition, resolves the active on-call users from PagerDuty, maps them to Slack users by email, and then updates the configured Slack channel.
32
+ `emberpost` keeps Slack and Microsoft Teams aligned with the current PagerDuty on-call rotation. It reads a YAML schedule definition, resolves the active on-call users from PagerDuty, and publishes each schedule group to its effective provider destination.
33
33
 
34
- Use it to post an on-call summary, update a channel topic, or keep a Slack user group in sync with the people currently carrying the pager. Schedule files can be marked as `daily`, `weekly`, or `manual`, which makes the same command safe to run from automation while only processing the rotations due for that run.
34
+ Use it to post an on-call summary to Slack or Microsoft Teams, update a Slack channel topic, or keep a Slack user group in sync with the people currently carrying the pager. Schedule files can be marked as `daily`, `weekly`, or `manual`, which makes the same command safe to run from automation while only processing the rotations due for that run.
35
35
 
36
36
  Start with [examples/01-minimal.yaml](examples/01-minimal.yaml) for the smallest working schedule shape, then add channel topics, user groups, headers, or footers as needed.
37
37
 
@@ -43,15 +43,15 @@ Install the project and its dependencies with [uv](https://docs.astral.sh/uv/):
43
43
  uv sync
44
44
  ```
45
45
 
46
- Commands can then be run through `uv run`, which uses the project environment automatically. The `--frequency` flag is an automation guardrail: a `weekly` schedule is skipped during a `daily` run. Set `slack.set_channel_topic: true` to update a channel topic instead of posting a message.
46
+ Commands can then be run through `uv run`, which uses the project environment automatically. The `--frequency` flag is an automation guardrail: a `weekly` schedule is skipped during a `daily` run. For a Slack provider, set `destination.provider.options.set_channel_topic: true` to update a channel topic instead of posting a message.
47
47
 
48
- Run a dry run before writing to Slack:
48
+ Run a dry run before writing to a destination provider:
49
49
 
50
50
  ```console
51
51
  uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run
52
52
  ```
53
53
 
54
- Run the weekly schedule and update Slack:
54
+ Run the weekly schedule and update its configured destinations:
55
55
 
56
56
  ```console
57
57
  uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly
@@ -75,50 +75,68 @@ Run with more logging while troubleshooting:
75
75
  uv run emberpost --schedule-file schedules/oncall.yaml --frequency weekly --dry-run --log-level DEBUG
76
76
  ```
77
77
 
78
- Add `slack_group_id` under a schedule group heading to sync that heading's resolved users to a Slack user group:
78
+ The top-level `destination` is used by every schedule group that does not define a complete override. Provider-specific settings live under `provider.options`:
79
79
 
80
80
  ```yaml
81
- pagerduty:
82
- tenant: example.pagerduty.com
83
- schedule_groups:
84
- Platform Coverage:
85
- slack_group_id: S0123456789
86
- entries:
87
- - schedule_id: PEXAMPLE1
88
- label: "Primary Responder"
89
- - schedule_id: PEXAMPLE2
90
- label: "Backup Responder"
81
+ pagerduty_tenant: example.pagerduty.com
82
+
83
+ destination:
84
+ provider:
85
+ name: slack
86
+ options:
87
+ space: example.slack.com
88
+ channel_id: C0123456789
89
+ set_channel_topic: false
90
+
91
+ schedule_groups:
92
+ Platform Coverage:
93
+ entries:
94
+ - schedule_id: PEXAMPLE1
95
+ label: "Primary Responder"
91
96
  ```
92
97
 
93
- The top-level `slack` block is the default destination for every schedule group.
94
- Any group can override `slack_space`, `slack_channel_id`, or
95
- `set_channel_topic`; values omitted from the group inherit from the top-level
96
- block:
98
+ Add `slack_group_id` to a group using an effective Slack destination to synchronize that group's resolved users to a Slack user group. A group may replace the default with another complete Slack or Microsoft Teams destination:
97
99
 
98
100
  ```yaml
99
- pagerduty:
100
- tenant: example.pagerduty.com
101
- schedule_groups:
102
- Platform Coverage:
103
- entries:
104
- - schedule_id: PEXAMPLE1
105
- label: "Primary Responder"
106
- Database Coverage:
107
- slack_space: database-team.slack.com
108
- slack_channel_id: C0987654321
109
- set_channel_topic: true
110
- entries:
111
- - schedule_id: PEXAMPLE2
112
- label: "Database Responder"
113
-
114
- slack:
115
- slack_space: example.slack.com
116
- slack_channel_id: C0123456789
117
- set_channel_topic: false
101
+ pagerduty_tenant: example.pagerduty.com
102
+
103
+ destination:
104
+ provider:
105
+ name: slack
106
+ options:
107
+ space: example.slack.com
108
+ channel_id: C0123456789
109
+ set_channel_topic: false
110
+
111
+ schedule_groups:
112
+ Platform Coverage:
113
+ slack_group_id: S0123456789
114
+ entries:
115
+ - schedule_id: PEXAMPLE1
116
+ label: "Primary Responder"
117
+ Database Coverage:
118
+ destination:
119
+ provider:
120
+ name: slack
121
+ options:
122
+ space: database-team.slack.com
123
+ channel_id: C0987654321
124
+ set_channel_topic: true
125
+ entries:
126
+ - schedule_id: PEXAMPLE2
127
+ label: "Database Responder"
128
+ Incident Coverage:
129
+ destination:
130
+ provider:
131
+ name: msteams
132
+ options:
133
+ webhook_env: MSTEAMS_WEBHOOK_INCIDENT
134
+ entries:
135
+ - schedule_id: PEXAMPLE3
136
+ label: "Incident Commander"
118
137
  ```
119
138
 
120
- Here, `Platform Coverage` uses all three top-level defaults. `Database Coverage`
121
- uses its own workspace and channel and updates that channel's topic.
139
+ Here, `Platform Coverage` uses the default Slack destination, `Database Coverage` replaces it with another Slack channel topic, and `Incident Coverage` posts through a Microsoft Teams Workflows webhook.
122
140
 
123
141
  ## Setting up your Slack Bot
124
142
 
@@ -183,13 +201,31 @@ settings:
183
201
  1. You’ll receive a Bot User OAuth Token once approved
184
202
  1. save this securely.
185
203
 
186
- ### Setup GitHub Repository Slack Notification
187
- 1. Create a slack app, if you haven't already
188
- 1. Go to the GitHub repository → Select Settings → select Secrets and variables → Select Actions → Add these three secrets under New repository secret and under Dependabot
189
- 1. `SLACK_BOT_TOKEN` - This is the authentication token you receive after creating and installing your Slack app. It allows your app to interact with the Slack API and post messages as a bot.
190
- 1. `SLACK_CHANNEL_ID` - The ID of the primary Slack channel where you want production alerts or notifications to be sent.
191
- 1. To find a channel ID, right-click on any Slack channel you have access to and select Copy then Copy link. The URL will look something like this: `https://xxxxx.slack.com/archives/Cxxxxx`. The part at the end that starts with a 'C' is the channel ID you’ll need.
192
- 1. `SLACK_CHANNEL_ID_TEST` - An optional separate channel ID used for testing purposes. It's recommended to use this during development to avoid cluttering your main channel with test messages.
204
+ ### Configure Slack credentials
205
+
206
+ For each configured Slack workspace, uppercase the hostname and replace non-alphanumeric characters with underscores. Store its bot token in the resulting environment variable:
207
+
208
+ ```text
209
+ example.slack.com -> SLACK_API_KEY_EXAMPLE_SLACK_COM
210
+ ```
211
+
212
+ To find a channel ID, copy the Slack channel link. The final path segment beginning with `C` is the channel ID.
213
+
214
+ ## Setting up Microsoft Teams
215
+
216
+ In Teams, open **Workflows**, search for an incoming-webhook template, and choose the template that posts to your intended channel or chat. Microsoft provides separate templates for channels, chats, and different authentication modes; these Teams webhook templates do not require a premium license. Select **Anyone** as the trigger authentication mode because Emberpost authenticates with the secret webhook URL and does not send an OAuth token. Choose the destination, save the workflow, add co-owners for operational continuity, and copy the generated webhook URL.
217
+
218
+ Store the URL in the environment variable named by `webhook_env`:
219
+
220
+ ```yaml
221
+ destination:
222
+ provider:
223
+ name: msteams
224
+ options:
225
+ webhook_env: MSTEAMS_WEBHOOK_INCIDENT
226
+ ```
227
+
228
+ Do not store a Teams webhook URL directly in schedule YAML. Each Teams Workflows webhook is bound to the chat or channel selected in its workflow, so no separate Team or channel ID is required. See Microsoft's [incoming webhook setup guide](https://support.microsoft.com/en-us/workflows/send-messages-in-teams-using-incoming-webhooks) for the current template flow.
193
229
 
194
230
 
195
231
 
@@ -4,8 +4,8 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "emberpost"
7
- version = "0.2.0"
8
- description = "Dispatch PagerDuty on-call schedules to Slack."
7
+ version = "0.3.0"
8
+ description = "Dispatch PagerDuty on-call schedules to notification providers."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14,<3.15"
11
11
  license = "MIT"
@@ -4,8 +4,8 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "emberpost"
7
- version = "0.2.0"
8
- description = "Dispatch PagerDuty on-call schedules to Slack."
7
+ version = "0.3.0"
8
+ description = "Dispatch PagerDuty on-call schedules to notification providers."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14,<3.15"
11
11
  authors = [
@@ -18,7 +18,7 @@ def _package_version(distribution_name: str) -> str:
18
18
  def parse_args() -> argparse.Namespace:
19
19
  """Parse Emberpost command-line arguments."""
20
20
  parser = argparse.ArgumentParser(
21
- description="Dispatch PagerDuty on-call schedules to Slack."
21
+ description="Dispatch PagerDuty on-call schedules to provider destinations."
22
22
  )
23
23
  parser.add_argument(
24
24
  "--version",
@@ -0,0 +1,49 @@
1
+ import json
2
+ import os
3
+ from urllib.request import Request, urlopen
4
+
5
+
6
+ class MSTeamsClient:
7
+ """Client for posting messages through a Microsoft Teams Workflow webhook."""
8
+
9
+ def __init__(self, webhook_env: str) -> None:
10
+ """Initialize the client from a configured webhook environment variable."""
11
+ self.webhook_env = webhook_env
12
+ self.webhook_url = self._webhook_url()
13
+
14
+ def post_message(self, message: str) -> None:
15
+ """Post a plain-text Adaptive Card through the configured workflow."""
16
+ payload = {
17
+ "type": "message",
18
+ "attachments": [
19
+ {
20
+ "contentType": "application/vnd.microsoft.card.adaptive",
21
+ "contentUrl": None,
22
+ "content": {
23
+ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
24
+ "type": "AdaptiveCard",
25
+ "version": "1.2",
26
+ "body": [{"type": "TextBlock", "text": message, "wrap": True}],
27
+ },
28
+ }
29
+ ],
30
+ }
31
+ request = Request(
32
+ self.webhook_url,
33
+ data=json.dumps(payload).encode("utf-8"),
34
+ headers={"Content-Type": "application/json"},
35
+ method="POST",
36
+ )
37
+ with urlopen(request, timeout=30) as response:
38
+ if not 200 <= response.status < 300:
39
+ raise RuntimeError(
40
+ f"Microsoft Teams webhook returned HTTP {response.status}"
41
+ )
42
+
43
+ def _webhook_url(self) -> str:
44
+ webhook_url = os.getenv(self.webhook_env)
45
+ if not webhook_url:
46
+ raise ValueError(
47
+ f"Missing Microsoft Teams Workflow webhook URL. Set {self.webhook_env}."
48
+ )
49
+ return webhook_url