Skip to content

Commit ac08142

Browse files
feat(tem): add support for webhook (#4004)
Co-authored-by: Rémy Léone <[email protected]>
1 parent c3cb877 commit ac08142

11 files changed

+610
-6
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Create a new Webhook triggered by a list of event types and pushed to a Scaleway SNS ARN.
4+
5+
USAGE:
6+
scw tem webhook create [arg=value ...]
7+
8+
ARGS:
9+
[domain-id] ID of the Domain to watch for triggering events
10+
[project-id] Project ID to use. If none is passed the default project ID will be used
11+
[name] Name of the Webhook
12+
[event-types.{index}] List of event types that will trigger an event (unknown_type | email_queued | email_dropped | email_deferred | email_delivered | email_spam | email_mailbox_not_found)
13+
[sns-arn] Scaleway SNS ARN topic to push the events to
14+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
15+
16+
FLAGS:
17+
-h, --help help for create
18+
19+
GLOBAL FLAGS:
20+
-c, --config string The path to the config file
21+
-D, --debug Enable debug mode
22+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
23+
-p, --profile string The config profile to use
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
You must specify the Webhook you want to delete by the `region` and `webhook_id`. Deleting a Webhook is permanent and cannot be undone.
4+
5+
USAGE:
6+
scw tem webhook delete <webhook-id ...> [arg=value ...]
7+
8+
ARGS:
9+
webhook-id ID of the Webhook to delete
10+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
11+
12+
FLAGS:
13+
-h, --help help for delete
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Retrieve information about a specific Webhook using the `webhook_id` and `region` parameters.
4+
5+
USAGE:
6+
scw tem webhook get <webhook-id ...> [arg=value ...]
7+
8+
ARGS:
9+
webhook-id ID of the Webhook to check
10+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
11+
12+
FLAGS:
13+
-h, --help help for get
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Retrieve the list of Webhook events triggered from a specific Webhook or for a specific Project or Organization. You must specify the `region`.
4+
5+
USAGE:
6+
scw tem webhook list-events [arg=value ...]
7+
8+
ARGS:
9+
[order-by] (Optional) List Webhook events corresponding to specific criteria (created_at_desc | created_at_asc)
10+
webhook-id ID of the Webhook linked to the events
11+
[email-id] ID of the email linked to the events
12+
[event-types.{index}] List of event types linked to the events (unknown_type | email_queued | email_dropped | email_deferred | email_delivered | email_spam | email_mailbox_not_found)
13+
[statuses.{index}] List of event statuses (unknown_status | sending | sent | failed)
14+
[project-id] ID of the webhook Project
15+
[domain-id] ID of the domain to watch for triggering events
16+
[organization-id] ID of the webhook Organization
17+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | all)
18+
19+
FLAGS:
20+
-h, --help help for list-events
21+
22+
GLOBAL FLAGS:
23+
-c, --config string The path to the config file
24+
-D, --debug Enable debug mode
25+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
26+
-p, --profile string The config profile to use
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Retrieve Webhooks in a specific Project or in a specific Organization using the `region` parameter.
4+
5+
USAGE:
6+
scw tem webhook list [arg=value ...]
7+
8+
ARGS:
9+
[order-by] (Optional) List Webhooks corresponding to specific criteria (created_at_desc | created_at_asc)
10+
[project-id] (Optional) ID of the Project for which to list the Webhooks
11+
[domain-id] (Optional) ID of the Domain for which to list the Webhooks
12+
[organization-id] (Optional) ID of the Organization for which to list the Webhooks
13+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | all)
14+
15+
FLAGS:
16+
-h, --help help for list
17+
18+
GLOBAL FLAGS:
19+
-c, --config string The path to the config file
20+
-D, --debug Enable debug mode
21+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
22+
-p, --profile string The config profile to use
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Update a Webhook events type, SNS ARN or name.
4+
5+
USAGE:
6+
scw tem webhook update [arg=value ...]
7+
8+
ARGS:
9+
webhook-id ID of the Webhook to update
10+
[name] Name of the Webhook to update
11+
[event-types.{index}] List of event types to update (unknown_type | email_queued | email_dropped | email_deferred | email_delivered | email_spam | email_mailbox_not_found)
12+
[sns-arn] Scaleway SNS ARN topic to update
13+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
14+
15+
FLAGS:
16+
-h, --help help for update
17+
18+
GLOBAL FLAGS:
19+
-c, --config string The path to the config file
20+
-D, --debug Enable debug mode
21+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
22+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-tem-webhook-usage.golden

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
Webhooks enable real-time communication and automation between systems by sending messages through all protocols supported by SNS, such as HTTP, HTTPS, and Serverless Functions, allowing for immediate updates and actions based on specific events. This feature is in beta. You can request quotas from the [Scaleway betas page](https://www.scaleway.com/fr/betas/#email-webhooks).
44

55
USAGE:
6-
scw tem webhook
6+
scw tem webhook <command>
7+
8+
AVAILABLE COMMANDS:
9+
create Create a Webhook
10+
delete Delete a Webhook
11+
get Get information about a Webhook
12+
list List Webhooks
13+
list-events List Webhook triggered events
14+
update Update a Webhook
715

816
FLAGS:
917
-h, --help help for webhook
@@ -13,3 +21,5 @@ GLOBAL FLAGS:
1321
-D, --debug Enable debug mode
1422
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
1523
-p, --profile string The config profile to use
24+
25+
Use "scw tem webhook [command] --help" for more information about a command.

docs/commands/tem.md

Lines changed: 136 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ This API allows you to manage your Transactional Email services.
1616
- [Email statuses](#email-statuses)
1717
- [List emails](#list-emails)
1818
- [Webhook management commands](#webhook-management-commands)
19+
- [Create a Webhook](#create-a-webhook)
20+
- [Delete a Webhook](#delete-a-webhook)
21+
- [Get information about a Webhook](#get-information-about-a-webhook)
22+
- [List Webhooks](#list-webhooks)
23+
- [List Webhook triggered events](#list-webhook-triggered-events)
24+
- [Update a Webhook](#update-a-webhook)
1925

2026

2127
## Domain management commands
@@ -290,13 +296,141 @@ scw tem email list [arg=value ...]
290296

291297
Webhooks enable real-time communication and automation between systems by sending messages through all protocols supported by SNS, such as HTTP, HTTPS, and Serverless Functions, allowing for immediate updates and actions based on specific events. This feature is in beta. You can request quotas from the [Scaleway betas page](https://www.scaleway.com/fr/betas/#email-webhooks).
292298

293-
Webhooks enable real-time communication and automation between systems by sending messages through all protocols supported by SNS, such as HTTP, HTTPS, and Serverless Functions, allowing for immediate updates and actions based on specific events. This feature is in beta. You can request quotas from the [Scaleway betas page](https://www.scaleway.com/fr/betas/#email-webhooks).
299+
300+
### Create a Webhook
301+
302+
Create a new Webhook triggered by a list of event types and pushed to a Scaleway SNS ARN.
303+
304+
**Usage:**
305+
306+
```
307+
scw tem webhook create [arg=value ...]
308+
```
309+
310+
311+
**Args:**
312+
313+
| Name | | Description |
314+
|------|---|-------------|
315+
| domain-id | | ID of the Domain to watch for triggering events |
316+
| project-id | | Project ID to use. If none is passed the default project ID will be used |
317+
| name | | Name of the Webhook |
318+
| event-types.{index} | One of: `unknown_type`, `email_queued`, `email_dropped`, `email_deferred`, `email_delivered`, `email_spam`, `email_mailbox_not_found` | List of event types that will trigger an event |
319+
| sns-arn | | Scaleway SNS ARN topic to push the events to |
320+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
321+
322+
323+
324+
### Delete a Webhook
325+
326+
You must specify the Webhook you want to delete by the `region` and `webhook_id`. Deleting a Webhook is permanent and cannot be undone.
327+
328+
**Usage:**
329+
330+
```
331+
scw tem webhook delete <webhook-id ...> [arg=value ...]
332+
```
333+
334+
335+
**Args:**
336+
337+
| Name | | Description |
338+
|------|---|-------------|
339+
| webhook-id | Required | ID of the Webhook to delete |
340+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
341+
342+
343+
344+
### Get information about a Webhook
345+
346+
Retrieve information about a specific Webhook using the `webhook_id` and `region` parameters.
294347

295348
**Usage:**
296349

297350
```
298-
scw tem webhook
351+
scw tem webhook get <webhook-id ...> [arg=value ...]
299352
```
300353

301354

355+
**Args:**
356+
357+
| Name | | Description |
358+
|------|---|-------------|
359+
| webhook-id | Required | ID of the Webhook to check |
360+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
361+
362+
363+
364+
### List Webhooks
365+
366+
Retrieve Webhooks in a specific Project or in a specific Organization using the `region` parameter.
367+
368+
**Usage:**
369+
370+
```
371+
scw tem webhook list [arg=value ...]
372+
```
373+
374+
375+
**Args:**
376+
377+
| Name | | Description |
378+
|------|---|-------------|
379+
| order-by | One of: `created_at_desc`, `created_at_asc` | (Optional) List Webhooks corresponding to specific criteria |
380+
| project-id | | (Optional) ID of the Project for which to list the Webhooks |
381+
| domain-id | | (Optional) ID of the Domain for which to list the Webhooks |
382+
| organization-id | | (Optional) ID of the Organization for which to list the Webhooks |
383+
| region | Default: `fr-par`<br />One of: `fr-par`, `all` | Region to target. If none is passed will use default region from the config |
384+
385+
386+
387+
### List Webhook triggered events
388+
389+
Retrieve the list of Webhook events triggered from a specific Webhook or for a specific Project or Organization. You must specify the `region`.
390+
391+
**Usage:**
392+
393+
```
394+
scw tem webhook list-events [arg=value ...]
395+
```
396+
397+
398+
**Args:**
399+
400+
| Name | | Description |
401+
|------|---|-------------|
402+
| order-by | One of: `created_at_desc`, `created_at_asc` | (Optional) List Webhook events corresponding to specific criteria |
403+
| webhook-id | Required | ID of the Webhook linked to the events |
404+
| email-id | | ID of the email linked to the events |
405+
| event-types.{index} | One of: `unknown_type`, `email_queued`, `email_dropped`, `email_deferred`, `email_delivered`, `email_spam`, `email_mailbox_not_found` | List of event types linked to the events |
406+
| statuses.{index} | One of: `unknown_status`, `sending`, `sent`, `failed` | List of event statuses |
407+
| project-id | | ID of the webhook Project |
408+
| domain-id | | ID of the domain to watch for triggering events |
409+
| organization-id | | ID of the webhook Organization |
410+
| region | Default: `fr-par`<br />One of: `fr-par`, `all` | Region to target. If none is passed will use default region from the config |
411+
412+
413+
414+
### Update a Webhook
415+
416+
Update a Webhook events type, SNS ARN or name.
417+
418+
**Usage:**
419+
420+
```
421+
scw tem webhook update [arg=value ...]
422+
```
423+
424+
425+
**Args:**
426+
427+
| Name | | Description |
428+
|------|---|-------------|
429+
| webhook-id | Required | ID of the Webhook to update |
430+
| name | | Name of the Webhook to update |
431+
| event-types.{index} | One of: `unknown_type`, `email_queued`, `email_dropped`, `email_deferred`, `email_delivered`, `email_spam`, `email_mailbox_not_found` | List of event types to update |
432+
| sns-arn | | Scaleway SNS ARN topic to update |
433+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
434+
435+
302436

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/mattn/go-isatty v0.0.20
2828
github.com/moby/buildkit v0.13.2
2929
github.com/opencontainers/go-digest v1.0.0
30-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240723092404-648ea2801f9f
30+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240725041911-1cd5fcfaf214
3131
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
3232
github.com/spf13/cobra v1.8.1
3333
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
463463
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
464464
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
465465
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
466-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240723092404-648ea2801f9f h1:xNv7pVCmf+8RmlAnALEeSNS6oGI4DFPAHt+19xY1oa8=
467-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240723092404-648ea2801f9f/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
466+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240725041911-1cd5fcfaf214 h1:OvbLG2G2BmPcxjarPKe/6dC17INl7SSr6q8f11tT0ho=
467+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240725041911-1cd5fcfaf214/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
468468
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
469469
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
470470
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

0 commit comments

Comments
 (0)