Secret
zenml.secret
special
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.
base_secret
Implementation of the Base SecretSchema class.
BaseSecretSchema (BaseModel)
Base class for all Secret Schemas.
Source code in zenml/secret/base_secret.py
class BaseSecretSchema(BaseModel):
"""Base class for all Secret Schemas."""
@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())
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)
model_config = ConfigDict(
# validate attribute assignments
validate_assignment=True,
# report extra attributes as validation failures
extra="forbid",
)
get_schema_keys()
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 zenml/secret/base_secret.py
@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(self)
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 zenml/secret/base_secret.py
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
special
Initialization of secret schemas.
aws_secret_schema
AWS Authentication Secret Schema definition.
AWSSecretSchema (BaseSecretSchema)
AWS Authentication Secret Schema definition.
Source code in zenml/secret/schemas/aws_secret_schema.py
class AWSSecretSchema(BaseSecretSchema):
"""AWS Authentication Secret Schema definition."""
aws_access_key_id: str
aws_secret_access_key: str
aws_session_token: Optional[str] = None
azure_secret_schema
Azure Authentication Secret Schema definition.
AzureSecretSchema (BaseSecretSchema)
Azure Authentication Secret Schema definition.
Source code in zenml/secret/schemas/azure_secret_schema.py
class AzureSecretSchema(BaseSecretSchema):
"""Azure Authentication Secret Schema definition."""
account_name: Optional[str] = None
account_key: Optional[str] = None
sas_token: Optional[str] = None
connection_string: Optional[str] = None
client_id: Optional[str] = None
client_secret: Optional[str] = None
tenant_id: Optional[str] = None
basic_auth_secret_schema
Basic Authentication Secret Schema definition.
BasicAuthSecretSchema (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. |
Source code in zenml/secret/schemas/basic_auth_secret_schema.py
class BasicAuthSecretSchema(BaseSecretSchema):
"""Secret schema for basic authentication.
Attributes:
username: The username that should be used for authentication.
password: The password that should be used for authentication.
"""
username: str
password: str
gcp_secret_schema
GCP Authentication Secret Schema definition.
GCPSecretSchema (BaseSecretSchema)
GCP Authentication Secret Schema definition.
Source code in zenml/secret/schemas/gcp_secret_schema.py
class GCPSecretSchema(BaseSecretSchema):
"""GCP Authentication Secret Schema definition."""
token: str
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_
get_credential_dict(self)
Gets a dictionary of credentials for authenticating to GCP.
Returns:
Type | Description |
---|---|
Dict[str, Any] |
A dictionary representing GCP credentials. |
Exceptions:
Type | Description |
---|---|
ValueError |
If the token value is not a JSON string of a dictionary. |
Source code in zenml/secret/schemas/gcp_secret_schema.py
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_