Metadata-Version: 2.2
Name: key-vault-interface
Version: 1.0.4
Summary: A simple package to work as an interface with a key; at the moment only supporting Azure.
Author-email: Mirco Domenicale <m.domenicale@40-factory.com>
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: azure-identity>=1.19.0
Requires-Dist: azure-keyvault-secrets>=4.9.0
Requires-Dist: yarg>=0.1.9
Provides-Extra: dev
Requires-Dist: pytest>=8.3.4; extra == "dev"
Requires-Dist: pipdeptree>=2.24.0; extra == "dev"
Requires-Dist: pytest-mock==3.14.0; extra == "dev"
Requires-Dist: python-dotenv==1.0.1; extra == "dev"
Requires-Dist: wheel==0.45.1; extra == "dev"
Requires-Dist: twine==6.0.1; extra == "dev"
Requires-Dist: build==1.2.2.post1; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=8.1.3; extra == "docs"
Requires-Dist: docopt>=0.6.2; extra == "docs"
Requires-Dist: ipython>=8.12.3; extra == "docs"
Requires-Dist: nbconvert>=7.16.4; extra == "docs"
Requires-Dist: pdoc==15.0.1; extra == "docs"
Requires-Dist: sphinx-markdown-builder==0.6.7; extra == "docs"

<!-- key vault interface documentation master file, created by
sphinx-quickstart on Tue Dec 17 11:19:41 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. -->

# key vault interface documentation

# API Reference

### *class* key_vault_interface.KeyVaultInterface(\*args, \*\*kwargs)

Bases: `object`

This class serves as an interface for interacting with Azure Key Vault.

Implements a singleton pattern to ensure only one instance is created.
It handles the interaction with Azure Key Vault to retrieve secrets and manage them in memory.

* **Parameters:**
  * **key_vault_name** – The Azure Key Vault name.
  * **tenant_id** – Azure AD Tenant ID.
  * **client_id** – Azure Client ID.
  * **client_secret_var_name** – The environment variable to use to load the client secret matching the client ID.
  * **secrets_to_load** (*dict* *,* *optional*) – Optional dictionary of secrets to load into the interface.

#### forget_secret(alias: str) → None

Removes a secret from memory.

* **Parameters:**
  **alias** (*str*) – Alias of the secret to remove.
* **Raises:**
  **KeyError** – If the secret alias is not found in the loaded secrets.

#### get(secret_name: str) → str

Retrieve a secret value from loaded secrets.

* **Parameters:**
  **secret_name** (*str*) – Name of the secret.
* **Returns:**
  Value of the secret or None if not found.
* **Return type:**
  str
* **Raises:**
  **ValueError** – If the secret_name is not a string.

#### load_secrets() → None

Loads all secrets specified in ‘secrets_to_load’ into memory.

Iterates over the secrets_to_load dictionary and fetches each secret from the Azure Key Vault.

#### update_and_reload_secrets(new_secrets: Dict[str, str]) → None

Updates the list of secrets to load and reloads them.

* **Parameters:**
  **new_secrets** (*dict*) – Dictionary of new secrets to load.
* **Raises:**
  **TypeError** – If new_secrets is not a dictionary.
