semantic-link-labs 0.9.4__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.
- {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.5.dist-info}/METADATA +18 -2
- {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.5.dist-info}/RECORD +49 -43
- sempy_labs/__init__.py +18 -3
- sempy_labs/_capacities.py +22 -127
- sempy_labs/_capacity_migration.py +8 -7
- sempy_labs/_dashboards.py +60 -0
- sempy_labs/_data_pipelines.py +5 -31
- sempy_labs/_environments.py +20 -48
- sempy_labs/_eventhouses.py +22 -52
- sempy_labs/_eventstreams.py +16 -34
- sempy_labs/_gateways.py +4 -4
- sempy_labs/_generate_semantic_model.py +0 -1
- sempy_labs/_git.py +90 -1
- sempy_labs/_graphQL.py +3 -20
- sempy_labs/_helper_functions.py +171 -43
- sempy_labs/_kql_databases.py +19 -34
- sempy_labs/_kql_querysets.py +15 -32
- sempy_labs/_list_functions.py +12 -155
- sempy_labs/_mirrored_databases.py +14 -48
- sempy_labs/_ml_experiments.py +5 -30
- sempy_labs/_ml_models.py +4 -28
- sempy_labs/_model_bpa.py +2 -0
- sempy_labs/_mounted_data_factories.py +119 -0
- sempy_labs/_notebooks.py +16 -26
- sempy_labs/_sql.py +7 -6
- sempy_labs/_utils.py +42 -0
- sempy_labs/_vertipaq.py +17 -2
- sempy_labs/_warehouses.py +5 -17
- sempy_labs/_workloads.py +23 -9
- sempy_labs/_workspaces.py +13 -5
- sempy_labs/admin/__init__.py +21 -1
- sempy_labs/admin/_apps.py +1 -1
- sempy_labs/admin/_artifacts.py +62 -0
- sempy_labs/admin/_basic_functions.py +0 -52
- sempy_labs/admin/_capacities.py +61 -0
- sempy_labs/admin/_reports.py +74 -0
- sempy_labs/admin/_shared.py +4 -2
- sempy_labs/admin/_users.py +133 -0
- sempy_labs/admin/_workspaces.py +148 -0
- sempy_labs/directlake/_update_directlake_partition_entity.py +9 -1
- sempy_labs/lakehouse/__init__.py +2 -0
- sempy_labs/lakehouse/_lakehouse.py +6 -7
- sempy_labs/lakehouse/_shortcuts.py +192 -53
- sempy_labs/report/_generate_report.py +9 -17
- sempy_labs/report/_report_bpa.py +12 -19
- sempy_labs/tom/_model.py +34 -16
- {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.5.dist-info}/LICENSE +0 -0
- {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.5.dist-info}/WHEEL +0 -0
- {semantic_link_labs-0.9.4.dist-info → semantic_link_labs-0.9.5.dist-info}/top_level.txt +0 -0
sempy_labs/_vertipaq.py
CHANGED
|
@@ -33,9 +33,11 @@ def vertipaq_analyzer(
|
|
|
33
33
|
export: Optional[str] = None,
|
|
34
34
|
read_stats_from_data: bool = False,
|
|
35
35
|
**kwargs,
|
|
36
|
-
):
|
|
36
|
+
) -> dict[str, pd.DataFrame]:
|
|
37
37
|
"""
|
|
38
|
-
Displays an HTML visualization of the Vertipaq Analyzer statistics from a semantic model.
|
|
38
|
+
Displays an HTML visualization of the `Vertipaq Analyzer <https://www.sqlbi.com/tools/vertipaq-analyzer/>`_ statistics from a semantic model.
|
|
39
|
+
|
|
40
|
+
`Vertipaq Analyzer <https://www.sqlbi.com/tools/vertipaq-analyzer/>`_ is an open-sourced tool built by SQLBI. It provides a detailed analysis of the VertiPaq engine, which is the in-memory engine used by Power BI and Analysis Services Tabular models.
|
|
39
41
|
|
|
40
42
|
Parameters
|
|
41
43
|
----------
|
|
@@ -51,6 +53,11 @@ def vertipaq_analyzer(
|
|
|
51
53
|
Default value: None.
|
|
52
54
|
read_stats_from_data : bool, default=False
|
|
53
55
|
Setting this parameter to true has the function get Column Cardinality and Missing Rows using DAX (Direct Lake semantic models achieve this using a Spark query to the lakehouse).
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
dict[str, pandas.DataFrame]
|
|
60
|
+
A dictionary of pandas dataframes showing the vertipaq analyzer statistics.
|
|
54
61
|
"""
|
|
55
62
|
|
|
56
63
|
from sempy_labs.tom import connect_semantic_model
|
|
@@ -502,6 +509,14 @@ def vertipaq_analyzer(
|
|
|
502
509
|
|
|
503
510
|
if export is None:
|
|
504
511
|
visualize_vertipaq(dfs)
|
|
512
|
+
return {
|
|
513
|
+
"Model Summary": export_Model,
|
|
514
|
+
"Tables": export_Table,
|
|
515
|
+
"Partitions": export_Part,
|
|
516
|
+
"Columns": export_Col,
|
|
517
|
+
"Relationships": export_Rel,
|
|
518
|
+
"Hierarchies": export_Hier,
|
|
519
|
+
}
|
|
505
520
|
|
|
506
521
|
# Export vertipaq to delta tables in lakehouse
|
|
507
522
|
if export in ["table", "zip"]:
|
sempy_labs/_warehouses.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import sempy.fabric as fabric
|
|
2
1
|
from sempy_labs._helper_functions import (
|
|
3
2
|
resolve_workspace_name_and_id,
|
|
4
3
|
_base_api,
|
|
5
4
|
_create_dataframe,
|
|
6
5
|
_update_dataframe_datatypes,
|
|
6
|
+
delete_item,
|
|
7
7
|
)
|
|
8
8
|
import pandas as pd
|
|
9
9
|
from typing import Optional
|
|
@@ -115,7 +115,7 @@ def list_warehouses(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
|
|
|
115
115
|
return df
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
def delete_warehouse(name: str, workspace: Optional[str | UUID] = None):
|
|
118
|
+
def delete_warehouse(name: str | UUID, workspace: Optional[str | UUID] = None):
|
|
119
119
|
"""
|
|
120
120
|
Deletes a Fabric warehouse.
|
|
121
121
|
|
|
@@ -123,27 +123,15 @@ def delete_warehouse(name: str, workspace: Optional[str | UUID] = None):
|
|
|
123
123
|
|
|
124
124
|
Parameters
|
|
125
125
|
----------
|
|
126
|
-
name: str
|
|
127
|
-
Name of the warehouse.
|
|
126
|
+
name: str | uuid.UUID
|
|
127
|
+
Name or ID of the warehouse.
|
|
128
128
|
workspace : str | uuid.UUID, default=None
|
|
129
129
|
The Fabric workspace name or ID.
|
|
130
130
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
131
131
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
132
132
|
"""
|
|
133
133
|
|
|
134
|
-
(
|
|
135
|
-
|
|
136
|
-
item_id = fabric.resolve_item_id(
|
|
137
|
-
item_name=name, type="Warehouse", workspace=workspace_id
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
_base_api(
|
|
141
|
-
request=f"/v1/workspaces/{workspace_id}/warehouses/{item_id}", method="delete"
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
print(
|
|
145
|
-
f"{icons.green_dot} The '{name}' warehouse within the '{workspace_name}' workspace has been deleted."
|
|
146
|
-
)
|
|
134
|
+
delete_item(item=name, type="Warehouse", workspace=workspace)
|
|
147
135
|
|
|
148
136
|
|
|
149
137
|
def get_warehouse_tables(
|
sempy_labs/_workloads.py
CHANGED
|
@@ -6,9 +6,10 @@ from sempy_labs._helper_functions import (
|
|
|
6
6
|
_base_api,
|
|
7
7
|
_create_dataframe,
|
|
8
8
|
)
|
|
9
|
+
from uuid import UUID
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
def list_workloads(
|
|
12
|
+
def list_workloads(capacity: str | UUID, **kwargs) -> pd.DataFrame:
|
|
12
13
|
"""
|
|
13
14
|
Returns the current state of the specified capacity workloads.
|
|
14
15
|
If a workload is enabled, the percentage of maximum memory that the workload can consume is also returned.
|
|
@@ -17,8 +18,8 @@ def list_workloads(capacity_name: str) -> pd.DataFrame:
|
|
|
17
18
|
|
|
18
19
|
Parameters
|
|
19
20
|
----------
|
|
20
|
-
|
|
21
|
-
The capacity name.
|
|
21
|
+
capacity : str | uuid.UUID
|
|
22
|
+
The capacity name or ID.
|
|
22
23
|
|
|
23
24
|
Returns
|
|
24
25
|
-------
|
|
@@ -28,6 +29,12 @@ def list_workloads(capacity_name: str) -> pd.DataFrame:
|
|
|
28
29
|
|
|
29
30
|
from sempy_labs._helper_functions import resolve_capacity_id
|
|
30
31
|
|
|
32
|
+
if "capacity_name" in kwargs:
|
|
33
|
+
capacity = kwargs["capacity_name"]
|
|
34
|
+
print(
|
|
35
|
+
f"{icons.warning} The 'capacity_name' parameter is deprecated. Please use 'capacity' instead."
|
|
36
|
+
)
|
|
37
|
+
|
|
31
38
|
columns = {
|
|
32
39
|
"Workload Name": "string",
|
|
33
40
|
"State": "string",
|
|
@@ -35,7 +42,7 @@ def list_workloads(capacity_name: str) -> pd.DataFrame:
|
|
|
35
42
|
}
|
|
36
43
|
df = _create_dataframe(columns=columns)
|
|
37
44
|
|
|
38
|
-
capacity_id = resolve_capacity_id(
|
|
45
|
+
capacity_id = resolve_capacity_id(capacity=capacity)
|
|
39
46
|
|
|
40
47
|
response = _base_api(request=f"/v1.0/myorg/capacities/{capacity_id}/Workloads")
|
|
41
48
|
|
|
@@ -53,10 +60,11 @@ def list_workloads(capacity_name: str) -> pd.DataFrame:
|
|
|
53
60
|
|
|
54
61
|
|
|
55
62
|
def patch_workload(
|
|
56
|
-
|
|
63
|
+
capacity: str | UUID,
|
|
57
64
|
workload_name: str,
|
|
58
65
|
state: Optional[str] = None,
|
|
59
66
|
max_memory_percentage: Optional[int] = None,
|
|
67
|
+
**kwargs,
|
|
60
68
|
):
|
|
61
69
|
"""
|
|
62
70
|
Changes the state of a specific workload to Enabled or Disabled.
|
|
@@ -66,8 +74,8 @@ def patch_workload(
|
|
|
66
74
|
|
|
67
75
|
Parameters
|
|
68
76
|
----------
|
|
69
|
-
|
|
70
|
-
The capacity name.
|
|
77
|
+
capacity : str | uuid.UUID
|
|
78
|
+
The capacity name or ID.
|
|
71
79
|
workload_name : str
|
|
72
80
|
The workload name.
|
|
73
81
|
state : str, default=None
|
|
@@ -78,7 +86,13 @@ def patch_workload(
|
|
|
78
86
|
|
|
79
87
|
from sempy_labs._helper_functions import resolve_capacity_id
|
|
80
88
|
|
|
81
|
-
|
|
89
|
+
if "capacity_name" in kwargs:
|
|
90
|
+
capacity = kwargs["capacity_name"]
|
|
91
|
+
print(
|
|
92
|
+
f"{icons.warning} The 'capacity_name' parameter is deprecated. Please use 'capacity' instead."
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
capacity_id = resolve_capacity_id(capacity=capacity)
|
|
82
96
|
|
|
83
97
|
states = ["Disabled", "Enabled", "Unsupported"]
|
|
84
98
|
state = state.capitalize()
|
|
@@ -119,5 +133,5 @@ def patch_workload(
|
|
|
119
133
|
_base_api(request=url, method="patch", payload=payload)
|
|
120
134
|
|
|
121
135
|
print(
|
|
122
|
-
f"The '{workload_name}' workload within the '{
|
|
136
|
+
f"The '{workload_name}' workload within the '{capacity}' capacity has been updated accordingly."
|
|
123
137
|
)
|
sempy_labs/_workspaces.py
CHANGED
|
@@ -204,7 +204,9 @@ def add_user_to_workspace(
|
|
|
204
204
|
|
|
205
205
|
|
|
206
206
|
def assign_workspace_to_capacity(
|
|
207
|
-
|
|
207
|
+
capacity: str | UUID,
|
|
208
|
+
workspace: Optional[str | UUID] = None,
|
|
209
|
+
**kwargs,
|
|
208
210
|
):
|
|
209
211
|
"""
|
|
210
212
|
Assigns a workspace to a capacity.
|
|
@@ -213,16 +215,22 @@ def assign_workspace_to_capacity(
|
|
|
213
215
|
|
|
214
216
|
Parameters
|
|
215
217
|
----------
|
|
216
|
-
|
|
217
|
-
The name of the capacity.
|
|
218
|
+
capacity : str | uuid.UUID
|
|
219
|
+
The name or ID of the capacity.
|
|
218
220
|
workspace : str | uuid.UUID, default=None
|
|
219
221
|
The name or ID of the Fabric workspace.
|
|
220
222
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
221
223
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
222
224
|
"""
|
|
223
225
|
|
|
226
|
+
if "capacity_name" in kwargs:
|
|
227
|
+
capacity = kwargs["capacity_name"]
|
|
228
|
+
print(
|
|
229
|
+
f"{icons.warning} The 'capacity_name' parameter is deprecated. Please use 'capacity' instead."
|
|
230
|
+
)
|
|
231
|
+
|
|
224
232
|
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
225
|
-
capacity_id = resolve_capacity_id(
|
|
233
|
+
capacity_id = resolve_capacity_id(capacity=capacity)
|
|
226
234
|
|
|
227
235
|
payload = {"capacityId": capacity_id}
|
|
228
236
|
|
|
@@ -233,7 +241,7 @@ def assign_workspace_to_capacity(
|
|
|
233
241
|
status_codes=[200, 202],
|
|
234
242
|
)
|
|
235
243
|
print(
|
|
236
|
-
f"{icons.green_dot} The '{workspace_name}' workspace has been assigned to the '{
|
|
244
|
+
f"{icons.green_dot} The '{workspace_name}' workspace has been assigned to the '{capacity}' capacity."
|
|
237
245
|
)
|
|
238
246
|
|
|
239
247
|
|
sempy_labs/admin/__init__.py
CHANGED
|
@@ -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
|
@@ -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:
|
sempy_labs/admin/_capacities.py
CHANGED
|
@@ -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
|
sempy_labs/admin/_reports.py
CHANGED
|
@@ -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
|
sempy_labs/admin/_shared.py
CHANGED
|
@@ -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}",
|
|
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("
|
|
59
|
+
for v in r.get("ArtifactAccessEntities", []):
|
|
58
60
|
sharer = v.get("sharer", {})
|
|
59
61
|
new_data = {
|
|
60
62
|
"Artifact Id": v.get("artifactId"),
|