Skip to content

prefect_soda_cloud.auth_config

This blocks can be used to store credentials that will be used to authenticate to Soda Cloud APIs.

Classes

SodaCloudAuthConfig

Bases: Block

This block can be used to store the configuration details required to interact with Soda Cloud and its APIs.

Attributes:

Name Type Description
api_base_url str

Soda Cloud base URL.

creds SodaCloudCredentials

SodaCloudCredentials that will be used to authenticate to Soda Cloud.

wait_secs_between_api_calls Optional[int]

The number of seconds to wait between API calls. Default to 10. Must be >= 0.

from prefect_soda_cloud import (
    SodaCloudAuthConfig,
    SodaCloudCredentials
)

auth_config = SodaCloudAuthConfig(
    api_base_url="https://cloud.soda.io",
    creds=SodaCloudCredentials(
        user_or_api_key_id="user",
        pwd_or_api_key_secret="pwd"
    ),
    wait_secs_between_api_calls=1
)
Source code in prefect_soda_cloud/auth_config.py
 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
120
121
122
123
124
125
class SodaCloudAuthConfig(Block):
    """
    This block can be used to store the configuration details
    required to interact with Soda Cloud and its APIs.

    Attributes:
        api_base_url: Soda Cloud base URL.
        creds: `SodaCloudCredentials` that
            will be used to authenticate to Soda Cloud.
        wait_secs_between_api_calls: The number of seconds to
            wait between API calls. Default to `10`. Must be >= 0.

    Example:
    ```python
    from prefect_soda_cloud import (
        SodaCloudAuthConfig,
        SodaCloudCredentials
    )

    auth_config = SodaCloudAuthConfig(
        api_base_url="https://cloud.soda.io",
        creds=SodaCloudCredentials(
            user_or_api_key_id="user",
            pwd_or_api_key_secret="pwd"
        ),
        wait_secs_between_api_calls=1
    )
    ```
    """

    _block_type_name = "Soda Cloud Auth Config"
    _logo_url = "https://avatars.githubusercontent.com/u/45313710?s=200&v=4"  # noqa
    _documentation_url = "https://AlessandroLollo.github.io/prefect-soda-cloud/blocks/#prefect-soda-cloud.auth_config.SodaCloudAuthConfig"  # noqa

    api_base_url: str = Field(
        name="Soda Cloud Base API URL",
        default="https://cloud.soda.io",
        description="Soda Cloud Base API URL.",
    )
    creds: SodaCloudCredentials
    wait_secs_between_api_calls: Optional[int] = Field(
        name="Wait time between API calls",
        default=10,
        description="Wait time in seconds between API calls. Must be >=0.",
    )

    @validator("wait_secs_between_api_calls")
    def _validate_wait_secs_between_api_calls(cls, value: int) -> int:
        """
        TODO
        """
        if value < 0:
            raise ValueError("wait_secs_between_api_calls must be >= 0")
        return value

    def get_client(self, logger: Logger) -> SodaCloudClient:
        """
        Returns a `SodaCloudClient` object.

        Args:
            logger (Logger): A configured logger.

        Returns:
            A `SodaCloudClient` object.
        """
        return SodaCloudClient(
            api_base_url=self.api_base_url,
            username=self.creds.user_or_api_key_id,
            password=self.creds.pwd_or_api_key_secret.get_secret_value(),
            logger=logger,
            wait_secs_between_api_calls=self.wait_secs_between_api_calls,
        )

Functions

get_client

Returns a SodaCloudClient object.

Parameters:

Name Type Description Default
logger Logger

A configured logger.

required

Returns:

Type Description
SodaCloudClient

A SodaCloudClient object.

Source code in prefect_soda_cloud/auth_config.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
def get_client(self, logger: Logger) -> SodaCloudClient:
    """
    Returns a `SodaCloudClient` object.

    Args:
        logger (Logger): A configured logger.

    Returns:
        A `SodaCloudClient` object.
    """
    return SodaCloudClient(
        api_base_url=self.api_base_url,
        username=self.creds.user_or_api_key_id,
        password=self.creds.pwd_or_api_key_secret.get_secret_value(),
        logger=logger,
        wait_secs_between_api_calls=self.wait_secs_between_api_calls,
    )

SodaCloudCredentials

Bases: Block

This block contains sensitive informations that will be used during the authentication flow with Soda Cloud. Please refer to Soda Cloud docs for more information about authentication.

Attributes:

Name Type Description
user_or_api_key_id str

Username or API Key ID.

pwd_or_api_key_secret SecretStr

Password or API Key Secret.

from prefect_soda_cloud import SodaCloudCredentials

creds = SodaCloudCredentials(
    user_or_api_key_id="user",
    pwd_or_api_key_secret="pwd"
)
Source code in prefect_soda_cloud/auth_config.py
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
class SodaCloudCredentials(Block):
    """
    This block contains sensitive informations
    that will be used during the authentication flow
    with Soda Cloud.
    Please refer to
    [Soda Cloud docs](https://docs.soda.io/api-docs/public-cloud-api-v1.html#/operations/GET/api/v1/test-login)
    for more information about authentication.

    Attributes:
        user_or_api_key_id: Username or API Key ID.
        pwd_or_api_key_secret: Password or API Key Secret.

    Example:
    ```python
    from prefect_soda_cloud import SodaCloudCredentials

    creds = SodaCloudCredentials(
        user_or_api_key_id="user",
        pwd_or_api_key_secret="pwd"
    )
    ```
    """  # noqa: E501

    _block_type_name = "Soda Cloud Credentials"
    _logo_url = "https://avatars.githubusercontent.com/u/45313710?s=200&v=4"  # noqa
    _documentation_url = "https://AlessandroLollo.github.io/prefect-soda-cloud/blocks/#prefect-soda-cloud.auth_config.SodaCloudCredentials"  # noqa

    user_or_api_key_id: str = Field(
        name="Username or API Key ID",
        default=None,
        description="Soda Cloud username or API Key ID.",
    )
    pwd_or_api_key_secret: SecretStr = Field(
        name="Password or API Key Secret",
        description="Soda Cloud password or API Key Secret.",
    )