BaseSecretBackend API¶
BaseSecretBackend
¶
Bases: ABC
Contract that every secrets backend must fulfil.
| METHOD | DESCRIPTION |
|---|---|
add_secret |
Store a new secret. |
get_secret |
Retrieve a secret by name. Raises a backend-specific NotFound error if not found. |
update_secret |
Update an existing secret. Raises a backend-specific NotFound error if not found. |
delete_secret |
Delete a secret. Raises if not found. |
list_secrets |
List secret names, optionally under a path prefix. |
add_secret(name: str, secret: Dict[str, Any]) -> None
abstractmethod
¶
Store a new secret.
Behavior varies by backend: - VaultBackend: creates a new KV-v2 version if the path already exists (idempotent/overwrite). - KeyringBackend: raises KeyringError if the name already exists. - EnvFileBackend: raises EnvFileKeyExistsError if any key already exists.
Do not assume idempotency when calling through SecretsManager.
Source code in src/credential_bridge/backends/base.py
get_secret(name: str) -> Dict[str, Any]
abstractmethod
¶
Retrieve a secret by name. Raises a backend-specific NotFound error if not found.
update_secret(name: str, secret: Dict[str, Any]) -> None
abstractmethod
¶
Update an existing secret. Raises a backend-specific NotFound error if not found.
Behavior varies by backend: - VaultBackend: merges supplied keys into the existing secret (other keys are preserved). - KeyringBackend: replaces the entire stored dict with the new value. - EnvFileBackend: replaces each supplied key in-place; raises if any key is missing.