Skip to content

Secret

zenml.secret

Initialization of the ZenML Secret module.

A ZenML Secret is a grouping of key-value pairs. These are accessed and administered via the ZenML Secret Store.

Attributes

__all__ = ['BaseSecretSchema'] module-attribute

Classes

BaseSecretSchema

Bases: BaseModel

Base class for all Secret Schemas.

Functions
get_schema_keys() -> List[str] classmethod

Get all attributes that are part of the schema.

These schema keys can be used to define all required key-value pairs of a secret schema.

Returns:

Type Description
List[str]

A list of all attribute names that are part of the schema.

Source code in src/zenml/secret/base_secret.py
24
25
26
27
28
29
30
31
32
33
34
@classmethod
def get_schema_keys(cls) -> List[str]:
    """Get all attributes that are part of the schema.

    These schema keys can be used to define all required key-value pairs of
    a secret schema.

    Returns:
        A list of all attribute names that are part of the schema.
    """
    return list(cls.model_fields.keys())
get_values() -> Dict[str, Any]

Get all values of the secret schema.

Returns:

Type Description
Dict[str, Any]

A dictionary of all attribute names and their corresponding values.

Source code in src/zenml/secret/base_secret.py
36
37
38
39
40
41
42
def get_values(self) -> Dict[str, Any]:
    """Get all values of the secret schema.

    Returns:
        A dictionary of all attribute names and their corresponding values.
    """
    return self.model_dump(exclude_none=True)

Modules

base_secret

Implementation of the Base SecretSchema class.

Classes
BaseSecretSchema

Bases: BaseModel

Base class for all Secret Schemas.

Functions
get_schema_keys() -> List[str] classmethod

Get all attributes that are part of the schema.

These schema keys can be used to define all required key-value pairs of a secret schema.

Returns:

Type Description
List[str]

A list of all attribute names that are part of the schema.

Source code in src/zenml/secret/base_secret.py
24
25
26
27
28
29
30
31
32
33
34
@classmethod
def get_schema_keys(cls) -> List[str]:
    """Get all attributes that are part of the schema.

    These schema keys can be used to define all required key-value pairs of
    a secret schema.

    Returns:
        A list of all attribute names that are part of the schema.
    """
    return list(cls.model_fields.keys())
get_values() -> Dict[str, Any]

Get all values of the secret schema.

Returns:

Type Description
Dict[str, Any]

A dictionary of all attribute names and their corresponding values.

Source code in src/zenml/secret/base_secret.py
36
37
38
39
40
41
42
def get_values(self) -> Dict[str, Any]:
    """Get all values of the secret schema.

    Returns:
        A dictionary of all attribute names and their corresponding values.
    """
    return self.model_dump(exclude_none=True)

schemas

Initialization of secret schemas.

Classes
AWSSecretSchema

Bases: BaseSecretSchema

AWS Authentication Secret Schema definition.

AzureSecretSchema

Bases: BaseSecretSchema

Azure Authentication Secret Schema definition.

BasicAuthSecretSchema

Bases: BaseSecretSchema

Secret schema for basic authentication.

Attributes:

Name Type Description
username str

The username that should be used for authentication.

password str

The password that should be used for authentication.

GCPSecretSchema

Bases: BaseSecretSchema

GCP Authentication Secret Schema definition.

Functions
get_credential_dict() -> Dict[str, Any]

Gets a dictionary of credentials for authenticating to GCP.

Returns:

Type Description
Dict[str, Any]

A dictionary representing GCP credentials.

Raises:

Type Description
ValueError

If the token value is not a JSON string of a dictionary.

Source code in src/zenml/secret/schemas/gcp_secret_schema.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
def get_credential_dict(self) -> Dict[str, Any]:
    """Gets a dictionary of credentials for authenticating to GCP.

    Returns:
        A dictionary representing GCP credentials.

    Raises:
        ValueError: If the token value is not a JSON string of a dictionary.
    """
    try:
        dict_ = json.loads(self.token)
    except json.JSONDecodeError:
        raise ValueError(
            "Failed to parse GCP secret token. The token value is not a "
            "valid JSON string."
        )

    if not isinstance(dict_, Dict):
        raise ValueError(
            "Failed to parse GCP secret token. The token value does not "
            "represent a GCP credential dictionary."
        )

    return dict_
Modules
aws_secret_schema

AWS Authentication Secret Schema definition.

Classes
AWSSecretSchema

Bases: BaseSecretSchema

AWS Authentication Secret Schema definition.

azure_secret_schema

Azure Authentication Secret Schema definition.

Classes
AzureSecretSchema

Bases: BaseSecretSchema

Azure Authentication Secret Schema definition.

basic_auth_secret_schema

Basic Authentication Secret Schema definition.

Classes
BasicAuthSecretSchema

Bases: BaseSecretSchema

Secret schema for basic authentication.

Attributes:

Name Type Description
username str

The username that should be used for authentication.

password str

The password that should be used for authentication.

gcp_secret_schema

GCP Authentication Secret Schema definition.

Classes
GCPSecretSchema

Bases: BaseSecretSchema

GCP Authentication Secret Schema definition.

Functions
get_credential_dict() -> Dict[str, Any]

Gets a dictionary of credentials for authenticating to GCP.

Returns:

Type Description
Dict[str, Any]

A dictionary representing GCP credentials.

Raises:

Type Description
ValueError

If the token value is not a JSON string of a dictionary.

Source code in src/zenml/secret/schemas/gcp_secret_schema.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
def get_credential_dict(self) -> Dict[str, Any]:
    """Gets a dictionary of credentials for authenticating to GCP.

    Returns:
        A dictionary representing GCP credentials.

    Raises:
        ValueError: If the token value is not a JSON string of a dictionary.
    """
    try:
        dict_ = json.loads(self.token)
    except json.JSONDecodeError:
        raise ValueError(
            "Failed to parse GCP secret token. The token value is not a "
            "valid JSON string."
        )

    if not isinstance(dict_, Dict):
        raise ValueError(
            "Failed to parse GCP secret token. The token value does not "
            "represent a GCP credential dictionary."
        )

    return dict_