prefect_slack.credentials
Credential classes use to store Slack credentials.
SlackCredentials
Bases: Block
Block holding Slack credentials for use in tasks and flows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
Bot user OAuth token for the Slack app used to perform actions. |
required |
Examples:
Load stored Slack credentials:
from prefect_slack import SlackCredentials
slack_credentials_block = SlackCredentials.load("BLOCK_NAME")
Get a Slack client:
from prefect_slack import SlackCredentials
slack_credentials_block = SlackCredentials.load("BLOCK_NAME")
client = slack_credentials_block.get_client()
Source code in prefect_slack/credentials.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
get_client()
Returns an authenticated AsyncWebClient
to interact with the Slack API.
Source code in prefect_slack/credentials.py
45 46 47 48 49 |
|
SlackWebhook
Bases: NotificationBlock
Block holding a Slack webhook for use in tasks and flows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
Slack webhook URL which can be used to send messages
(e.g. |
required |
Examples:
Load stored Slack webhook:
from prefect_slack import SlackWebhook
slack_webhook_block = SlackWebhook.load("BLOCK_NAME")
Get a Slack webhook client:
from prefect_slack import SlackWebhook
slack_webhook_block = SlackWebhook.load("BLOCK_NAME")
client = slack_webhook_block.get_client()
Send a notification in Slack:
from prefect_slack import SlackWebhook
slack_webhook_block = SlackWebhook.load("BLOCK_NAME")
slack_webhook_block.notify("Hello, world!")
Source code in prefect_slack/credentials.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
get_client()
Returns an authenticated AsyncWebhookClient
to interact with the configured
Slack webhook.
Source code in prefect_slack/credentials.py
93 94 95 96 97 98 |
|
notify(body, subject=None)
async
Sends a message to the Slack channel.
Source code in prefect_slack/credentials.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|