semantic-link-labs 0.9.4__py3-none-any.whl → 0.9.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of semantic-link-labs might be problematic. Click here for more details.

Files changed (71) hide show
  1. {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.6.dist-info}/METADATA +19 -2
  2. {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.6.dist-info}/RECORD +71 -64
  3. {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.6.dist-info}/WHEEL +1 -1
  4. sempy_labs/__init__.py +33 -4
  5. sempy_labs/_capacities.py +59 -128
  6. sempy_labs/_capacity_migration.py +19 -21
  7. sempy_labs/_connections.py +2 -4
  8. sempy_labs/_dashboards.py +60 -0
  9. sempy_labs/_data_pipelines.py +5 -31
  10. sempy_labs/_dataflows.py +2 -2
  11. sempy_labs/_dax_query_view.py +55 -0
  12. sempy_labs/_delta_analyzer.py +16 -14
  13. sempy_labs/_environments.py +28 -49
  14. sempy_labs/_eventhouses.py +27 -53
  15. sempy_labs/_eventstreams.py +16 -34
  16. sempy_labs/_external_data_shares.py +4 -10
  17. sempy_labs/_gateways.py +4 -4
  18. sempy_labs/_generate_semantic_model.py +2 -2
  19. sempy_labs/_git.py +90 -1
  20. sempy_labs/_graphQL.py +8 -21
  21. sempy_labs/_helper_functions.py +440 -91
  22. sempy_labs/_kql_databases.py +24 -35
  23. sempy_labs/_kql_querysets.py +15 -32
  24. sempy_labs/_list_functions.py +17 -192
  25. sempy_labs/_managed_private_endpoints.py +9 -2
  26. sempy_labs/_mirrored_databases.py +17 -49
  27. sempy_labs/_ml_experiments.py +6 -31
  28. sempy_labs/_ml_models.py +4 -28
  29. sempy_labs/_model_bpa.py +4 -11
  30. sempy_labs/_model_bpa_bulk.py +23 -27
  31. sempy_labs/_mounted_data_factories.py +119 -0
  32. sempy_labs/_notebooks.py +16 -26
  33. sempy_labs/_one_lake_integration.py +2 -1
  34. sempy_labs/_semantic_models.py +20 -0
  35. sempy_labs/_sql.py +13 -8
  36. sempy_labs/_sqldatabase.py +61 -100
  37. sempy_labs/_utils.py +42 -0
  38. sempy_labs/_vertipaq.py +25 -13
  39. sempy_labs/_warehouses.py +19 -20
  40. sempy_labs/_workloads.py +23 -9
  41. sempy_labs/_workspace_identity.py +6 -0
  42. sempy_labs/_workspaces.py +55 -7
  43. sempy_labs/admin/__init__.py +21 -1
  44. sempy_labs/admin/_apps.py +1 -1
  45. sempy_labs/admin/_artifacts.py +62 -0
  46. sempy_labs/admin/_basic_functions.py +3 -54
  47. sempy_labs/admin/_capacities.py +61 -0
  48. sempy_labs/admin/_reports.py +74 -0
  49. sempy_labs/admin/_scanner.py +2 -2
  50. sempy_labs/admin/_shared.py +4 -2
  51. sempy_labs/admin/_users.py +133 -0
  52. sempy_labs/admin/_workspaces.py +148 -0
  53. sempy_labs/directlake/_directlake_schema_compare.py +2 -1
  54. sempy_labs/directlake/_directlake_schema_sync.py +65 -19
  55. sempy_labs/directlake/_dl_helper.py +0 -6
  56. sempy_labs/directlake/_generate_shared_expression.py +10 -11
  57. sempy_labs/directlake/_guardrails.py +2 -1
  58. sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +12 -25
  59. sempy_labs/directlake/_update_directlake_partition_entity.py +11 -3
  60. sempy_labs/lakehouse/__init__.py +2 -0
  61. sempy_labs/lakehouse/_lakehouse.py +6 -7
  62. sempy_labs/lakehouse/_shortcuts.py +198 -57
  63. sempy_labs/migration/_migration_validation.py +0 -4
  64. sempy_labs/report/_download_report.py +4 -6
  65. sempy_labs/report/_generate_report.py +15 -23
  66. sempy_labs/report/_report_bpa.py +12 -19
  67. sempy_labs/report/_report_functions.py +2 -1
  68. sempy_labs/report/_report_rebind.py +8 -6
  69. sempy_labs/tom/_model.py +34 -16
  70. {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.6.dist-info}/LICENSE +0 -0
  71. {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.6.dist-info}/top_level.txt +0 -0
