Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,12 +1929,12 @@ def get_token(audience="pbi"):
elif client == "fabric_sp":
token = auth.token_provider.get() or get_token
c = fabric.FabricRestClient(token_provider=token)
elif client in ["azure", "graph"]:
elif client in ["azure", "graph", "keyvault"]:
pass
else:
raise ValueError(f"{icons.red_dot} The '{client}' client is not supported.")

if client not in ["azure", "graph"]:
if client not in ["azure", "graph", "keyvault"]:
if method == "get":
response = c.get(request)
elif method == "delete":
Expand All @@ -1947,7 +1947,7 @@ def get_token(audience="pbi"):
response = c.put(request, json=payload)
else:
raise NotImplementedError
else:
elif client in ["azure", "graph"]:
headers = _get_headers(auth.token_provider.get(), audience=client)
if client == "graph":
url = f"https://graph.microsoft.com/v1.0/{request}"
Expand All @@ -1961,6 +1961,31 @@ def get_token(audience="pbi"):
headers=headers,
json=payload,
)
elif client == "keyvault":
token = notebookutils.credentials.getToken("keyvault")
headers = {"Authorization": f"Bearer {token}"}

api_suffix = "?api-version=2025-07-01"

if uses_pagination:
all_items = []
while request:
if not request.endswith(api_suffix):
request += api_suffix
response = requests.request(
method.upper(), request, headers=headers, json=payload
)
result = response.json()
items = result.get("value", [])
all_items.extend(items)
request = result.get("nextLink") # Update to next page if it exists
return all_items
else:
return requests.request(
method.upper(), f"{request}{api_suffix}", headers=headers, json=payload
)
else:
raise NotImplementedError

if lro_return_json:
return lro(c, response, status_codes).json()
Expand Down
28 changes: 28 additions & 0 deletions src/sempy_labs/key_vault/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from ._secrets import (
get_secret,
set_secret,
delete_secret,
list_secrets,
recover_deleted_secret,
purge_deleted_secret,
backup_secret,
restore_secret,
update_secret,
list_deleted_secrets,
list_secret_versions,
)


__all__ = [
"get_secret",
"set_secret",
"delete_secret",
"list_secrets",
"recover_deleted_secret",
"purge_deleted_secret",
"backup_secret",
"restore_secret",
"update_secret",
"list_deleted_secrets",
"list_secret_versions",
]
Loading