Skip to content

prefect_transform.credentials

Transform credentials block

TransformCredentials

Block used to manage authentication with Transform.

Parameters:

Name Type Description Default
api_key SecretStr

The API key to use to connect to Transform.

required
mql_server_url str

The URL of the Transform MQL server.

required
Example

Load stored Transform credentials

from prefect_transform.credentials import TransformCredentials
transform_credentials_block = TransformCredentials.load("BLOCK_NAME")

Source code in prefect_transform/credentials.py
10
11
12
13
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
class TransformCredentials(Block):
    """
    Block used to manage authentication with Transform.

    Args:
        api_key (SecretStr): The API key to use to connect to Transform.
        mql_server_url (str): The URL of the Transform MQL server.

    Example:
        Load stored Transform credentials
        ```python
        from prefect_transform.credentials import TransformCredentials
        transform_credentials_block = TransformCredentials.load("BLOCK_NAME")
        ```
    """  # noqa E501

    _block_type_name = "Transform Credentials"
    _logo_url = "https://github.com/PrefectHQ/prefect/blob/main/docs/img/collections/transform.png?raw=true"  # noqa

    api_key: SecretStr = Field(..., description="Transform API key")
    mql_server_url: str = Field(..., description="Transform MQL Server URL")

    def get_client(self) -> MQLClient:
        """
        Return an MQLClient that can be used to interact with
        Transform server.

        Returns:
            An `MQLClient` that can be used to interact with Transform server.
        """

        _api_key = self.api_key.get_secret_value()

        try:
            return MQLClient(api_key=_api_key, mql_server_url=self.mql_server_url)
        except (AuthException, URLException) as e:
            msg = f"Cannot connect to Transform server! Error is: {e}"
            raise TransformAuthException(msg) from e

get_client

Return an MQLClient that can be used to interact with Transform server.

Returns:

Type Description
MQLClient

An MQLClient that can be used to interact with Transform server.

Source code in prefect_transform/credentials.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def get_client(self) -> MQLClient:
    """
    Return an MQLClient that can be used to interact with
    Transform server.

    Returns:
        An `MQLClient` that can be used to interact with Transform server.
    """

    _api_key = self.api_key.get_secret_value()

    try:
        return MQLClient(api_key=_api_key, mql_server_url=self.mql_server_url)
    except (AuthException, URLException) as e:
        msg = f"Cannot connect to Transform server! Error is: {e}"
        raise TransformAuthException(msg) from e