Skip to content

prefect_slack.credentials

Credential classes used to perform authenticated interacting with Slack

SlackCredentials dataclass

Class for holding Slack credentials for use in tasks and flows.

Parameters:

Name Type Description Default
token str

Bot user OAuth token for the Slack app used to perform actions.

required
Source code in prefect_slack/credentials.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@dataclass
class SlackCredentials:
    """
    Class for holding Slack credentials for use in tasks and flows.

    Args:
        token: Bot user OAuth token for the Slack app used to perform actions.
    """

    token: str

    def get_client(self) -> AsyncWebClient:
        """
        Returns an authenticated `AsyncWebClient` to interact with the Slack API.
        """
        return AsyncWebClient(token=self.token)

get_client

Returns an authenticated AsyncWebClient to interact with the Slack API.

Source code in prefect_slack/credentials.py
19
20
21
22
23
def get_client(self) -> AsyncWebClient:
    """
    Returns an authenticated `AsyncWebClient` to interact with the Slack API.
    """
    return AsyncWebClient(token=self.token)

SlackWebhook dataclass

Class holding a Slack webhook for use in tasks and flows.

Parameters:

Name Type Description Default
url str

Slack webhook URL which can be used to send messages (e.g. https://hooks.slack.com/XXX).

required
Source code in prefect_slack/credentials.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@dataclass
class SlackWebhook:
    """
    Class holding a Slack webhook for use in tasks and flows.

    Args:
        url: Slack webhook URL which can be used to send messages
            (e.g. `https://hooks.slack.com/XXX`).
    """

    url: str

    def get_client(self) -> AsyncWebhookClient:
        """
        Returns and authenticated `AsyncWebhookClient` to interact with the configured
        Slack webhook.
        """
        return AsyncWebhookClient(url=self.url)

get_client

Returns and authenticated AsyncWebhookClient to interact with the configured Slack webhook.

Source code in prefect_slack/credentials.py
38
39
40
41
42
43
def get_client(self) -> AsyncWebhookClient:
    """
    Returns and authenticated `AsyncWebhookClient` to interact with the configured
    Slack webhook.
    """
    return AsyncWebhookClient(url=self.url)