sempy_labs/_workspaces.py CHANGED
@@ -18,6 +18,8 @@ def delete_user_from_workspace(
18
18
 
19
19
  This is a wrapper function for the following API: `Groups - Delete User In Group <https://learn.microsoft.com/rest/api/power-bi/groups/delete-user-in-group>`_.
20
20
 
21
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
22
+
21
23
  Parameters
22
24
  ----------
23
25
  email_address : str
@@ -33,6 +35,7 @@ def delete_user_from_workspace(
33
35
  _base_api(
34
36
  request=f"/v1.0/myorg/groups/{workspace_id}/users/{email_address}",
35
37
  method="delete",
38
+ client="fabric_sp",
36
39
  )
37
40
  print(
38
41
  f"{icons.green_dot} The '{email_address}' user has been removed from accessing the '{workspace_name}' workspace."
@@ -50,6 +53,8 @@ def update_workspace_user(
50
53
 
51
54
  This is a wrapper function for the following API: `Groups - Update Group User <https://learn.microsoft.com/rest/api/power-bi/groups/update-group-user>`_.
52
55
 
56
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
57
+
53
58
  Parameters
54
59
  ----------
55
60
  email_address : str
@@ -90,6 +95,7 @@ def update_workspace_user(
90
95
  request=f"/v1.0/myorg/groups/{workspace_id}/users",
91
96
  method="put",
92
97
  payload=payload,
98
+ client="fabric_sp",
93
99
  )
94
100
  print(
95
101
  f"{icons.green_dot} The '{email_address}' user has been updated to a '{role_name}' within the '{workspace_name}' workspace."
@@ -102,6 +108,8 @@ def list_workspace_users(workspace: Optional[str | UUID] = None) -> pd.DataFrame
102
108
 
103
109
  This is a wrapper function for the following API: `Workspaces - List Workspace Role Assignments <https://learn.microsoft.com/rest/api/fabric/core/workspaces/list-workspace-role-assignments>`_.
104
110
 
111
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
112
+
105
113
  Parameters
106
114
  ----------
107
115
  workspace : str | uuid.UUID, default=None
@@ -127,7 +135,9 @@ def list_workspace_users(workspace: Optional[str | UUID] = None) -> pd.DataFrame
127
135
  df = _create_dataframe(columns=columns)
128
136
 
129
137
  responses = _base_api(
130
- request=f"v1/workspaces/{workspace_id}/roleAssignments", uses_pagination=True
138
+ request=f"v1/workspaces/{workspace_id}/roleAssignments",
139
+ uses_pagination=True,
140
+ client="fabric_sp",
131
141
  )
132
142
 
133
143
  for r in responses:
@@ -204,7 +214,9 @@ def add_user_to_workspace(
204
214
 
205
215
 
206
216
  def assign_workspace_to_capacity(
207
- capacity_name: str, workspace: Optional[str | UUID] = None
217
+ capacity: str | UUID,
218
+ workspace: Optional[str | UUID] = None,
219
+ **kwargs,
208
220
  ):
209
221
  """
210
222
  Assigns a workspace to a capacity.
@@ -213,16 +225,22 @@ def assign_workspace_to_capacity(
213
225
 
214
226
  Parameters
215
227
  ----------
216
- capacity_name : str
217
- The name of the capacity.
228
+ capacity : str | uuid.UUID
229
+ The name or ID of the capacity.
218
230
  workspace : str | uuid.UUID, default=None
219
231
  The name or ID of the Fabric workspace.
220
232
  Defaults to None which resolves to the workspace of the attached lakehouse
221
233
  or if no lakehouse attached, resolves to the workspace of the notebook.
222
234
  """
223
235
 
236
+ if "capacity_name" in kwargs:
237
+ capacity = kwargs["capacity_name"]
238
+ print(
239
+ f"{icons.warning} The 'capacity_name' parameter is deprecated. Please use 'capacity' instead."
240
+ )
241
+
224
242
  (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
225
- capacity_id = resolve_capacity_id(capacity_name=capacity_name)
243
+ capacity_id = resolve_capacity_id(capacity=capacity)
226
244
 
227
245
  payload = {"capacityId": capacity_id}
228
246
 
@@ -233,7 +251,7 @@ def assign_workspace_to_capacity(
233
251
  status_codes=[200, 202],
234
252
  )
235
253
  print(
236
- f"{icons.green_dot} The '{workspace_name}' workspace has been assigned to the '{capacity_name}' capacity."
254
+ f"{icons.green_dot} The '{workspace_name}' workspace has been assigned to the '{capacity}' capacity."
237
255
  )
238
256
 
239
257
 
@@ -243,6 +261,8 @@ def unassign_workspace_from_capacity(workspace: Optional[str | UUID] = None):
243
261
 
244
262
  This is a wrapper function for the following API: `Workspaces - Unassign From Capacity <https://learn.microsoft.com/rest/api/fabric/core/workspaces/unassign-from-capacity>`_.
245
263
 
264
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
265
+
246
266
  Parameters
247
267
  ----------
248
268
  workspace : str | uuid.UUID, default=None
@@ -257,6 +277,7 @@ def unassign_workspace_from_capacity(workspace: Optional[str | UUID] = None):
257
277
  request=f"/v1/workspaces/{workspace_id}/unassignFromCapacity",
258
278
  method="post",
259
279
  status_codes=[200, 202],
280
+ client="fabric_sp",
260
281
  )
261
282
  print(
262
283
  f"{icons.green_dot} The '{workspace_name}' workspace has been unassigned from its capacity."
@@ -271,6 +292,8 @@ def list_workspace_role_assignments(
271
292
 
272
293
  This is a wrapper function for the following API: `Workspaces - List Workspace Role Assignments <https://learn.microsoft.com/rest/api/fabric/core/workspaces/list-workspace-role-assignments>`_.
273
294
 
295
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
296
+
274
297
  Parameters
275
298
  ----------
276
299
  workspace : str | uuid.UUID, default=None
@@ -295,7 +318,9 @@ def list_workspace_role_assignments(
295
318
  df = _create_dataframe(columns=columns)
296
319
 
297
320
  responses = _base_api(
298
- request=f"v1/workspaces/{workspace_id}/roleAssignments", uses_pagination=True
321
+ request=f"v1/workspaces/{workspace_id}/roleAssignments",
322
+ uses_pagination=True,
323
+ client="fabric_sp",
299
324
  )
300
325
 
301
326
  for r in responses:
@@ -310,3 +335,26 @@ def list_workspace_role_assignments(
310
335
  df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
311
336
 
312
337
  return df
338
+
339
+
340
+ def delete_workspace(workspace: Optional[str | UUID] = None):
341
+ """
342
+ Deletes a workspace.
343
+
344
+ This is a wrapper function for the following API: `Workspaces - Delete Workspace <https://learn.microsoft.com/rest/api/fabric/core/workspaces/delete-workspace>`_.
345
+
346
+ Parameters
347
+ ----------
348
+ workspace : str | uuid.UUID, default=None
349
+ The Fabric workspace name or ID.
350
+ Defaults to None which resolves to the workspace of the attached lakehouse
351
+ or if no lakehouse attached, resolves to the workspace of the notebook.
352
+ """
353
+
354
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
355
+
356
+ _base_api(
357
+ request=f"v1/workspaces/{workspace_id}", method="delete", client="fabric_sp"
358
+ )
359
+
360
+ print(f"{icons.green_dot} The '{workspace_name}' workspace has been deleted.")
@@ -1,3 +1,15 @@
1
+ from sempy_labs.admin._users import (
2
+ list_access_entities,
3
+ list_user_subscriptions,
4
+ )
5
+ from sempy_labs.admin._workspaces import (
6
+ add_user_to_workspace,
7
+ delete_user_from_workspace,
8
+ restore_deleted_workspace,
9
+ )
10
+ from sempy_labs.admin._artifacts import (
11
+ list_unused_artifacts,
12
+ )
1
13
  from sempy_labs.admin._shared import (
2
14
  list_widely_shared_artifacts,
3
15
  )
@@ -12,6 +24,7 @@ from sempy_labs.admin._apps import (
12
24
  from sempy_labs.admin._reports import (
13
25
  list_reports,
14
26
  list_report_users,
27
+ list_report_subscriptions,
15
28
  )
16
29
  from sempy_labs.admin._activities import (
17
30
  list_activity_events,
@@ -24,6 +37,7 @@ from sempy_labs.admin._capacities import (
24
37
  list_capacities,
25
38
  get_capacity_assignment_status,
26
39
  get_capacity_state,
40
+ list_capacity_users,
27
41
  )
28
42
  from sempy_labs.admin._tenant import (
29
43
  list_tenant_settings,
@@ -41,7 +55,6 @@ from sempy_labs.admin._basic_functions import (
41
55
  list_workspaces,
42
56
  list_workspace_access_details,
43
57
  list_modified_workspaces,
44
- list_access_entities,
45
58
  list_workspace_users,
46
59
  )
47
60
  from sempy_labs.admin._domains import (
@@ -113,4 +126,11 @@ __all__ = [
113
126
  "list_capacity_tenant_settings_overrides",
114
127
  "list_capacities_delegated_tenant_settings",
115
128
  "list_domain_tenant_settings_overrides",
129
+ "list_unused_artifacts",
130
+ "add_user_to_workspace",
131
+ "delete_user_from_workspace",
132
+ "restore_deleted_workspace",
133
+ "list_capacity_users",
134
+ "list_user_subscriptions",
135
+ "list_report_subscriptions",
116
136
  ]
sempy_labs/admin/_apps.py CHANGED
@@ -40,7 +40,7 @@ def list_apps(
40
40
  "App Id": "string",
41
41
  "Description": "string",
42
42
  "Published By": "string",
43
- "Last Update": "datetime",
43
+ "Last Update": "datetime_coerce",
44
44
  }
45
45
 
46
46
  df = _create_dataframe(columns=columns)
@@ -0,0 +1,62 @@
1
+ import pandas as pd
2
+ from sempy_labs._helper_functions import (
3
+ _base_api,
4
+ )
5
+ from uuid import UUID
6
+ from typing import Optional
7
+ from sempy_labs.admin._basic_functions import (
8
+ _resolve_workspace_name_and_id,
9
+ _create_dataframe,
10
+ _update_dataframe_datatypes,
11
+ )
12
+
13
+
14
+ def list_unused_artifacts(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
15
+ """
16
+ Returns a list of datasets, reports, and dashboards that have not been used within 30 days for the specified workspace.
17
+
18
+ This is a wrapper function for the following API: `Admin - Groups GetUnusedArtifactsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/groups-get-unused-artifacts-as-admin>`_.
19
+
20
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
21
+
22
+ Returns
23
+ -------
24
+ pandas.DataFrame
25
+ A pandas dataframe showing a list of datasets, reports, and dashboards that have not been used within 30 days for the specified workspace.
26
+ """
27
+
28
+ (workspace_name, workspace_id) = _resolve_workspace_name_and_id(workspace)
29
+
30
+ columns = {
31
+ "Artifact Name": "string",
32
+ "Artifact Id": "string",
33
+ "Artifact Type": "string",
34
+ "Artifact Size in MB": "int",
35
+ "Created Date Time": "datetime",
36
+ "Last Accessed Date Time": "datetime",
37
+ }
38
+
39
+ df = _create_dataframe(columns=columns)
40
+
41
+ responses = _base_api(
42
+ request=f"/v1.0/myorg/admin/groups/{workspace_id}/unused",
43
+ client="fabric_sp",
44
+ uses_pagination=True,
45
+ )
46
+
47
+ for r in responses:
48
+ for i in r.get("unusedArtifactEntities", []):
49
+ new_data = {
50
+ "Artifact Name": i.get("artifactId"),
51
+ "Artifact Id": i.get("displayName"),
52
+ "Artifact Type": i.get("artifactType"),
53
+ "Artifact Size in MB": i.get("artifactSizeInMB"),
54
+ "Created Date Time": i.get("createdDateTime"),
55
+ "Last Accessed Date Time": i.get("lastAccessedDateTime"),
56
+ }
57
+
58
+ df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
59
+
60
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
61
+
62
+ return df
@@ -298,58 +298,6 @@ def list_modified_workspaces(
298
298
  return df
299
299
 
300
300
 
301
- def list_access_entities(
302
- user_email_address: str,
303
- ) -> pd.DataFrame:
304
- """
305
- Shows a list of permission details for Fabric and Power BI items the specified user can access.
306
-
307
- This is a wrapper function for the following API: `Users - List Access Entities <https://learn.microsoft.com/rest/api/fabric/admin/users/list-access-entities>`_.
308
-
309
- Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
310
-
311
- Parameters
312
- ----------
313
- user_email_address : str
314
- The user's email address.
315
-
316
- Returns
317
- -------
318
- pandas.DataFrame
319
- A pandas dataframe showing a list of permission details for Fabric and Power BI items the specified user can access.
320
- """
321
-
322
- columns = {
323
- "Item Id": "string",
324
- "Item Name": "string",
325
- "Item Type": "string",
326
- "Permissions": "string",
327
- "Additional Permissions": "string",
328
- }
329
- df = _create_dataframe(columns=columns)
330
-
331
- responses = _base_api(
332
- request=f"/v1/admin/users/{user_email_address}/access",
333
- client="fabric_sp",
334
- uses_pagination=True,
335
- )
336
-
337
- for r in responses:
338
- for v in r.get("accessEntities", []):
339
- new_data = {
340
- "Item Id": v.get("id"),
341
- "Item Name": v.get("displayName"),
342
- "Item Type": v.get("itemAccessDetails", {}).get("type"),
343
- "Permissions": v.get("itemAccessDetails", {}).get("permissions"),
344
- "Additional Permissions": v.get("itemAccessDetails", {}).get(
345
- "additionalPermissions"
346
- ),
347
- }
348
- df = pd.concat([df, pd.DataFrame([new_data])], ignore_index=True)
349
-
350
- return df
351
-
352
-
353
301
  def list_workspace_access_details(
354
302
  workspace: Optional[Union[str, UUID]] = None,
355
303
  ) -> pd.DataFrame:
@@ -406,9 +354,10 @@ def _resolve_workspace_name_and_id(
406
354
  workspace: str | UUID,
407
355
  ) -> Tuple[str, UUID]:
408
356
 
357
+ from sempy_labs._helper_functions import resolve_workspace_name_and_id
358
+
409
359
  if workspace is None:
410
- workspace_id = fabric.get_workspace_id()
411
- workspace_name = fabric.resolve_workspace_name(workspace_id)
360
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id()
412
361
  else:
413
362
  dfW = list_workspaces(workspace=workspace)
414
363
  if not dfW.empty:
@@ -248,3 +248,64 @@ def list_capacities(
248
248
  df = df[df["Capacity Name"] == capacity]
249
249
 
250
250
  return df
251
+
252
+
253
+ def list_capacity_users(capacity: str | UUID) -> pd.DataFrame:
254
+ """
255
+ Shows a list of users that have access to the specified workspace.
256
+
257
+ This is a wrapper function for the following API: `Admin - Capacities GetCapacityUsersAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/capacities-get-capacity-users-as-admin>`_.
258
+
259
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
260
+
261
+ Parameters
262
+ ----------
263
+ capacity : str | uuid.UUID
264
+ The name or ID of the capacity.
265
+
266
+ Returns
267
+ -------
268
+ pandas.DataFrame
269
+ A pandas dataframe showing a list of users that have access to the specified workspace.
270
+ """
271
+
272
+ (capacity_name, capacity_id) = _resolve_capacity_name_and_id(capacity)
273
+
274
+ columns = {
275
+ "User Name": "string",
276
+ "Email Address": "string",
277
+ "Capacity User Access Right": "string",
278
+ "Identifier": "string",
279
+ "Graph Id": "string",
280
+ "Principal Type": "string",
281
+ "User Type": "string",
282
+ "Profile": "string",
283
+ }
284
+
285
+ df = _create_dataframe(columns=columns)
286
+
287
+ response = _base_api(
288
+ request=f"/v1.0/myorg/admin/capacities/{capacity_id}/users", client="fabric_sp"
289
+ )
290
+
291
+ rows = []
292
+ for v in response.json().get("value", []):
293
+ rows.append(
294
+ {
295
+ "User Name": v.get("displayName"),
296
+ "Email Address": v.get("emailAddress"),
297
+ "Capacity User Access Right": v.get("capacityUserAccessRight"),
298
+ "Identifier": v.get("identifier"),
299
+ "Graph Id": v.get("graphId"),
300
+ "Principal Type": v.get("principalType"),
301
+ "User Type": v.get("userType"),
302
+ "Profile": v.get("profile"),
303
+ }
304
+ )
305
+
306
+ if rows:
307
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
308
+
309
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
310
+
311
+ return df
@@ -163,3 +163,77 @@ def list_report_users(report: str | UUID) -> pd.DataFrame:
163
163
  _update_dataframe_datatypes(dataframe=df, column_map=columns)
164
164
 
165
165
  return df
166
+
167
+
168
+ def list_report_subscriptions(report: str | UUID) -> pd.DataFrame:
169
+ """
170
+ Shows a list of report subscriptions along with subscriber details. This is a preview API call.
171
+
172
+ This is a wrapper function for the following API: `Admin - Reports GetReportSubscriptionsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/reports-get-report-subscriptions-as-admin>`_.
173
+
174
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
175
+
176
+ Parameters
177
+ ----------
178
+ report : str | uuid.UUID
179
+ The name or ID of the report.
180
+
181
+ Returns
182
+ -------
183
+ pandas.DataFrame
184
+ A pandas dataframe showing a list of report subscriptions along with subscriber details. This is a preview API call.
185
+ """
186
+
187
+ report_id = _resolve_report_id(report)
188
+
189
+ columns = {
190
+ "Subscription Id": "string",
191
+ "Title": "string",
192
+ "Artifact Id": "string",
193
+ "Artifact Name": "string",
194
+ "Sub Artifact Name": "string",
195
+ "Artifact Type": "string",
196
+ "Is Enabled": "bool",
197
+ "Frequency": "string",
198
+ "Start Date": "datetime",
199
+ "End Date": "string",
200
+ "Link To Content": "bool",
201
+ "Preview Image": "bool",
202
+ "Attachment Format": "string",
203
+ "Users": "string",
204
+ }
205
+
206
+ df = _create_dataframe(columns=columns)
207
+
208
+ response = _base_api(
209
+ request=f"/v1.0/myorg/admin/reports/{report_id}/subscriptions",
210
+ client="fabric_sp",
211
+ )
212
+
213
+ rows = []
214
+ for v in response.json().get("value", []):
215
+ rows.append(
216
+ {
217
+ "Subscription Id": v.get("id"),
218
+ "Title": v.get("title"),
219
+ "Artifact Id": v.get("artifactId"),
220
+ "Artifact Name": v.get("artifactDisplayName"),
221
+ "Sub Artifact Name": v.get("subArtifactDisplayName"),
222
+ "Artifact Type": v.get("artifactType"),
223
+ "Is Enabled": v.get("isEnabled"),
224
+ "Frequency": v.get("frequency"),
225
+ "Start Date": v.get("startDate"),
226
+ "End Date": v.get("endDate"),
227
+ "Link To Content": v.get("linkToContent"),
228
+ "Preview Image": v.get("previewImage"),
229
+ "Attachment Format": v.get("attachmentFormat"),
230
+ "Users": str(v.get("users")),
231
+ }
232
+ )
233
+
234
+ if rows:
235
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
236
+
237
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
238
+
239
+ return df
@@ -1,4 +1,3 @@
1
- import sempy.fabric as fabric
2
1
  from typing import Optional, List
3
2
  from uuid import UUID
4
3
  from sempy.fabric.exceptions import FabricHTTPException
@@ -10,6 +9,7 @@ from sempy_labs._helper_functions import (
10
9
  _base_api,
11
10
  _is_valid_uuid,
12
11
  _build_url,
12
+ resolve_workspace_name,
13
13
  )
14
14
 
15
15
 
@@ -54,7 +54,7 @@ def scan_workspaces(
54
54
  """
55
55
 
56
56
  if workspace is None:
57
- workspace = fabric.resolve_workspace_name()
57
+ workspace = resolve_workspace_name()
58
58
 
59
59
  if isinstance(workspace, str):
60
60
  workspace = [workspace]
@@ -50,11 +50,13 @@ def list_widely_shared_artifacts(
50
50
  )
51
51
 
52
52
  responses = _base_api(
53
- request=f"/v1.0/myorg/admin/widelySharedArtifacts/{api}", client="fabric_sp"
53
+ request=f"/v1.0/myorg/admin/widelySharedArtifacts/{api}",
54
+ client="fabric_sp",
55
+ uses_pagination=True,
54
56
  )
55
57
 
56
58
  for r in responses:
57
- for v in r.get("value", []):
59
+ for v in r.get("ArtifactAccessEntities", []):
58
60
  sharer = v.get("sharer", {})
59
61
  new_data = {
60
62
  "Artifact Id": v.get("artifactId"),
@@ -0,0 +1,133 @@
1
+ from sempy_labs._helper_functions import (
2
+ _base_api,
3
+ _create_dataframe,
4
+ _update_dataframe_datatypes,
5
+ )
6
+ from uuid import UUID
7
+ import pandas as pd
8
+
9
+
10
+ def list_access_entities(
11
+ user_email_address: str,
12
+ ) -> pd.DataFrame:
13
+ """
14
+ Shows a list of permission details for Fabric and Power BI items the specified user can access.
15
+
16
+ This is a wrapper function for the following API: `Users - List Access Entities <https://learn.microsoft.com/rest/api/fabric/admin/users/list-access-entities>`_.
17
+
18
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
19
+
20
+ Parameters
21
+ ----------
22
+ user_email_address : str
23
+ The user's email address.
24
+
25
+ Returns
26
+ -------
27
+ pandas.DataFrame
28
+ A pandas dataframe showing a list of permission details for Fabric and Power BI items the specified user can access.
29
+ """
30
+
31
+ columns = {
32
+ "Item Id": "string",
33
+ "Item Name": "string",
34
+ "Item Type": "string",
35
+ "Permissions": "string",
36
+ "Additional Permissions": "string",
37
+ }
38
+ df = _create_dataframe(columns=columns)
39
+
40
+ responses = _base_api(
41
+ request=f"/v1/admin/users/{user_email_address}/access",
42
+ client="fabric_sp",
43
+ uses_pagination=True,
44
+ )
45
+
46
+ for r in responses:
47
+ for v in r.get("accessEntities", []):
48
+ new_data = {
49
+ "Item Id": v.get("id"),
50
+ "Item Name": v.get("displayName"),
51
+ "Item Type": v.get("itemAccessDetails", {}).get("type"),
52
+ "Permissions": v.get("itemAccessDetails", {}).get("permissions"),
53
+ "Additional Permissions": v.get("itemAccessDetails", {}).get(
54
+ "additionalPermissions"
55
+ ),
56
+ }
57
+ df = pd.concat([df, pd.DataFrame([new_data])], ignore_index=True)
58
+
59
+ return df
60
+
61
+
62
+ def list_user_subscriptions(user: str | UUID) -> pd.DataFrame:
63
+ """
64
+ Shows a list of subscriptions for the specified user. This is a preview API call.
65
+
66
+ This is a wrapper function for the following API: `Admin - Users GetUserSubscriptionsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/users-get-user-subscriptions-as-admin>`_.
67
+
68
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
69
+
70
+ Parameters
71
+ ----------
72
+ user : str | uuid.UUID
73
+ The graph ID or user principal name (UPN) of the user.
74
+
75
+ Returns
76
+ -------
77
+ pandas.DataFrame
78
+ A pandas dataframe showing a list of subscriptions for the specified user. This is a preview API call.
79
+ """
80
+
81
+ columns = {
82
+ "Subscription Id": "string",
83
+ "Title": "string",
84
+ "Artifact Id": "string",
85
+ "Artifact Name": "string",
86
+ "Sub Artifact Name": "string",
87
+ "Artifact Type": "string",
88
+ "Is Enabled": "bool",
89
+ "Frequency": "string",
90
+ "Start Date": "datetime",
91
+ "End Date": "string",
92
+ "Link To Content": "bool",
93
+ "Preview Image": "bool",
94
+ "Attachment Format": "string",
95
+ "Users": "string",
96
+ }
97
+
98
+ df = _create_dataframe(columns=columns)
99
+
100
+ responses = _base_api(
101
+ request=f"/v1.0/myorg/admin/users/{user}/subscriptions",
102
+ client="fabric_sp",
103
+ uses_pagination=True,
104
+ )
105
+
106
+ rows = []
107
+ for r in responses:
108
+ for v in r.get("subscriptionEntities", []):
109
+ rows.append(
110
+ {
111
+ "Subscription Id": v.get("id"),
112
+ "Title": v.get("title"),
113
+ "Artifact Id": v.get("artifactId"),
114
+ "Artifact Name": v.get("artifactDisplayName"),
115
+ "Sub Artifact Name": v.get("subArtifactDisplayName"),
116
+ "Artifact Type": v.get("artifactType"),
117
+ "Is Enabled": v.get("isEnabled"),
118
+ "Frequency": v.get("frequency"),
119
+ "Start Date": v.get("startDate"),
120
+ "End Date": v.get("endDate"),
121
+ "Link To Content": v.get("linkToContent"),
122
+ "Preview Image": v.get("previewImage"),
123
+ "Attachment Format": v.get("attachmentFormat"),
124
+ "Users": str(v.get("users")),
125
+ }
126
+ )
127
+
128
+ if rows:
129
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
130
+
131
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
132
+
133
+ return df