Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added reset_shortcut_cache #419

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
4 changes: 2 additions & 2 deletions src/sempy_labs/admin/_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def update_domain(


def assign_domain_workspaces_by_capacities(
domain: Optional[str | UUID] = None,
domain: str | UUID,
capacity_names: str | List[str],
**kwargs,
):
Expand Down Expand Up @@ -370,7 +370,7 @@ def assign_domain_workspaces_by_capacities(


def assign_domain_workspaces(
domain: Optional[str | UUID], workspace_names: str | List[str]
domain: str | UUID, workspace_names: str | List[str]
):
"""
Assigns workspaces to the specified domain by workspace.
Expand Down
2 changes: 2 additions & 0 deletions src/sempy_labs/lakehouse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# create_shortcut,
create_shortcut_onelake,
delete_shortcut,
reset_shortcut_cache,
)

__all__ = [
Expand All @@ -21,4 +22,5 @@
"create_shortcut_onelake",
"delete_shortcut",
"vacuum_lakehouse_tables",
"reset_shortcut_cache",
]
28 changes: 28 additions & 0 deletions src/sempy_labs/lakehouse/_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,31 @@ def delete_shortcut(
print(
f"{icons.green_dot} The '{shortcut_name}' shortcut in the '{lakehouse}' within the '{workspace_name}' workspace has been deleted."
)


def reset_shortcut_cache(workspace: Optional[str | UUID]):
"""
Deletes any cached files that were stored while reading from shortcuts.

This is a wrapper function for the following API: `OneLake Shortcuts - Reset Shortcut Cache <https://learn.microsoft.com/rest/api/fabric/core/onelake-shortcuts/reset-shortcut-cache>`_.

Parameters
----------
workspace : str | uuid.UUID, default=None
The name or ID of the Fabric workspace.
Defaults to None which resolves to the workspace of the attached lakehouse
or if no lakehouse attached, resolves to the workspace of the notebook.
"""

(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)

_base_api(
request=f"/v1/workspaces/{workspace_id}/onelake/resetShortcutCache",
method="post",
lro_return_status_code=True,
status_codes=None,
)

print(
f"{icons.green_dot} The shortcut cache has been reset for the '{workspace_name}' workspace."
)
Loading