공부
[tableau] webhook
승가비
2023. 1. 7. 23:54
728x90
from config import TABLEAU
import tableauserverclient as TSC
auth = TSC.PersonalAccessTokenAuth(
TABLEAU["TOKEN_NAME"],
TABLEAU["TOKEN_VALUE"],
)
server = TSC.Server(
TABLEAU["SERVER_URL"],
use_server_version=True
)
server.auth.sign_in(auth)
list, _ = server.webhooks.get()
for i in list:
server.webhooks.delete(i.id)
print(f"Webhook deleted; {i.name}: {i.id}")
map = {
# "test": "https://webhook.site/27a0c410-3fc7-4052-beba-dba223847473",
"stg": "https://stg",
"prd": "https://prd",
}
for k, v in map.items():
webhook = TSC.WebhookItem()
webhook.event = "datasource-refresh-succeeded"
webhook.name = k
webhook.url = v
webhook = server.webhooks.create(webhook)
print(f"Webhook created; {webhook.name}: {webhook.id}")
Creating Tableau Server webhooks to alert your team when extracts fail or succeed
How to set up webhooks using Python and Tableau’s REST API
medium.com
728x90