Skip to content

prefect_hightouch.credentials

generated

This is a module containing credentials, auto-generated, used to perform authenticated interactions with Hightouch.

HightouchCredentials

Bases: Block

Block used to manage Hightouch authentication.

Attributes:

Name Type Description
token SecretStr

The token to authenticate with Hightouch.

timeout float

Number of seconds before the request times out.

client_kwargs Dict[str, Any]

Additional keyword arguments to pass to prefect_hightouch.api_client.client.AuthenticatedClient.

Examples:

Load stored Hightouch credentials:

from prefect_hightouch import HightouchCredentials
hightouch_credentials_block = HightouchCredentials.load("BLOCK_NAME")

Source code in prefect_hightouch/credentials/generated.py
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
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
class HightouchCredentials(Block):
    """
    Block used to manage Hightouch authentication.

    Attributes:
        token: The token to authenticate with Hightouch.

        timeout: Number of seconds before the request times out.
        client_kwargs: Additional keyword arguments to pass to
            `prefect_hightouch.api_client.client.AuthenticatedClient`.

    Examples:
        Load stored Hightouch credentials:
        ```python
        from prefect_hightouch import HightouchCredentials
        hightouch_credentials_block = HightouchCredentials.load("BLOCK_NAME")
        ```
    """

    _block_type_name = "Hightouch Credentials"
    # _logo_url = "<UPDATE _logo_url IN __init__.py>"  # noqa

    token: SecretStr = Field(default=..., description="Token used for authentication.")
    timeout: float = Field(
        default=5.0, description="Number of seconds before the request times out."
    )
    client_kwargs: Dict[str, Any] = Field(
        default_factory=dict,
        title="Additional configuration",
        description=(
            "Additional keyword arguments to pass to "
            "`prefect_hightouch.api_client.client.AuthenticatedClient`."
        ),
    )

    def get_client(self) -> AuthenticatedClient:
        """
        Gets a Hightouch REST API Authenticated Client.

        Returns:
            A Hightouch REST API Authenticated Client.

        Example:
            Gets a Hightouch REST API Authenticated Client.
            ```python
            from prefect import flow
            from prefect_hightouch import HightouchCredentials

            @flow
            def example_get_client_flow():
                token = "consumer_key"
                hightouch_credentials = HightouchCredentials(token=token)
                client = hightouch_credentials.get_client()
                return client

            example_get_client_flow()
            ```
        """

        base_url = "https://api.hightouch.com/api/v1"

        client_kwargs = self.client_kwargs.copy()
        token = self.token.get_secret_value()
        prefix = "Bearer"
        client = AuthenticatedClient(
            base_url=base_url,
            token=token,
            prefix=prefix,
            timeout=self.timeout,
            **client_kwargs
        )
        return client

get_client

Gets a Hightouch REST API Authenticated Client.

Returns:

Type Description
AuthenticatedClient

A Hightouch REST API Authenticated Client.

Example

Gets a Hightouch REST API Authenticated Client.

from prefect import flow
from prefect_hightouch import HightouchCredentials

@flow
def example_get_client_flow():
    token = "consumer_key"
    hightouch_credentials = HightouchCredentials(token=token)
    client = hightouch_credentials.get_client()
    return client

example_get_client_flow()

Source code in prefect_hightouch/credentials/generated.py
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
def get_client(self) -> AuthenticatedClient:
    """
    Gets a Hightouch REST API Authenticated Client.

    Returns:
        A Hightouch REST API Authenticated Client.

    Example:
        Gets a Hightouch REST API Authenticated Client.
        ```python
        from prefect import flow
        from prefect_hightouch import HightouchCredentials

        @flow
        def example_get_client_flow():
            token = "consumer_key"
            hightouch_credentials = HightouchCredentials(token=token)
            client = hightouch_credentials.get_client()
            return client

        example_get_client_flow()
        ```
    """

    base_url = "https://api.hightouch.com/api/v1"

    client_kwargs = self.client_kwargs.copy()
    token = self.token.get_secret_value()
    prefix = "Bearer"
    client = AuthenticatedClient(
        base_url=base_url,
        token=token,
        prefix=prefix,
        timeout=self.timeout,
        **client_kwargs
    )
    return client