Skip to content

Credentials

Credential classes used to perform authenticated interactions with Monday

MondayCredentials

Bases: Block

Block used to manage Monday authentication.

Attributes:

Name Type Description
token SecretStr

the token to authenticate into Monday.

Examples:

Load stored Monday credentials:

from prefect_monday import MondayCredentials
monday_credentials_block = MondayCredentials.load("BLOCK_NAME")

Source code in prefect_monday/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
50
51
52
53
54
55
56
57
58
59
60
61
62
class MondayCredentials(Block):
    """
    Block used to manage Monday authentication.

    Attributes:
        token: the token to authenticate into Monday.

    Examples:
        Load stored Monday credentials:
        ```python
        from prefect_monday import MondayCredentials
        monday_credentials_block = MondayCredentials.load("BLOCK_NAME")
        ```
    """

    _block_type_name = "Monday Credentials"
    _logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/ad8614977614bcafee59ec5a3ef080111f045ffc-250x250.png"  # noqa

    token: SecretStr = None

    def get_endpoint(self) -> HTTPEndpoint:
        """
        Gets an authenticated Monday GraphQL HTTPEndpoint.

        Returns:
            An authenticated Monday GraphQL HTTPEndpoint

        Example:
            Gets an authenticated Monday GraphQL HTTPEndpoint.
            ```python
            from prefect import flow
            from prefect_monday import MondayCredentials

            @flow
            def example_get_endpoint_flow():
                token = "token_xxxxxxx"
                monday_credentials = MondayCredentials(token=token)
                endpoint = monday_credentials.get_endpoint()
                return endpoint

            example_get_endpoint_flow()
            ```
        """
        if self.token is not None:
            base_headers = {"Authorization": f"Bearer {self.token.get_secret_value()}"}
        else:
            base_headers = None
        endpoint = HTTPEndpoint("https://api.monday.com/v2", base_headers=base_headers)
        return endpoint

get_endpoint()

Gets an authenticated Monday GraphQL HTTPEndpoint.

Returns:

Type Description
HTTPEndpoint

An authenticated Monday GraphQL HTTPEndpoint

Example

Gets an authenticated Monday GraphQL HTTPEndpoint.

from prefect import flow
from prefect_monday import MondayCredentials

@flow
def example_get_endpoint_flow():
    token = "token_xxxxxxx"
    monday_credentials = MondayCredentials(token=token)
    endpoint = monday_credentials.get_endpoint()
    return endpoint

example_get_endpoint_flow()

Source code in prefect_monday/credentials.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def get_endpoint(self) -> HTTPEndpoint:
    """
    Gets an authenticated Monday GraphQL HTTPEndpoint.

    Returns:
        An authenticated Monday GraphQL HTTPEndpoint

    Example:
        Gets an authenticated Monday GraphQL HTTPEndpoint.
        ```python
        from prefect import flow
        from prefect_monday import MondayCredentials

        @flow
        def example_get_endpoint_flow():
            token = "token_xxxxxxx"
            monday_credentials = MondayCredentials(token=token)
            endpoint = monday_credentials.get_endpoint()
            return endpoint

        example_get_endpoint_flow()
        ```
    """
    if self.token is not None:
        base_headers = {"Authorization": f"Bearer {self.token.get_secret_value()}"}
    else:
        base_headers = None
    endpoint = HTTPEndpoint("https://api.monday.com/v2", base_headers=base_headers)
    return endpoint