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.
- {emberpost-0.2.0 → emberpost-0.3.0}/PKG-INFO +86 -50
- {emberpost-0.2.0 → emberpost-0.3.0}/README.md +84 -48
- {emberpost-0.2.0 → emberpost-0.3.0}/pyproject.toml +2 -2
- {emberpost-0.2.0 → emberpost-0.3.0}/pyproject.toml.orig +2 -2
- {emberpost-0.2.0 → emberpost-0.3.0}/src/emberpost/cli.py +1 -1
- emberpost-0.3.0/src/emberpost/msteams.py +49 -0
- {emberpost-0.2.0 → emberpost-0.3.0}/src/emberpost/post.py +142 -77
- emberpost-0.3.0/src/emberpost/schedule_config.py +203 -0
- {emberpost-0.2.0 → emberpost-0.3.0}/src/emberpost/schemas/schedule.schema.json +117 -104
- emberpost-0.2.0/src/emberpost/schedule_config.py +0 -151
- {emberpost-0.2.0 → emberpost-0.3.0}/LICENSE +0 -0
- {emberpost-0.2.0 → emberpost-0.3.0}/src/emberpost/__init__.py +0 -0
- {emberpost-0.2.0 → emberpost-0.3.0}/src/emberpost/pagerduty.py +0 -0
- {emberpost-0.2.0 → emberpost-0.3.0}/src/emberpost/slack.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: emberpost
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Dispatch PagerDuty on-call schedules to
|
|
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,
|
|
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.
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
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
|
-
###
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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,
|
|
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.
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
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
|
-
###
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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.
|
|
8
|
-
description = "Dispatch PagerDuty on-call schedules to
|
|
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.
|
|
8
|
-
description = "Dispatch PagerDuty on-call schedules to
|
|
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
|
|
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
|