dkutils.datakitchen_api.vault module¶
- class dkutils.datakitchen_api.vault.Vault(client: DataKitchenClient, kitchen_name: str)[source]¶
Bases:
object
Vault object for performing vault related API requests.
- Parameters
client (DataKitchenClient) – Client for making requests.
kitchen_name (str) – Name of existing kitchen.
- __init__(client: DataKitchenClient, kitchen_name: str) None [source]¶
Vault object for performing vault related API requests.
- Parameters
client (DataKitchenClient) – Client for making requests.
kitchen_name (str) – Name of existing kitchen.
- delete_secret(path: str, is_global: bool = False) requests.models.Response [source]¶
Delete a secret from vault.
- Parameters
path (str) – Path in vault to the secret being deleted.
is_global (boolean, optional) – If True, delete from the global vault. Otherwise, delete from the kitchen vault.
- Raises
HTTPError – If the request fails.
- Returns
Response
object- Return type
requests.Response
- get_config(is_global: bool = False) dict [source]¶
Return the vault configuration for the global or kitchen vault.
- Parameters
is_global (boolean, optional) – If True, return global vault config. Otherwise, return kitchen vault config.
- Raises
HTTPError – If the request fails.
- Returns
Dictionary of vault config of the form:
{ 'inheritable': True, 'prefix': 'Acme/development', 'private': False, 'service': 'custom', 'sourceKitchen': 'Development', 'url': 'https://vault2.datakitchen.io:8200' }
- Return type
dict
- get_secrets(is_global: bool = False)[source]¶
Get a list of paths for all the secrets in the kitchen or global vault. No secret values are returned.
- Parameters
is_global (boolean, optional) – If True, return global vault secret paths. Otherwise, return kitchen vault secret paths.
- Raises
HTTPError – If the request fails.
ValueError – If there is an error retrieving the secrets (e.g. the kitchen does not exist)
- Returns
List of secret paths.
- Return type
list
- update_config(prefix: str, vault_token: str, vault_url: str = 'https://vault2.datakitchen.io:8200', private: bool = False, inheritable: bool = True)[source]¶
Updates the custom vault configuration for a Kitchen.
- Parameters
prefix (str) – Prefix specifying the vault location (e.g. Implementation/dev).
vault_token (str) – Token for the custom vault.
vault_url (str, optional) – Vault URL (default: https://vault2.datakitchen.io:8200).
private (str, optional) – Set to True if this is a private vault service, otherwise set to False (default: False)
inheritable (str, optional) – Set to True if this vault should be inherited by child kitchens, otherwise set to false (default: True).
- Raises
HTTPError – If the request fails.
- Returns
Response
object- Return type
requests.Response
- update_or_add_secret(path: str, value: str, is_global: bool = False) requests.models.Response [source]¶
Update an existing secret value or add a new secret if one does not already exist.
- Parameters
path (str) – Path in vault where the secret will be stored.
value (str) – Value of the secret being stored.
is_global (boolean, optional) – If True, add to the global vault. Otherwise, add to the kitchen vault.
- Raises
HTTPError – If the request fails.
- Returns
Response
object- Return type
requests.Response