Skip to content

Commit 1a82d6d

Browse files
committed
Merge branch 'm-kovalsky/delete_external_data_share'
2 parents a4ff1ec + 092c1ed commit 1a82d6d

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

src/sempy_labs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
list_external_data_shares_in_item,
9292
create_external_data_share,
9393
revoke_external_data_share,
94+
delete_external_data_share,
9495
)
9596
from ._ml_models import (
9697
list_ml_models,
@@ -498,6 +499,7 @@
498499
"list_external_data_shares_in_item",
499500
"create_external_data_share",
500501
"revoke_external_data_share",
502+
"delete_external_data_share",
501503
"migrate_fabric_trial_capacity",
502504
"create_resource_group",
503505
"list_workloads",

src/sempy_labs/_external_data_shares.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
_base_api,
88
_create_dataframe,
99
resolve_item_id,
10+
resolve_item_name_and_id,
11+
resolve_workspace_id,
1012
)
1113
from sempy._utils._log import log
1214

@@ -24,6 +26,8 @@ def create_external_data_share(
2426
2527
This is a wrapper function for the following API: `External Data Shares - Create External Data Share <https://learn.microsoft.com/rest/api/fabric/core/external-data-shares/create-external-data-share>`_.
2628
29+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
30+
2731
Parameters
2832
----------
2933
item_name : str
@@ -53,6 +57,7 @@ def create_external_data_share(
5357
method="post",
5458
status_codes=201,
5559
payload=payload,
60+
client="fabric_sp",
5661
)
5762
print(
5863
f"{icons.green_dot} An external data share was created for the '{item_name}' {item_type} within the '{workspace_name}' workspace for the {paths} paths."
@@ -71,6 +76,8 @@ def revoke_external_data_share(
7176
7277
This is a wrapper function for the following API: `External Data Shares - Revoke External Data Share <https://learn.microsoft.com/rest/api/fabric/core/external-data-shares/revoke-external-data-share`_.
7378
79+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
80+
7481
Parameters
7582
----------
7683
external_data_share_id : uuid.UUID
@@ -91,6 +98,7 @@ def revoke_external_data_share(
9198
_base_api(
9299
request=f"/v1/workspaces/{workspace_id}/items/{item_id}/externalDataShares/{external_data_share_id}/revoke",
93100
method="post",
101+
client="fabric_sp",
94102
)
95103
print(
96104
f"{icons.green_dot} The '{external_data_share_id}' external data share for the '{item_name}' {item_type} within the '{workspace_name}' workspace has been revoked."
@@ -106,6 +114,8 @@ def list_external_data_shares_in_item(
106114
107115
This is a wrapper function for the following API: `External Data Shares - List External Data Shares In Item <https://learn.microsoft.com/rest/api/fabric/core/external-data-shares/list-external-data-shares-in-item`_.
108116
117+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
118+
109119
Parameters
110120
----------
111121
item_name : str
@@ -123,7 +133,7 @@ def list_external_data_shares_in_item(
123133
A pandas dataframe showing a list of the external data shares that exist for the specified item.
124134
"""
125135

126-
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
136+
workspace_id = resolve_workspace_id(workspace)
127137
item_id = resolve_item_id(item=item_name, type=item_type, workspace=workspace_id)
128138

129139
columns = {
@@ -145,6 +155,7 @@ def list_external_data_shares_in_item(
145155
responses = _base_api(
146156
request=f"/v1/workspaces/{workspace_id}/items/{item_id}/externalDataShares",
147157
uses_pagination=True,
158+
client="fabric_sp",
148159
)
149160

150161
rows = []
@@ -174,3 +185,46 @@ def list_external_data_shares_in_item(
174185
df = pd.DataFrame(rows, columns=list(columns.keys()))
175186

176187
return df
188+
189+
190+
@log
191+
def delete_external_data_share(
192+
external_data_share_id: UUID,
193+
item: str | UUID,
194+
item_type: str,
195+
workspace: Optional[str | UUID] = None,
196+
):
197+
"""
198+
Deletes the specified external data share.
199+
200+
This is a wrapper function for the following API: `External Data Shares Provider - Delete External Data Share <https://learn.microsoft.com/rest/api/fabric/core/external-data-shares-provider/delete-external-data-share`_.
201+
202+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
203+
204+
Parameters
205+
----------
206+
external_data_share_id : uuid.UUID
207+
The external data share ID.
208+
item : str | uuid.UUID
209+
The item name or ID.
210+
item_type : str
211+
The `item type <https://learn.microsoft.com/rest/api/fabric/core/items/list-items?tabs=HTTP#itemtype>`_.
212+
workspace : str | uuid.UUID, default=None
213+
The Fabric workspace name or ID.
214+
Defaults to None which resolves to the workspace of the attached lakehouse
215+
or if no lakehouse attached, resolves to the workspace of the notebook.
216+
"""
217+
218+
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
219+
(item_name, item_id) = resolve_item_name_and_id(
220+
item=item, type=item_type, workspace=workspace_id
221+
)
222+
223+
_base_api(
224+
request=f"/v1/workspaces/{workspace_id}/items/{item_id}/externalDataShares/{external_data_share_id}",
225+
method="delete",
226+
client="fabric_sp",
227+
)
228+
print(
229+
f"{icons.green_dot} The '{external_data_share_id}' external data share for the '{item_name}' {item_type} within the '{workspace_name}' workspace has been revoked."
230+
)

src/sempy_labs/report/_reportwrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,7 @@ def remove_unnecessary_custom_visuals(self):
20832083
item for item in custom_visuals if item not in cv_remove
20842084
]
20852085
self.set_json(
2086-
file_path=self._report_path,
2086+
file_path=self._report_file_path,
20872087
json_path=json_path,
20882088
json_value=updated_custom_visuals,
20892089
)

0 commit comments

Comments
 (0)