semantic-link-labs 0.8.2__py3-none-any.whl → 0.8.4__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.
- {semantic_link_labs-0.8.2.dist-info → semantic_link_labs-0.8.4.dist-info}/METADATA +37 -8
- {semantic_link_labs-0.8.2.dist-info → semantic_link_labs-0.8.4.dist-info}/RECORD +108 -104
- {semantic_link_labs-0.8.2.dist-info → semantic_link_labs-0.8.4.dist-info}/WHEEL +1 -1
- sempy_labs/__init__.py +38 -0
- sempy_labs/_bpa_translation/_model/_translations_am-ET.po +24 -5
- sempy_labs/_bpa_translation/_model/_translations_ar-AE.po +28 -4
- sempy_labs/_bpa_translation/_model/_translations_bg-BG.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_ca-ES.po +33 -4
- sempy_labs/_bpa_translation/_model/_translations_cs-CZ.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_da-DK.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_de-DE.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_el-GR.po +36 -4
- sempy_labs/_bpa_translation/_model/_translations_es-ES.po +90 -58
- sempy_labs/_bpa_translation/_model/_translations_fa-IR.po +31 -5
- sempy_labs/_bpa_translation/_model/_translations_fi-FI.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_fr-FR.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_ga-IE.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_he-IL.po +28 -4
- sempy_labs/_bpa_translation/_model/_translations_hi-IN.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_hu-HU.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_id-ID.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_is-IS.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_it-IT.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_ja-JP.po +24 -4
- sempy_labs/_bpa_translation/_model/_translations_ko-KR.po +72 -56
- sempy_labs/_bpa_translation/_model/_translations_mt-MT.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_nl-NL.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_pl-PL.po +95 -71
- sempy_labs/_bpa_translation/_model/_translations_pt-BR.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_pt-PT.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_ro-RO.po +33 -4
- sempy_labs/_bpa_translation/_model/_translations_ru-RU.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_sk-SK.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_sl-SL.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_sv-SE.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_ta-IN.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_te-IN.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_th-TH.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_tr-TR.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_uk-UA.po +100 -72
- sempy_labs/_bpa_translation/_model/_translations_zh-CN.po +23 -5
- sempy_labs/_bpa_translation/_model/_translations_zu-ZA.po +32 -4
- sempy_labs/_capacities.py +138 -25
- sempy_labs/_capacity_migration.py +161 -60
- sempy_labs/_clear_cache.py +3 -3
- sempy_labs/_data_pipelines.py +54 -0
- sempy_labs/_dataflows.py +4 -0
- sempy_labs/_deployment_pipelines.py +13 -7
- sempy_labs/_environments.py +6 -0
- sempy_labs/_eventhouses.py +6 -0
- sempy_labs/_eventstreams.py +6 -0
- sempy_labs/_external_data_shares.py +190 -0
- sempy_labs/_generate_semantic_model.py +26 -4
- sempy_labs/_git.py +15 -15
- sempy_labs/_helper_functions.py +186 -11
- sempy_labs/_icons.py +55 -22
- sempy_labs/_kql_databases.py +6 -0
- sempy_labs/_kql_querysets.py +6 -0
- sempy_labs/_list_functions.py +6 -3
- sempy_labs/_managed_private_endpoints.py +166 -0
- sempy_labs/_mirrored_warehouses.py +2 -0
- sempy_labs/_ml_experiments.py +6 -0
- sempy_labs/_ml_models.py +6 -0
- sempy_labs/_model_bpa.py +11 -6
- sempy_labs/_model_bpa_bulk.py +14 -30
- sempy_labs/_model_bpa_rules.py +8 -3
- sempy_labs/_notebooks.py +111 -15
- sempy_labs/_query_scale_out.py +8 -6
- sempy_labs/_refresh_semantic_model.py +299 -49
- sempy_labs/_spark.py +12 -5
- sempy_labs/_sql.py +2 -2
- sempy_labs/_translations.py +16 -14
- sempy_labs/_vertipaq.py +127 -116
- sempy_labs/_warehouses.py +90 -1
- sempy_labs/_workloads.py +128 -0
- sempy_labs/_workspace_identity.py +4 -4
- sempy_labs/_workspaces.py +14 -1
- sempy_labs/admin/__init__.py +2 -0
- sempy_labs/admin/_basic_functions.py +203 -58
- sempy_labs/admin/_domains.py +18 -18
- sempy_labs/directlake/__init__.py +2 -0
- sempy_labs/directlake/_directlake_schema_sync.py +2 -6
- sempy_labs/directlake/_dl_helper.py +4 -1
- sempy_labs/directlake/_generate_shared_expression.py +1 -1
- sempy_labs/directlake/_get_shared_expression.py +7 -1
- sempy_labs/directlake/_guardrails.py +3 -2
- sempy_labs/directlake/_show_unsupported_directlake_objects.py +2 -8
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +78 -0
- sempy_labs/directlake/_update_directlake_partition_entity.py +13 -32
- sempy_labs/lakehouse/_get_lakehouse_tables.py +6 -2
- sempy_labs/lakehouse/_shortcuts.py +4 -0
- sempy_labs/migration/_create_pqt_file.py +2 -2
- sempy_labs/migration/_migrate_calctables_to_lakehouse.py +3 -2
- sempy_labs/migration/_migrate_calctables_to_semantic_model.py +2 -0
- sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +2 -8
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +17 -0
- sempy_labs/migration/_migration_validation.py +2 -0
- sempy_labs/migration/_refresh_calc_tables.py +1 -0
- sempy_labs/report/__init__.py +4 -1
- sempy_labs/report/_generate_report.py +16 -14
- sempy_labs/report/_paginated.py +74 -0
- sempy_labs/report/_report_bpa.py +8 -10
- sempy_labs/report/_report_functions.py +19 -19
- sempy_labs/report/_report_rebind.py +6 -1
- sempy_labs/report/_reportwrapper.py +3 -3
- sempy_labs/tom/_model.py +173 -67
- {semantic_link_labs-0.8.2.dist-info → semantic_link_labs-0.8.4.dist-info}/LICENSE +0 -0
- {semantic_link_labs-0.8.2.dist-info → semantic_link_labs-0.8.4.dist-info}/top_level.txt +0 -0
sempy_labs/_workspaces.py
CHANGED
|
@@ -14,6 +14,8 @@ def delete_user_from_workspace(email_address: str, workspace: Optional[str] = No
|
|
|
14
14
|
"""
|
|
15
15
|
Removes a user from a workspace.
|
|
16
16
|
|
|
17
|
+
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`_.
|
|
18
|
+
|
|
17
19
|
Parameters
|
|
18
20
|
----------
|
|
19
21
|
email_address : str
|
|
@@ -45,6 +47,8 @@ def update_workspace_user(
|
|
|
45
47
|
"""
|
|
46
48
|
Updates a user's role within a workspace.
|
|
47
49
|
|
|
50
|
+
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`_.
|
|
51
|
+
|
|
48
52
|
Parameters
|
|
49
53
|
----------
|
|
50
54
|
email_address : str
|
|
@@ -95,6 +99,8 @@ def list_workspace_users(workspace: Optional[str] = None) -> pd.DataFrame:
|
|
|
95
99
|
"""
|
|
96
100
|
A list of all the users of a workspace and their roles.
|
|
97
101
|
|
|
102
|
+
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`_.
|
|
103
|
+
|
|
98
104
|
Parameters
|
|
99
105
|
----------
|
|
100
106
|
workspace : str, default=None
|
|
@@ -142,6 +148,8 @@ def add_user_to_workspace(
|
|
|
142
148
|
"""
|
|
143
149
|
Adds a user to a workspace.
|
|
144
150
|
|
|
151
|
+
This is a wrapper function for the following API: `Groups - Add Group User <https://learn.microsoft.com/rest/api/power-bi/groups/add-group-user`_.
|
|
152
|
+
|
|
145
153
|
Parameters
|
|
146
154
|
----------
|
|
147
155
|
email_address : str
|
|
@@ -196,6 +204,8 @@ def assign_workspace_to_capacity(capacity_name: str, workspace: Optional[str] =
|
|
|
196
204
|
"""
|
|
197
205
|
Assigns a workspace to a capacity.
|
|
198
206
|
|
|
207
|
+
This is a wrapper function for the following API: `Workspaces - Assign To Capacity <https://learn.microsoft.com/rest/api/fabric/core/workspaces/assign-to-capacity`_.
|
|
208
|
+
|
|
199
209
|
Parameters
|
|
200
210
|
----------
|
|
201
211
|
capacity_name : str
|
|
@@ -228,6 +238,8 @@ def unassign_workspace_from_capacity(workspace: Optional[str] = None):
|
|
|
228
238
|
"""
|
|
229
239
|
Unassigns a workspace from its assigned capacity.
|
|
230
240
|
|
|
241
|
+
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`_.
|
|
242
|
+
|
|
231
243
|
Parameters
|
|
232
244
|
----------
|
|
233
245
|
workspace : str, default=None
|
|
@@ -236,7 +248,6 @@ def unassign_workspace_from_capacity(workspace: Optional[str] = None):
|
|
|
236
248
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
237
249
|
"""
|
|
238
250
|
|
|
239
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/core/workspaces/unassign-from-capacity?tabs=HTTP
|
|
240
251
|
(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
241
252
|
|
|
242
253
|
client = fabric.FabricRestClient()
|
|
@@ -253,6 +264,8 @@ def list_workspace_role_assignments(workspace: Optional[str] = None) -> pd.DataF
|
|
|
253
264
|
"""
|
|
254
265
|
Shows the members of a given workspace.
|
|
255
266
|
|
|
267
|
+
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`_.
|
|
268
|
+
|
|
256
269
|
Parameters
|
|
257
270
|
----------
|
|
258
271
|
workspace : str, default=None
|
sempy_labs/admin/__init__.py
CHANGED
|
@@ -12,6 +12,7 @@ from sempy_labs.admin._basic_functions import (
|
|
|
12
12
|
list_access_entities,
|
|
13
13
|
list_workspace_access_details,
|
|
14
14
|
list_items,
|
|
15
|
+
list_activity_events,
|
|
15
16
|
)
|
|
16
17
|
from sempy_labs.admin._domains import (
|
|
17
18
|
list_domains,
|
|
@@ -50,4 +51,5 @@ __all__ = [
|
|
|
50
51
|
"unassign_workspaces_from_capacity",
|
|
51
52
|
"list_external_data_shares",
|
|
52
53
|
"revoke_external_data_share",
|
|
54
|
+
"list_activity_events",
|
|
53
55
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import sempy.fabric as fabric
|
|
2
|
-
from typing import Optional, List, Union
|
|
2
|
+
from typing import Optional, List, Union, Tuple
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
import sempy_labs._icons as icons
|
|
5
5
|
from sempy.fabric.exceptions import FabricHTTPException
|
|
@@ -7,22 +7,29 @@ from sempy_labs._helper_functions import (
|
|
|
7
7
|
resolve_workspace_name_and_id,
|
|
8
8
|
pagination,
|
|
9
9
|
)
|
|
10
|
-
import datetime
|
|
11
10
|
import numpy as np
|
|
12
11
|
import pandas as pd
|
|
13
12
|
import time
|
|
13
|
+
import urllib.parse
|
|
14
|
+
from datetime import datetime
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
def list_workspaces(
|
|
17
|
-
top: Optional[int] = 5000,
|
|
18
|
+
top: Optional[int] = 5000,
|
|
19
|
+
filter: Optional[str] = None,
|
|
20
|
+
skip: Optional[int] = None,
|
|
18
21
|
) -> pd.DataFrame:
|
|
19
22
|
"""
|
|
20
23
|
Lists workspaces for the organization. This function is the admin version of list_workspaces.
|
|
21
24
|
|
|
25
|
+
This is a wrapper function for the following API: `Admin - Groups GetGroupsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/groups-get-groups-as-admin>`_.
|
|
26
|
+
|
|
22
27
|
Parameters
|
|
23
28
|
----------
|
|
24
29
|
top : int, default=5000
|
|
25
30
|
Returns only the first n results. This parameter is mandatory and must be in the range of 1-5000.
|
|
31
|
+
filter : str, default=None
|
|
32
|
+
Returns a subset of a results based on `Odata filter <https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_SystemQueryOptions>`_ query parameter condition.
|
|
26
33
|
skip : int, default=None
|
|
27
34
|
Skips the first n results. Use with top to fetch results beyond the first 5000.
|
|
28
35
|
|
|
@@ -49,6 +56,8 @@ def list_workspaces(
|
|
|
49
56
|
url = f"/v1.0/myorg/admin/groups?$top={top}"
|
|
50
57
|
if skip is not None:
|
|
51
58
|
url = f"{url}&$skip={skip}"
|
|
59
|
+
if filter is not None:
|
|
60
|
+
url = f"{url}&$filter={filter}"
|
|
52
61
|
|
|
53
62
|
client = fabric.PowerBIRestClient()
|
|
54
63
|
response = client.get(url)
|
|
@@ -92,6 +101,8 @@ def assign_workspaces_to_capacity(
|
|
|
92
101
|
"""
|
|
93
102
|
Assigns a workspace to a capacity. This function is the admin version.
|
|
94
103
|
|
|
104
|
+
This is a wrapper function for the following API: `Admin - Capacities AssignWorkspacesToCapacity <https://learn.microsoft.com/rest/api/power-bi/admin/capacities-assign-workspaces-to-capacity>`_.
|
|
105
|
+
|
|
95
106
|
Parameters
|
|
96
107
|
----------
|
|
97
108
|
source_capacity : str
|
|
@@ -106,27 +117,25 @@ def assign_workspaces_to_capacity(
|
|
|
106
117
|
if isinstance(workspace, str):
|
|
107
118
|
workspace = [workspace]
|
|
108
119
|
|
|
109
|
-
dfC =
|
|
110
|
-
dfC_filt = dfC[dfC["
|
|
111
|
-
source_capacity_id = dfC_filt["Id"].iloc[0]
|
|
120
|
+
dfC = list_capacities()
|
|
121
|
+
dfC_filt = dfC[dfC["Capacity Name"] == source_capacity]
|
|
122
|
+
source_capacity_id = dfC_filt["Capacity Id"].iloc[0]
|
|
112
123
|
|
|
113
|
-
dfC_filt = dfC[dfC["
|
|
114
|
-
target_capacity_id = dfC_filt["Id"].iloc[0]
|
|
124
|
+
dfC_filt = dfC[dfC["Capacity Name"] == target_capacity]
|
|
125
|
+
target_capacity_id = dfC_filt["Capacity Id"].iloc[0]
|
|
115
126
|
|
|
116
127
|
if workspace is None:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
dfW = list_workspaces()
|
|
129
|
+
dfW = dfW[dfW["Capacity Id"].str.upper() == source_capacity_id.upper()]
|
|
130
|
+
workspaces = dfW["Id"].tolist()
|
|
120
131
|
else:
|
|
121
|
-
dfW =
|
|
122
|
-
workspaces = dfW[dfW["Name"].isin(workspace)]["Id"].
|
|
132
|
+
dfW = list_workspaces()
|
|
133
|
+
workspaces = dfW[dfW["Name"].isin(workspace)]["Id"].tolist()
|
|
123
134
|
|
|
124
135
|
workspaces = np.array(workspaces)
|
|
125
136
|
batch_size = 999
|
|
126
137
|
for i in range(0, len(workspaces), batch_size):
|
|
127
138
|
batch = workspaces[i : i + batch_size].tolist()
|
|
128
|
-
batch_length = len(batch)
|
|
129
|
-
start_time = datetime.datetime.now()
|
|
130
139
|
request_body = {
|
|
131
140
|
"capacityMigrationAssignments": [
|
|
132
141
|
{
|
|
@@ -144,10 +153,6 @@ def assign_workspaces_to_capacity(
|
|
|
144
153
|
|
|
145
154
|
if response.status_code != 200:
|
|
146
155
|
raise FabricHTTPException(response)
|
|
147
|
-
end_time = datetime.datetime.now()
|
|
148
|
-
print(
|
|
149
|
-
f"Total time for assigning {str(batch_length)} workspaces is {str((end_time - start_time).total_seconds())}"
|
|
150
|
-
)
|
|
151
156
|
print(
|
|
152
157
|
f"{icons.green_dot} The workspaces have been assigned to the '{target_capacity}' capacity."
|
|
153
158
|
)
|
|
@@ -157,8 +162,7 @@ def list_capacities() -> pd.DataFrame:
|
|
|
157
162
|
"""
|
|
158
163
|
Shows the a list of capacities and their properties. This function is the admin version.
|
|
159
164
|
|
|
160
|
-
|
|
161
|
-
----------
|
|
165
|
+
This is a wrapper function for the following API: `Admin - Get Capacities As Admin <https://learn.microsoft.com/rest/api/power-bi/admin/get-capacities-as-admin>`_.
|
|
162
166
|
|
|
163
167
|
Returns
|
|
164
168
|
-------
|
|
@@ -196,14 +200,14 @@ def list_tenant_settings() -> pd.DataFrame:
|
|
|
196
200
|
"""
|
|
197
201
|
Lists all tenant settings.
|
|
198
202
|
|
|
203
|
+
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>`_.
|
|
204
|
+
|
|
199
205
|
Returns
|
|
200
206
|
-------
|
|
201
207
|
pandas.DataFrame
|
|
202
208
|
A pandas dataframe showing the tenant settings.
|
|
203
209
|
"""
|
|
204
210
|
|
|
205
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/admin/tenants/list-tenant-settings?tabs=HTTP
|
|
206
|
-
|
|
207
211
|
client = fabric.FabricRestClient()
|
|
208
212
|
response = client.get("/v1/admin/tenantsettings")
|
|
209
213
|
|
|
@@ -269,7 +273,9 @@ def _list_capacities_meta() -> pd.DataFrame:
|
|
|
269
273
|
|
|
270
274
|
def unassign_workspaces_from_capacity(workspaces: str | List[str]):
|
|
271
275
|
"""
|
|
272
|
-
Unassigns workspace(s) from their capacity.
|
|
276
|
+
Unassigns workspace(s) from their capacity.
|
|
277
|
+
|
|
278
|
+
This is a wrapper function for the following API: `Admin - Capacities UnassignWorkspacesFromCapacity <https://learn.microsoft.com/rest/api/power-bi/admin/capacities-unassign-workspaces-from-capacity>`_.
|
|
273
279
|
|
|
274
280
|
Parameters
|
|
275
281
|
----------
|
|
@@ -277,8 +283,6 @@ def unassign_workspaces_from_capacity(workspaces: str | List[str]):
|
|
|
277
283
|
The Fabric workspace name(s).
|
|
278
284
|
"""
|
|
279
285
|
|
|
280
|
-
# https://learn.microsoft.com/en-us/rest/api/power-bi/admin/capacities-unassign-workspaces-from-capacity
|
|
281
|
-
|
|
282
286
|
if isinstance(workspaces, str):
|
|
283
287
|
workspaces = [workspaces]
|
|
284
288
|
|
|
@@ -300,14 +304,14 @@ def list_external_data_shares():
|
|
|
300
304
|
"""
|
|
301
305
|
Lists external data shares in the tenant. This function is for admins.
|
|
302
306
|
|
|
307
|
+
This is a wrapper function for the following API: `External Data Shares - List External Data Shares <https://learn.microsoft.com/rest/api/fabric/admin/external-data-shares/list-external-data-shares>`_.
|
|
308
|
+
|
|
303
309
|
Returns
|
|
304
310
|
-------
|
|
305
311
|
pandas.DataFrame
|
|
306
312
|
A pandas dataframe showing a list of external data shares in the tenant.
|
|
307
313
|
"""
|
|
308
314
|
|
|
309
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/admin/external-data-shares/list-external-data-shares?tabs=HTTP
|
|
310
|
-
|
|
311
315
|
df = pd.DataFrame(
|
|
312
316
|
columns=[
|
|
313
317
|
"External Data Share Id",
|
|
@@ -362,6 +366,8 @@ def revoke_external_data_share(
|
|
|
362
366
|
"""
|
|
363
367
|
Revokes the specified external data share. Note: This action cannot be undone.
|
|
364
368
|
|
|
369
|
+
This is a wrapper function for the following API: `External Data Shares - Revoke External Data Share <https://learn.microsoft.com/rest/api/fabric/admin/external-data-shares/revoke-external-data-share`_.
|
|
370
|
+
|
|
365
371
|
Parameters
|
|
366
372
|
----------
|
|
367
373
|
external_data_share_id : UUID
|
|
@@ -372,8 +378,6 @@ def revoke_external_data_share(
|
|
|
372
378
|
The Fabric workspace name.
|
|
373
379
|
"""
|
|
374
380
|
|
|
375
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/admin/external-data-shares/revoke-external-data-share?tabs=HTTP
|
|
376
|
-
|
|
377
381
|
(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
378
382
|
|
|
379
383
|
client = fabric.FabricRestClient()
|
|
@@ -391,23 +395,23 @@ def revoke_external_data_share(
|
|
|
391
395
|
|
|
392
396
|
def list_capacities_delegated_tenant_settings(
|
|
393
397
|
return_dataframe: bool = True,
|
|
394
|
-
) ->
|
|
398
|
+
) -> pd.DataFrame | dict:
|
|
395
399
|
"""
|
|
396
400
|
Returns list of tenant setting overrides that override at the capacities.
|
|
397
401
|
|
|
402
|
+
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`_.
|
|
403
|
+
|
|
398
404
|
Parameters
|
|
399
405
|
----------
|
|
400
406
|
return_dataframe : bool, default=True
|
|
401
|
-
If True, returns a dataframe. If False, returns a dictionary
|
|
407
|
+
If True, returns a dataframe. If False, returns a dictionary.
|
|
402
408
|
|
|
403
409
|
Returns
|
|
404
410
|
-------
|
|
405
|
-
pandas.DataFrame
|
|
411
|
+
pandas.DataFrame | dict
|
|
406
412
|
A pandas dataframe showing a list of tenant setting overrides that override at the capacities.
|
|
407
413
|
"""
|
|
408
414
|
|
|
409
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/admin/tenants/list-capacities-tenant-settings-overrides?tabs=HTTP
|
|
410
|
-
|
|
411
415
|
df = pd.DataFrame(
|
|
412
416
|
columns=[
|
|
413
417
|
"Capacity Id",
|
|
@@ -488,7 +492,8 @@ def scan_workspaces(
|
|
|
488
492
|
workspace: Optional[str | List[str]] = None,
|
|
489
493
|
) -> dict:
|
|
490
494
|
|
|
491
|
-
workspace
|
|
495
|
+
if workspace is None:
|
|
496
|
+
workspace = fabric.resolve_workspace_name()
|
|
492
497
|
|
|
493
498
|
if isinstance(workspace, str):
|
|
494
499
|
workspace = [workspace]
|
|
@@ -525,14 +530,14 @@ def list_datasets() -> pd.DataFrame:
|
|
|
525
530
|
"""
|
|
526
531
|
Shows a list of datasets for the organization.
|
|
527
532
|
|
|
533
|
+
This is a wrapper function for the following API: `Admin - Datasets GetDatasetsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/datasets-get-datasets-as-admin`_.
|
|
534
|
+
|
|
528
535
|
Returns
|
|
529
536
|
-------
|
|
530
537
|
pandas.DataFrame
|
|
531
538
|
A pandas dataframe showing a list of datasets for the organization.
|
|
532
539
|
"""
|
|
533
540
|
|
|
534
|
-
# https://learn.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-as-admin
|
|
535
|
-
|
|
536
541
|
df = pd.DataFrame(
|
|
537
542
|
columns=[
|
|
538
543
|
"Dataset Id",
|
|
@@ -615,6 +620,8 @@ def list_item_access_details(
|
|
|
615
620
|
"""
|
|
616
621
|
Returns a list of users (including groups and service principals) and lists their workspace roles.
|
|
617
622
|
|
|
623
|
+
This is a wrapper function for the following API: `Items - List Item Access Details <https://learn.microsoft.com/rest/api/fabric/admin/items/list-item-access-details`_.
|
|
624
|
+
|
|
618
625
|
Parameters
|
|
619
626
|
----------
|
|
620
627
|
item_name : str
|
|
@@ -632,13 +639,8 @@ def list_item_access_details(
|
|
|
632
639
|
A pandas dataframe showing a list of users (including groups and service principals) and lists their workspace roles.
|
|
633
640
|
"""
|
|
634
641
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
workspace = fabric.resolve_workspace_name(workspace)
|
|
638
|
-
workspace_id = fabric.resolve_workspace_id(workspace)
|
|
639
|
-
item_id = fabric.resolve_item_id(
|
|
640
|
-
item_name=item_name, type=type, workspace=workspace
|
|
641
|
-
)
|
|
642
|
+
workspace_name, workspace_id = _resolve_workspace_name_and_id(workspace)
|
|
643
|
+
item_id = _resolve_item_id(item_name=item_name, type=type, workspace=workspace_name)
|
|
642
644
|
|
|
643
645
|
df = pd.DataFrame(
|
|
644
646
|
columns=[
|
|
@@ -684,7 +686,9 @@ def list_access_entities(
|
|
|
684
686
|
user_email_address: str,
|
|
685
687
|
) -> pd.DataFrame:
|
|
686
688
|
"""
|
|
687
|
-
Shows a list of permission details for Fabric and
|
|
689
|
+
Shows a list of permission details for Fabric and Power BI items the specified user can access.
|
|
690
|
+
|
|
691
|
+
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`_.
|
|
688
692
|
|
|
689
693
|
Parameters
|
|
690
694
|
----------
|
|
@@ -694,11 +698,9 @@ def list_access_entities(
|
|
|
694
698
|
Returns
|
|
695
699
|
-------
|
|
696
700
|
pandas.DataFrame
|
|
697
|
-
A pandas dataframe showing a list of permission details for Fabric and
|
|
701
|
+
A pandas dataframe showing a list of permission details for Fabric and Power BI items the specified user can access.
|
|
698
702
|
"""
|
|
699
703
|
|
|
700
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/admin/users/list-access-entities?tabs=HTTP
|
|
701
|
-
|
|
702
704
|
df = pd.DataFrame(
|
|
703
705
|
columns=[
|
|
704
706
|
"Item Id",
|
|
@@ -738,6 +740,8 @@ def list_workspace_access_details(
|
|
|
738
740
|
"""
|
|
739
741
|
Shows a list of users (including groups and Service Principals) that have access to the specified workspace.
|
|
740
742
|
|
|
743
|
+
This is a wrapper function for the following API: `Workspaces - List Workspace Access Details <https://learn.microsoft.com/rest/api/fabric/admin/workspaces/list-workspace-access-details`_.
|
|
744
|
+
|
|
741
745
|
Parameters
|
|
742
746
|
----------
|
|
743
747
|
workspace : str, default=None
|
|
@@ -751,10 +755,7 @@ def list_workspace_access_details(
|
|
|
751
755
|
A pandas dataframe showing a list of users (including groups and Service Principals) that have access to the specified workspace.
|
|
752
756
|
"""
|
|
753
757
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
workspace_name = fabric.resolve_workspace_name(workspace)
|
|
757
|
-
workspace_id = fabric.resolve_workspace_id(workspace_name)
|
|
758
|
+
workspace_name, workspace_id = _resolve_workspace_name_and_id(workspace)
|
|
758
759
|
|
|
759
760
|
df = pd.DataFrame(
|
|
760
761
|
columns=[
|
|
@@ -785,6 +786,32 @@ def list_workspace_access_details(
|
|
|
785
786
|
return df
|
|
786
787
|
|
|
787
788
|
|
|
789
|
+
def _resolve_item_id(
|
|
790
|
+
item_name: str, type: str, workspace: Optional[str] = None
|
|
791
|
+
) -> UUID:
|
|
792
|
+
|
|
793
|
+
workspace_name, workspace_id = _resolve_workspace_name_and_id(workspace)
|
|
794
|
+
dfI = list_items(workspace=workspace_name, type=type)
|
|
795
|
+
dfI_filt = dfI[dfI["Item Name"] == item_name]
|
|
796
|
+
|
|
797
|
+
if len(dfI_filt) == 0:
|
|
798
|
+
raise ValueError(
|
|
799
|
+
f"The '{item_name}' {type} does not exist within the '{workspace_name}' workspace."
|
|
800
|
+
)
|
|
801
|
+
|
|
802
|
+
return dfI_filt["Item Id"].iloc[0]
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def _resolve_workspace_name_and_id(workspace: str) -> Tuple[str, UUID]:
|
|
806
|
+
|
|
807
|
+
filter_condition = urllib.parse.quote(workspace)
|
|
808
|
+
dfW_filt = list_workspaces(filter=f"name eq '{filter_condition}'")
|
|
809
|
+
workspace_name = dfW_filt["Name"].iloc[0]
|
|
810
|
+
workspace_id = dfW_filt["Id"].iloc[0]
|
|
811
|
+
|
|
812
|
+
return workspace_name, workspace_id
|
|
813
|
+
|
|
814
|
+
|
|
788
815
|
def list_items(
|
|
789
816
|
capacity_name: Optional[str] = None,
|
|
790
817
|
workspace: Optional[str] = None,
|
|
@@ -792,7 +819,9 @@ def list_items(
|
|
|
792
819
|
type: Optional[str] = None,
|
|
793
820
|
) -> pd.DataFrame:
|
|
794
821
|
"""
|
|
795
|
-
Shows a list of active Fabric and
|
|
822
|
+
Shows a list of active Fabric and Power BI items.
|
|
823
|
+
|
|
824
|
+
This is a wrapper function for the following API: `Items - List Items <https://learn.microsoft.com/rest/api/fabric/admin/items/list-items`_.
|
|
796
825
|
|
|
797
826
|
Parameters
|
|
798
827
|
----------
|
|
@@ -813,8 +842,6 @@ def list_items(
|
|
|
813
842
|
A pandas dataframe showing a list of active Fabric and Power BI items.
|
|
814
843
|
"""
|
|
815
844
|
|
|
816
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/admin/items/list-items?tabs=HTTP
|
|
817
|
-
|
|
818
845
|
url = "/v1/admin/items?"
|
|
819
846
|
|
|
820
847
|
df = pd.DataFrame(
|
|
@@ -835,8 +862,7 @@ def list_items(
|
|
|
835
862
|
)
|
|
836
863
|
|
|
837
864
|
if workspace is not None:
|
|
838
|
-
|
|
839
|
-
workspace_id = fabric.resolve_workspace_id(workspace)
|
|
865
|
+
workspace_name, workspace_id = _resolve_workspace_name_and_id(workspace)
|
|
840
866
|
url += f"workspaceId={workspace_id}&"
|
|
841
867
|
if capacity_name is not None:
|
|
842
868
|
dfC = list_capacities()
|
|
@@ -886,3 +912,122 @@ def list_items(
|
|
|
886
912
|
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
887
913
|
|
|
888
914
|
return df
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
def list_activity_events(
|
|
918
|
+
start_time: str,
|
|
919
|
+
end_time: str,
|
|
920
|
+
activity_filter: Optional[str] = None,
|
|
921
|
+
user_id_filter: Optional[str] = None,
|
|
922
|
+
):
|
|
923
|
+
"""
|
|
924
|
+
Shows a list of audit activity events for a tenant.
|
|
925
|
+
|
|
926
|
+
This is a wrapper function for the following API: `Admin - Get Activity Events <https://learn.microsoft.com/rest/api/power-bi/admin/get-activity-events`_.
|
|
927
|
+
|
|
928
|
+
Parameters
|
|
929
|
+
----------
|
|
930
|
+
start_time : str
|
|
931
|
+
Start date and time of the window for audit event results. Example: "2024-09-25T07:55:00".
|
|
932
|
+
end_time : str
|
|
933
|
+
End date and time of the window for audit event results. Example: "2024-09-25T08:55:00".
|
|
934
|
+
activity_filter : str, default=None
|
|
935
|
+
Filter value for activities. Example: 'viewreport'.
|
|
936
|
+
user_id_filter : str, default=None
|
|
937
|
+
Email address of the user.
|
|
938
|
+
|
|
939
|
+
Returns
|
|
940
|
+
-------
|
|
941
|
+
pandas.DataFrame
|
|
942
|
+
A pandas dataframe showing a list of audit activity events for a tenant.
|
|
943
|
+
"""
|
|
944
|
+
|
|
945
|
+
start_dt = datetime.strptime(start_time, "%Y-%m-%dT%H:%M:%S")
|
|
946
|
+
end_dt = datetime.strptime(end_time, "%Y-%m-%dT%H:%M:%S")
|
|
947
|
+
|
|
948
|
+
if not start_dt.date() == end_dt.date():
|
|
949
|
+
raise ValueError(
|
|
950
|
+
f"{icons.red_dot} Start and End Times must be within the same UTC day. Please refer to the documentation here: https://learn.microsoft.com/rest/api/power-bi/admin/get-activity-events#get-audit-activity-events-within-a-time-window-and-for-a-specific-activity-type-and-user-id-example"
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
df = pd.DataFrame(
|
|
954
|
+
columns=[
|
|
955
|
+
"Id",
|
|
956
|
+
"Record Type",
|
|
957
|
+
"Creation Time",
|
|
958
|
+
"Operation",
|
|
959
|
+
"Organization Id",
|
|
960
|
+
"User Type",
|
|
961
|
+
"User Key",
|
|
962
|
+
"Workload",
|
|
963
|
+
"Result Status",
|
|
964
|
+
"User Id",
|
|
965
|
+
"Client IP",
|
|
966
|
+
"User Agent",
|
|
967
|
+
"Activity",
|
|
968
|
+
"Workspace Name",
|
|
969
|
+
"Workspace Id",
|
|
970
|
+
"Object Id",
|
|
971
|
+
"Request Id",
|
|
972
|
+
"Object Type",
|
|
973
|
+
"Object Display Name",
|
|
974
|
+
"Experience",
|
|
975
|
+
"Refresh Enforcement Policy",
|
|
976
|
+
]
|
|
977
|
+
)
|
|
978
|
+
|
|
979
|
+
tic = "%27"
|
|
980
|
+
space = "%20"
|
|
981
|
+
client = fabric.PowerBIRestClient()
|
|
982
|
+
base_url = "/v1.0/myorg/admin/activityevents"
|
|
983
|
+
conditions = []
|
|
984
|
+
|
|
985
|
+
if activity_filter is not None:
|
|
986
|
+
conditions.append(f"Activity{space}eq{space}{tic}{activity_filter}{tic}")
|
|
987
|
+
if user_id_filter is not None:
|
|
988
|
+
conditions.append(f"UserId{space}eq{space}{tic}{user_id_filter}{tic}")
|
|
989
|
+
|
|
990
|
+
filter_value = (
|
|
991
|
+
f"&$filter={f'{space}and{space}'.join(conditions)}" if conditions else ""
|
|
992
|
+
)
|
|
993
|
+
|
|
994
|
+
full_url = f"{base_url}?startDateTime={tic}{start_time}{tic}&endDateTime={tic}{end_time}{tic}{filter_value}"
|
|
995
|
+
response = client.get(full_url)
|
|
996
|
+
if response.status_code != 200:
|
|
997
|
+
raise FabricHTTPException(response)
|
|
998
|
+
|
|
999
|
+
responses = pagination(client, response)
|
|
1000
|
+
|
|
1001
|
+
for r in responses:
|
|
1002
|
+
for i in r.get("activityEventEntities", []):
|
|
1003
|
+
new_data = {
|
|
1004
|
+
"Id": i.get("id"),
|
|
1005
|
+
"Record Type": i.get("RecordType"),
|
|
1006
|
+
"Creation Time": i.get("CreationTime"),
|
|
1007
|
+
"Operation": i.get("Operation"),
|
|
1008
|
+
"Organization Id": i.get("OrganizationId"),
|
|
1009
|
+
"User Type": i.get("UserType"),
|
|
1010
|
+
"User Key": i.get("UserKey"),
|
|
1011
|
+
"Workload": i.get("Workload"),
|
|
1012
|
+
"Result Status": i.get("ResultStatus"),
|
|
1013
|
+
"User Id": i.get("UserId"),
|
|
1014
|
+
"Client IP": i.get("ClientIP"),
|
|
1015
|
+
"User Agent": i.get("UserAgent"),
|
|
1016
|
+
"Activity": i.get("Activity"),
|
|
1017
|
+
"Workspace Name": i.get("WorkSpaceName"),
|
|
1018
|
+
"Workspace Id": i.get("WorkspaceId"),
|
|
1019
|
+
"Object Id": i.get("ObjectId"),
|
|
1020
|
+
"Request Id": i.get("RequestId"),
|
|
1021
|
+
"Object Type": i.get("ObjectType"),
|
|
1022
|
+
"Object Display Name": i.get("ObjectDisplayName"),
|
|
1023
|
+
"Experience": i.get("Experience"),
|
|
1024
|
+
"Refresh Enforcement Policy": i.get("RefreshEnforcementPolicy"),
|
|
1025
|
+
}
|
|
1026
|
+
df = pd.concat(
|
|
1027
|
+
[df, pd.DataFrame(new_data, index=[0])],
|
|
1028
|
+
ignore_index=True,
|
|
1029
|
+
)
|
|
1030
|
+
|
|
1031
|
+
df["Creation Time"] = pd.to_datetime(df["Creation Time"])
|
|
1032
|
+
|
|
1033
|
+
return df
|