From 09f594e588620aad13026e8f013d6fb568999dd2 Mon Sep 17 00:00:00 2001 From: Vignesh Rao Date: Tue, 21 Jan 2025 22:44:56 -0600 Subject: [PATCH] Includes support for deleting tables in the `VaultAPI` server --- vaultapi/__init__.py | 2 +- vaultapi/config.py | 1 + vaultapi/main.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/vaultapi/__init__.py b/vaultapi/__init__.py index b43c7e3..56941b6 100644 --- a/vaultapi/__init__.py +++ b/vaultapi/__init__.py @@ -4,7 +4,7 @@ from .exceptions import VaultAPIClientError from .main import LOGGER, VaultAPIClient -version = "0.1.0" +version = "0.1.1" def commandline(): diff --git a/vaultapi/config.py b/vaultapi/config.py index 9da880b..08d4cd9 100644 --- a/vaultapi/config.py +++ b/vaultapi/config.py @@ -25,6 +25,7 @@ class EndpointMapping: put_secret: str = "/put-secret" list_tables: str = "/list-tables" create_table: str = "/create-table" + delete_table: str = "/delete-table" delete_secret: str = "/delete-secret" diff --git a/vaultapi/main.py b/vaultapi/main.py index a281f69..8ca9a76 100644 --- a/vaultapi/main.py +++ b/vaultapi/main.py @@ -135,6 +135,20 @@ def create_table(self, table_name: str) -> Dict[str, str]: response = self.SESSION.post(url, params={"table_name": table_name}) return process_response(response) + def delete_table(self, table_name: str) -> Dict[str, str]: + """Deletes an existing table. + + Args: + table_name: Table name. + + Returns: + Dict[str, str]: + Returns the server response. + """ + url = urljoin(self.env_config.vault_server, server_map.delete_table) + response = self.SESSION.delete(url, params={"table_name": table_name}) + return process_response(response) + def get_secret(self, key: str, table_name: str) -> Dict[str, str]: """Retrieves multiple secrets from a table.