Forked from boxysean/external_email_notifications.sh
Last active
March 28, 2023 15:59
-
-
Save kbrock91/3d68e81508c0137e0588cb3bdbbd52f0 to your computer and use it in GitHub Desktop.
dbt Cloud Notification configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run these commands to create/modify new Notification configurations in dbt Cloud that will alert | |
# an "external" email address of your choosing of job events: cancels, failures, and successes. | |
# Note that you MUST manage this Notification configuration via the API -- there is currently | |
# not UI configuration within dbt Cloud. | |
# parameters: | |
### url | |
# {dbt_url} # the base URL of your dbt account, eg cloud.getdbt.com or emea.dbt.com | |
# {account_id} # Account ID to setup notifications for | |
### headers and body | |
# "account_id": 1, # Account ID to setup notifications for | |
# "user_id": 1, # Required when creating notifications, must be the user_id for an existing user | |
# "on_cancel": [1, 2], # Job IDs to trigger cancel notifications for | |
# "on_failure": [1, 4], # Job IDs to trigger failure notifications for | |
# "on_success": [1, 5], # Job IDs to trigger success notifications for | |
# "state": 1, # 1 = Active, 2 = Deleted | |
# "type": 4, # Always 4, External email notification type | |
# "external_email": "email@example.com" # The email to send notifications to - Needed for the notifications for a new user and has to be removed when updating | |
# create notifications for a new user | |
curl \ | |
--location \ | |
--request POST 'https://{dbt_url}/api/v2/accounts/{account_id}/notifications/' \ | |
--header 'Authorization: Token {XXX}' \ | |
--header 'Content-Type: application/json' \ | |
--data-raw '{ | |
"account_id": {account_id}, | |
"user_id": {user_id}, | |
"on_cancel": [1, 2], | |
"on_failure": [1, 4], | |
"on_success": [1, 5], | |
"state": 1, | |
"type": 4, | |
"external_email": "email@example.com" | |
}' | |
# get the list of existing notifications for external emails, take note of the notification_id and user_id for the notification you want to update | |
curl \ | |
--location \ | |
--request GET 'https://{dbt_url}/api/v2/accounts/{account_id}/notifications/?type=4' \ | |
--header 'Authorization: Token XXX' \ | |
--header 'Content-Type: application/json' | |
# update notifications for an existing user (ex. set state = 2 [deleted]) | |
curl \ | |
--location \ | |
--request POST 'https://{dbt_url}/api/v2/accounts/{account_id}/notifications/{notification_id}' \ | |
--header 'Authorization: Token {XXXX}' \ | |
--header 'Content-Type: application/json' \ | |
--data-raw '{ | |
"id": {notification_id}, | |
"account_id": {account_id} , | |
"user_id": {user_id}, | |
"on_cancel": [], | |
"on_failure": [1], | |
"on_success": [1], | |
"state": 2, | |
"type": 4 | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment