semantic-link-labs 0.9.3__py3-none-any.whl → 0.9.5__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 (68) hide show
  1. {semantic_link_labs-0.9.3.dist-info → semantic_link_labs-0.9.5.dist-info}/METADATA +25 -6
  2. {semantic_link_labs-0.9.3.dist-info → semantic_link_labs-0.9.5.dist-info}/RECORD +68 -52
  3. {semantic_link_labs-0.9.3.dist-info → semantic_link_labs-0.9.5.dist-info}/WHEEL +1 -1
  4. sempy_labs/__init__.py +45 -4
  5. sempy_labs/_capacities.py +22 -127
  6. sempy_labs/_capacity_migration.py +11 -9
  7. sempy_labs/_dashboards.py +60 -0
  8. sempy_labs/_data_pipelines.py +5 -31
  9. sempy_labs/_dax.py +17 -3
  10. sempy_labs/_delta_analyzer.py +279 -127
  11. sempy_labs/_environments.py +20 -48
  12. sempy_labs/_eventhouses.py +69 -30
  13. sempy_labs/_eventstreams.py +16 -34
  14. sempy_labs/_gateways.py +4 -4
  15. sempy_labs/_generate_semantic_model.py +30 -10
  16. sempy_labs/_git.py +90 -1
  17. sempy_labs/_graphQL.py +3 -20
  18. sempy_labs/_helper_functions.py +201 -44
  19. sempy_labs/_job_scheduler.py +226 -2
  20. sempy_labs/_kql_databases.py +19 -34
  21. sempy_labs/_kql_querysets.py +15 -32
  22. sempy_labs/_list_functions.py +14 -133
  23. sempy_labs/_mirrored_databases.py +14 -48
  24. sempy_labs/_ml_experiments.py +5 -30
  25. sempy_labs/_ml_models.py +4 -28
  26. sempy_labs/_model_bpa.py +17 -0
  27. sempy_labs/_model_bpa_rules.py +12 -2
  28. sempy_labs/_mounted_data_factories.py +119 -0
  29. sempy_labs/_notebooks.py +16 -26
  30. sempy_labs/_semantic_models.py +117 -0
  31. sempy_labs/_sql.py +78 -10
  32. sempy_labs/_sqldatabase.py +227 -0
  33. sempy_labs/_utils.py +42 -0
  34. sempy_labs/_vertipaq.py +17 -2
  35. sempy_labs/_warehouses.py +5 -17
  36. sempy_labs/_workloads.py +23 -9
  37. sempy_labs/_workspaces.py +13 -5
  38. sempy_labs/admin/__init__.py +70 -9
  39. sempy_labs/admin/_activities.py +166 -0
  40. sempy_labs/admin/_apps.py +143 -0
  41. sempy_labs/admin/_artifacts.py +62 -0
  42. sempy_labs/admin/_basic_functions.py +32 -704
  43. sempy_labs/admin/_capacities.py +311 -0
  44. sempy_labs/admin/_datasets.py +184 -0
  45. sempy_labs/admin/_domains.py +1 -1
  46. sempy_labs/admin/_items.py +3 -1
  47. sempy_labs/admin/_reports.py +239 -0
  48. sempy_labs/admin/_scanner.py +0 -1
  49. sempy_labs/admin/_shared.py +76 -0
  50. sempy_labs/admin/_tenant.py +489 -0
  51. sempy_labs/admin/_users.py +133 -0
  52. sempy_labs/admin/_workspaces.py +148 -0
  53. sempy_labs/directlake/_dl_helper.py +0 -1
  54. sempy_labs/directlake/_update_directlake_partition_entity.py +14 -0
  55. sempy_labs/graph/_teams.py +1 -1
  56. sempy_labs/graph/_users.py +9 -1
  57. sempy_labs/lakehouse/__init__.py +2 -0
  58. sempy_labs/lakehouse/_lakehouse.py +6 -7
  59. sempy_labs/lakehouse/_shortcuts.py +216 -64
  60. sempy_labs/report/__init__.py +3 -1
  61. sempy_labs/report/_download_report.py +4 -1
  62. sempy_labs/report/_export_report.py +272 -0
  63. sempy_labs/report/_generate_report.py +9 -17
  64. sempy_labs/report/_report_bpa.py +12 -19
  65. sempy_labs/report/_report_functions.py +9 -261
  66. sempy_labs/tom/_model.py +307 -40
  67. {semantic_link_labs-0.9.3.dist-info → semantic_link_labs-0.9.5.dist-info}/LICENSE +0 -0
  68. {semantic_link_labs-0.9.3.dist-info → semantic_link_labs-0.9.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,489 @@
1
+ from sempy_labs._helper_functions import (
2
+ _update_dataframe_datatypes,
3
+ _base_api,
4
+ _create_dataframe,
5
+ )
6
+ from sempy._utils._log import log
7
+ import pandas as pd
8
+ from uuid import UUID
9
+ from sempy_labs.admin._capacities import _resolve_capacity_name_and_id
10
+ import sempy_labs._icons as icons
11
+ from typing import Optional, List
12
+
13
+
14
+ @log
15
+ def list_tenant_settings() -> pd.DataFrame:
16
+ """
17
+ Lists all tenant settings.
18
+
19
+ This is a wrapper function for the following API: `Tenants - List Tenant Settings <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-tenant-settings>`_.
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
+
23
+ Returns
24
+ -------
25
+ pandas.DataFrame
26
+ A pandas dataframe showing the tenant settings.
27
+ """
28
+
29
+ columns = {
30
+ "Setting Name": "string",
31
+ "Title": "string",
32
+ "Enabled": "bool",
33
+ "Can Specify Security Groups": "bool",
34
+ "Tenant Setting Group": "string",
35
+ "Enabled Security Groups": "string",
36
+ }
37
+ df = _create_dataframe(columns=columns)
38
+
39
+ response = _base_api(request="/v1/admin/tenantsettings", client="fabric_sp")
40
+
41
+ for i in response.json().get("value", []):
42
+ new_data = {
43
+ "Setting Name": i.get("settingName"),
44
+ "Title": i.get("title"),
45
+ "Enabled": i.get("enabled"),
46
+ "Can Specify Security Groups": i.get("canSpecifySecurityGroups"),
47
+ "Tenant Setting Group": i.get("tenantSettingGroup"),
48
+ "Enabled Security Groups": [i.get("enabledSecurityGroups", [])],
49
+ }
50
+ df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
51
+
52
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
53
+
54
+ return df
55
+
56
+
57
+ @log
58
+ def list_capacity_tenant_settings_overrides(
59
+ capacity: Optional[str | UUID] = None,
60
+ return_dataframe: bool = True,
61
+ ) -> pd.DataFrame | dict:
62
+ """
63
+ Returns list of tenant setting overrides that override at the capacities.
64
+
65
+ This is a wrapper function for the following API: `Tenants - List Capacities Tenant Settings Overrides <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-capacities-tenant-settings-overrides>`_.
66
+
67
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
68
+
69
+ Parameters
70
+ ----------
71
+ capacity : str | uuid.UUID, default=None
72
+ The capacity name or ID.
73
+ Defaults to None which resolves to showing all capacities.
74
+ return_dataframe : bool, default=True
75
+ If True, returns a dataframe. If False, returns a dictionary.
76
+
77
+ Returns
78
+ -------
79
+ pandas.DataFrame | dict
80
+ A pandas dataframe showing a list of tenant setting overrides that override at the capacities.
81
+ """
82
+
83
+ columns = {
84
+ "Capacity Id": "string",
85
+ "Setting Name": "string",
86
+ "Setting Title": "string",
87
+ "Setting Enabled": "bool",
88
+ "Can Specify Security Groups": "bool",
89
+ "Enabled Security Groups": "string",
90
+ "Tenant Setting Group": "string",
91
+ "Tenant Setting Properties": "string",
92
+ "Delegate to Workspace": "bool",
93
+ "Delegated From": "string",
94
+ }
95
+
96
+ if capacity is None:
97
+ url = "/v1/admin/capacities/delegatedTenantSettingOverrides"
98
+ else:
99
+ (_, capacity_id) = _resolve_capacity_name_and_id(capacity=capacity)
100
+ url = f"/v1/admin/capacities/{capacity_id}/delegatedTenantSettingOverrides"
101
+ responses = _base_api(
102
+ request=url,
103
+ client="fabric_sp",
104
+ uses_pagination=True,
105
+ )
106
+
107
+ def create_new_data(setting, capacity_id=None):
108
+ return {
109
+ "Capacity Id": capacity_id or setting.get("id"),
110
+ "Setting Name": setting.get("settingName"),
111
+ "Setting Title": setting.get("title"),
112
+ "Setting Enabled": setting.get("enabled"),
113
+ "Can Specify Security Groups": setting.get("canSpecifySecurityGroups"),
114
+ "Enabled Security Groups": setting.get("enabledSecurityGroups", []),
115
+ "Tenant Setting Group": setting.get("tenantSettingGroup"),
116
+ "Tenant Setting Properties": setting.get("properties", []),
117
+ "Delegate to Workspace": setting.get("delegateToWorkspace"),
118
+ "Delegated From": setting.get("delegatedFrom"),
119
+ }
120
+
121
+ def process_responses(responses, capacity_id=None, return_dataframe=False):
122
+ data = []
123
+ df = _create_dataframe(columns=columns)
124
+
125
+ for r in responses:
126
+ if capacity_id is None:
127
+ # If capacity_id is None, we access 'Overrides' -> 'tenantSettings'
128
+ for override in r.get("overrides", []):
129
+ tenant_settings = override.get("tenantSettings", [])
130
+ for setting in tenant_settings:
131
+ data.append(
132
+ create_new_data(setting)
133
+ ) # No capacity_id needed here
134
+ else:
135
+ # If capacity_id is provided, we access 'value' directly for tenantSettings
136
+ for setting in r.get("value", []):
137
+ data.append(
138
+ create_new_data(setting, capacity_id)
139
+ ) # Use provided capacity_id
140
+
141
+ if return_dataframe:
142
+ if data:
143
+ df = pd.DataFrame(data)
144
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
145
+ return df
146
+ else:
147
+ key = "overrides" if capacity_id is None else "value"
148
+ continuation_uri = r.get("continuationUri", "")
149
+ continuation_token = r.get("continuationToken", "")
150
+
151
+ return {
152
+ key: data,
153
+ "continuationUri": continuation_uri,
154
+ "continuationToken": continuation_token,
155
+ }
156
+
157
+ # Main logic
158
+ if capacity is None:
159
+ return (
160
+ process_responses(responses, return_dataframe=True)
161
+ if return_dataframe
162
+ else process_responses(responses)
163
+ )
164
+ else:
165
+ return (
166
+ process_responses(responses, capacity_id=capacity_id, return_dataframe=True)
167
+ if return_dataframe
168
+ else process_responses(responses, capacity_id=capacity_id)
169
+ )
170
+
171
+
172
+ @log
173
+ def list_capacities_delegated_tenant_settings(
174
+ return_dataframe: bool = True,
175
+ ) -> pd.DataFrame | dict:
176
+ """
177
+ Returns list of tenant setting overrides that override at the capacities.
178
+
179
+ NOTE: This function is to be deprecated. Please use the `list_capacity_tenant_settings_overrides` function instead.
180
+
181
+ This is a wrapper function for the following API: `Tenants - List Capacities Tenant Settings Overrides <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-capacities-tenant-settings-overrides>`_.
182
+
183
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
184
+
185
+ Parameters
186
+ ----------
187
+ return_dataframe : bool, default=True
188
+ If True, returns a dataframe. If False, returns a dictionary.
189
+
190
+ Returns
191
+ -------
192
+ pandas.DataFrame | dict
193
+ A pandas dataframe showing a list of tenant setting overrides that override at the capacities.
194
+ """
195
+
196
+ list_capacity_tenant_settings_overrides(return_dataframe=return_dataframe)
197
+
198
+
199
+ @log
200
+ def delete_capacity_tenant_setting_override(capacity: str | UUID, tenant_setting: str):
201
+ """
202
+ Remove given tenant setting override for given capacity Id.
203
+
204
+ This is a wrapper function for the following API: `Tenants - Delete Capacity Tenant Setting Override <https://learn.microsoft.com/rest/api/fabric/admin/tenants/delete-capacity-tenant-setting-override>`_.
205
+
206
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
207
+
208
+ Parameters
209
+ ----------
210
+ capacity : str | uuid.UUID
211
+ The capacity name or ID.
212
+ tenant_setting : str
213
+ The tenant setting name. Example: "TenantSettingForCapacityDelegatedSwitch"
214
+ """
215
+
216
+ (capacity_name, capacity_id) = _resolve_capacity_name_and_id(capacity=capacity)
217
+
218
+ _base_api(
219
+ request=f"/v1/admin/capacities/{capacity_id}/delegatedTenantSettingOverrides/{tenant_setting}",
220
+ client="fabric_sp",
221
+ method="delete",
222
+ )
223
+
224
+ print(
225
+ f"{icons.green_dot} The '{tenant_setting}' tenant setting has been removed from the '{capacity_name}' capacity."
226
+ )
227
+
228
+
229
+ @log
230
+ def update_tenant_setting(
231
+ tenant_setting: str,
232
+ enabled: bool,
233
+ delegate_to_capacity: Optional[bool] = None,
234
+ delegate_to_domain: Optional[bool] = None,
235
+ delegate_to_workspace: Optional[bool] = None,
236
+ enabled_security_groups: Optional[List[dict]] = None,
237
+ excluded_security_groups: Optional[List[dict]] = None,
238
+ properties: Optional[List[dict]] = None,
239
+ ):
240
+ """
241
+ Update a given tenant setting.
242
+
243
+ This is a wrapper function for the following API: `Tenants - Update Tenant Setting <https://learn.microsoft.com/rest/api/fabric/admin/tenants/update-tenant-setting>`_.
244
+
245
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
246
+
247
+ Parameters
248
+ ----------
249
+ tenant_setting : str
250
+ The tenant setting name. Example: "TenantSettingForCapacityDelegatedSwitch"
251
+ enabled : bool
252
+ The status of the tenant setting. False - Disabled, True - Enabled.
253
+ delegate_to_capacity : bool, default=None
254
+ Indicates whether the tenant setting can be delegated to a capacity admin. False - Capacity admin cannot override the tenant setting. True - Capacity admin can override the tenant setting.
255
+ delegate_to_domain : bool, default=None
256
+ Indicates whether the tenant setting can be delegated to a domain admin. False - Domain admin cannot override the tenant setting. True - Domain admin can override the tenant setting.
257
+ delegate_to_workspace : bool, default=None
258
+ Indicates whether the tenant setting can be delegated to a workspace admin. False - Workspace admin cannot override the tenant setting. True - Workspace admin can override the tenant setting.
259
+ enabled_security_groups : List[dict], default=None
260
+ A list of enabled security groups. Example:
261
+ [
262
+ {
263
+ "graphId": "f51b705f-a409-4d40-9197-c5d5f349e2f0",
264
+ "name": "TestComputeCdsa"
265
+ }
266
+ ]
267
+ excluded_security_groups : List[dict], default=None
268
+ A list of excluded security groups. Example:
269
+ [
270
+ {
271
+ "graphId": "f51b705f-a409-4d40-9197-c5d5f349e2f0",
272
+ "name": "TestComputeCdsa"
273
+ }
274
+ ]
275
+ properties : List[dict], default=None
276
+ Tenant setting properties. Example:
277
+ [
278
+ {
279
+ "name": "CreateP2w",
280
+ "value": "true",
281
+ "type": "Boolean"
282
+ }
283
+ ]
284
+ """
285
+
286
+ payload = {"enabled": enabled}
287
+
288
+ if delegate_to_capacity is not None:
289
+ payload["delegateToCapacity"] = delegate_to_capacity
290
+ if delegate_to_domain is not None:
291
+ payload["delegateToDomain"] = delegate_to_domain
292
+ if delegate_to_workspace is not None:
293
+ payload["delegateToWorkspace"] = delegate_to_workspace
294
+ if enabled_security_groups is not None:
295
+ payload["enabledSecurityGroups"] = enabled_security_groups
296
+ if excluded_security_groups is not None:
297
+ payload["excludedSecurityGroups"] = excluded_security_groups
298
+ if properties is not None:
299
+ payload["properties"] = properties
300
+
301
+ _base_api(
302
+ request=f"/v1/admin/tenantsettings/{tenant_setting}/update",
303
+ client="fabric_sp",
304
+ method="post",
305
+ payload=payload,
306
+ )
307
+
308
+ print(f"{icons.green_dot} The '{tenant_setting}' tenant setting has been updated.")
309
+
310
+
311
+ @log
312
+ def update_capacity_tenant_setting_override(
313
+ capacity: str | UUID,
314
+ tenant_setting: str,
315
+ enabled: bool,
316
+ delegate_to_workspace: Optional[bool] = None,
317
+ enabled_security_groups: Optional[List[dict]] = None,
318
+ excluded_security_groups: Optional[List[dict]] = None,
319
+ ):
320
+ """
321
+ Update given tenant setting override for given capacity.
322
+
323
+ This is a wrapper function for the following API: `Tenants - Update Capacity Tenant Setting Override <https://learn.microsoft.com/en-us/rest/api/fabric/admin/tenants/update-capacity-tenant-setting-override>`_.
324
+
325
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
326
+
327
+ Parameters
328
+ ----------
329
+ capacity : str | uuid.UUID
330
+ The capacity name or ID.
331
+ tenant_setting : str
332
+ The tenant setting name. Example: "TenantSettingForCapacityDelegatedSwitch"
333
+ enabled : bool
334
+ The status of the tenant setting. False - Disabled, True - Enabled.
335
+ delegate_to_workspace : bool, default=None
336
+ Indicates whether the tenant setting can be delegated to a workspace admin. False - Workspace admin cannot override the tenant setting. True - Workspace admin can override the tenant setting.
337
+ enabled_security_groups : List[dict], default=None
338
+ A list of enabled security groups. Example:
339
+ [
340
+ {
341
+ "graphId": "f51b705f-a409-4d40-9197-c5d5f349e2f0",
342
+ "name": "TestComputeCdsa"
343
+ }
344
+ ]
345
+ excluded_security_groups : List[dict], default=None
346
+ A list of excluded security groups. Example:
347
+ [
348
+ {
349
+ "graphId": "f51b705f-a409-4d40-9197-c5d5f349e2f0",
350
+ "name": "TestComputeCdsa"
351
+ }
352
+ ]
353
+ """
354
+
355
+ (capacity_name, capacity_id) = _resolve_capacity_name_and_id(capacity=capacity)
356
+
357
+ payload = {"enabled": enabled}
358
+
359
+ if delegate_to_workspace is not None:
360
+ payload["delegateToWorkspace"] = delegate_to_workspace
361
+ if enabled_security_groups is not None:
362
+ payload["enabledSecurityGroups"] = enabled_security_groups
363
+ if excluded_security_groups is not None:
364
+ payload["excludedSecurityGroups"] = excluded_security_groups
365
+
366
+ _base_api(
367
+ request=f"/v1/admin/capacities/{capacity_id}/delegatedTenantSettingOverrides/{tenant_setting}/update",
368
+ client="fabric_sp",
369
+ method="post",
370
+ payload=payload,
371
+ )
372
+
373
+ print(
374
+ f"{icons.green_dot} The '{tenant_setting}' tenant setting for the '{capacity_name}' capacity has been updated."
375
+ )
376
+
377
+
378
+ @log
379
+ def list_workspaces_tenant_settings_overrides() -> pd.DataFrame:
380
+ """
381
+ Shows a list of workspace delegation setting overrides. In order to run this function, you must enable the workspace's delegated OneLake settings. To do this, navigate to the workspace, Workspace Settings -> Delegated Settings -> OneLake settings -> Set to 'On'.
382
+
383
+ This is a wrapper function for the following API: `Tenants - List Workspaces Tenant Settings Overrides <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-workspaces-tenant-settings-overrides>`_.
384
+
385
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
386
+
387
+ Returns
388
+ -------
389
+ pandas.DataFrame
390
+ A pandas dataframe showing a list of workspace delegation setting overrides.
391
+ """
392
+
393
+ columns = {
394
+ "Setting Name": "string",
395
+ "Title": "string",
396
+ "Enabled": "bool",
397
+ "Can Specify Security Groups": "bool",
398
+ "Enabled Security Groups": "string",
399
+ "Tenant Setting Group": "string",
400
+ "Delegated From": "string",
401
+ }
402
+ df = _create_dataframe(columns=columns)
403
+
404
+ responses = _base_api(
405
+ request="/v1/admin/workspaces/delegatedTenantSettingOverrides",
406
+ client="fabric_sp",
407
+ uses_pagination=True,
408
+ )
409
+
410
+ for r in responses:
411
+ for v in r.get("value", []):
412
+ for setting in v.get("tenantSettings", []):
413
+ new_data = {
414
+ "Setting Name": setting.get("settingName"),
415
+ "Title": setting.get("title"),
416
+ "Enabled": setting.get("enabled"),
417
+ "Can Specify Security Groups": setting.get(
418
+ "canSpecifySecurityGroups"
419
+ ),
420
+ "Enabled Security Groups": [
421
+ setting.get("enabledSecurityGroups", [])
422
+ ],
423
+ "Tenant Setting Group": setting.get("tenantSettingGroup"),
424
+ "Delegated From": setting.get("delegatedFrom"),
425
+ }
426
+
427
+ df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
428
+
429
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
430
+
431
+ return df
432
+
433
+
434
+ @log
435
+ def list_domain_tenant_settings_overrides() -> pd.DataFrame:
436
+ """
437
+ Shows a list of domain delegation setting overrides.
438
+
439
+ This is a wrapper function for the following API: `Tenants - List Domains Tenant Settings Overrides <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-domains-tenant-settings-overrides>`_.
440
+
441
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
442
+
443
+ Returns
444
+ -------
445
+ pandas.DataFrame
446
+ A pandas dataframe showing a list of domain delegation setting overrides.
447
+ """
448
+
449
+ columns = {
450
+ "Setting Name": "string",
451
+ "Title": "string",
452
+ "Enabled": "bool",
453
+ "Can Specify Security Groups": "bool",
454
+ "Enabled Security Groups": "string",
455
+ "Tenant Setting Group": "string",
456
+ "Delegated To Workspace": "bool",
457
+ "Delegated From": "string",
458
+ }
459
+ df = _create_dataframe(columns=columns)
460
+
461
+ responses = _base_api(
462
+ request="/v1/admin/domains/delegatedTenantSettingOverrides",
463
+ client="fabric_sp",
464
+ uses_pagination=True,
465
+ )
466
+
467
+ for r in responses:
468
+ for v in r.get("value", []):
469
+ for setting in v.get("tenantSettings", []):
470
+ new_data = {
471
+ "Setting Name": setting.get("settingName"),
472
+ "Title": setting.get("title"),
473
+ "Enabled": setting.get("enabled"),
474
+ "Can Specify Security Groups": setting.get(
475
+ "canSpecifySecurityGroups"
476
+ ),
477
+ "Enabled Security Groups": [
478
+ setting.get("enabledSecurityGroups", [])
479
+ ],
480
+ "Tenant Setting Group": setting.get("tenantSettingGroup"),
481
+ "Delegated To Workspace": setting.get("delegateToWorkspace"),
482
+ "Delegated From": setting.get("delegatedFrom"),
483
+ }
484
+
485
+ df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
486
+
487
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
488
+
489
+ return df
@@ -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