Generated API reference
yak.Secret
Represents a Secret whose values can be injected into Task Invocations.
Represents a Secret whose values can be injected into Task Invocations.
Secrets can be created from:
- Named secrets stored in the Yak backend (from_name)
- Dictionary of key-value pairs (from_dict)
- .env files (from_dotenv)
- Local environment variables (from_local_environ)
provenance
c2e8cf7c309abe376f390072b94a9ecd3e633080Secret(name: Optional[str] = None, data: Optional[Dict[str, str]] = None)
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
namepositional-or-keyword |
Optional[str] |
None |
Name of the secret in the backend (for remote secrets) |
datapositional-or-keyword |
Optional[Dict[str, str]] |
None |
Inline key-value pairs (for inline secrets) |
Secret.from_name#
Reference a secret by name from the Yak backend.
Reference a secret by name from the Yak backend.
Returns:
Secret instance that will be resolved server-side
from_name(name: str) -> Secret
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
namepositional-or-keyword |
str |
— |
The name of the secret in the organization |
Returns#
SecretSecret.from_dict#
Create a secret from a dictionary of key-value pairs.
Create a secret from a dictionary of key-value pairs.
from_dict(env_dict: Optional[Dict[str, Optional[str]]] = None) -> Secret
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
env_dictpositional-or-keyword |
Optional[Dict[str, Optional[str]]] |
None |
Dictionary of environment variables (None values ignored) |
Returns#
SecretSecret instance with inline data
Secret.from_dotenv#
Create a secret from a .env file.
Create a secret from a .env file.
from_dotenv(path: Optional[str] = None, *, filename: str = '.env') -> Secret
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
pathpositional-or-keyword |
Optional[str] |
None |
Starting path to search for .env file (defaults to cwd) |
filenamekeyword-only |
str |
'.env' |
Name of the env file (defaults to ".env") |
Returns#
SecretSecret instance with data loaded from .env file
Raises#
FileNotFoundErrorIf .env file not found
ImportErrorIf python-dotenv not installed
Secret.from_local_environ#
Create a secret from local environment variables.
Create a secret from local environment variables.
from_local_environ(env_keys: Optional[List[str]] = None) -> Secret
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
env_keyspositional-or-keyword |
Optional[List[str]] |
None |
List of environment variable names to include |
Returns#
SecretSecret instance with data from local environment
Secret.get_environment#
Get the environment variables for this secret (inline only).
Get the environment variables for this secret (inline only).
get_environment() -> Dict[str, str]
Returns#
Dict[str, str]Dictionary of environment variables for inline secrets
Secret.get_secret_names#
Get the secret names to resolve server-side (remote only).
Get the secret names to resolve server-side (remote only).
get_secret_names() -> List[str]
Returns#
List[str]List of secret names for remote secrets, empty for inline
Related guides
- This page is generated from the pinned release schema; update the site pin when a new release should be documented.
- Lifecycle, persistence and operational context belong in the linked handwritten guides.