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,239 @@
1
+ import pandas as pd
2
+ from typing import Optional
3
+ from sempy_labs._helper_functions import (
4
+ _base_api,
5
+ _create_dataframe,
6
+ _update_dataframe_datatypes,
7
+ _is_valid_uuid,
8
+ )
9
+ from uuid import UUID
10
+ import sempy_labs._icons as icons
11
+
12
+
13
+ def list_reports(
14
+ top: Optional[int] = None,
15
+ skip: Optional[int] = None,
16
+ filter: Optional[str] = None,
17
+ ) -> pd.DataFrame:
18
+ """
19
+ Shows a list of reports for the organization.
20
+
21
+ This is a wrapper function for the following API: `Admin - Reports GetReportsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/reports-get-reports-as-admin>`_.
22
+
23
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
24
+
25
+ Parameters
26
+ ----------
27
+ top : int, default=None
28
+ Returns only the first n results.
29
+ skip : int, default=None
30
+ Skips the first n results.
31
+ filter : str, default=None
32
+ Returns a subset of a results based on Odata filter query parameter condition.
33
+
34
+ Returns
35
+ -------
36
+ pandas.DataFrame
37
+ A pandas dataframe showing a list of reports for the organization.
38
+ """
39
+
40
+ columns = {
41
+ "Report Id": "string",
42
+ "Report Name": "string",
43
+ "Type": "string",
44
+ "Web URL": "string",
45
+ "Embed URL": "string",
46
+ "Dataset Id": "string",
47
+ "Created Date": "datetime_coerce",
48
+ "Modified Date": "datetime_coerce",
49
+ "Created By": "string",
50
+ "Modified By": "string",
51
+ "Sensitivity Label Id": "string",
52
+ "Users": "string",
53
+ "Subscriptions": "string",
54
+ "Workspace Id": "string",
55
+ "Report Flags": "int",
56
+ }
57
+
58
+ df = _create_dataframe(columns=columns)
59
+
60
+ url = "/v1.0/myorg/admin/reports?"
61
+ if top is not None:
62
+ url += f"$top={top}&"
63
+ if skip is not None:
64
+ url += f"$skip={skip}&"
65
+ if filter is not None:
66
+ url += f"$filter={filter}&"
67
+
68
+ url.rstrip("$").rstrip("?")
69
+ response = _base_api(request=url, client="fabric_sp")
70
+ rows = []
71
+
72
+ for v in response.json().get("value", []):
73
+ rows.append(
74
+ {
75
+ "Report Id": v.get("id"),
76
+ "Report Name": v.get("name"),
77
+ "Type": v.get("reportType"),
78
+ "Web URL": v.get("webUrl"),
79
+ "Embed URL": v.get("embedUrl"),
80
+ "Dataset Id": v.get("datasetId"),
81
+ "Created Date": v.get("createdDateTime"),
82
+ "Modified Date": v.get("modifiedDateTime"),
83
+ "Created By": v.get("createdBy"),
84
+ "Modified By": v.get("modifiedBy"),
85
+ "Sensitivity Label Id": v.get("sensitivityLabel", {}).get("labelId"),
86
+ "Users": v.get("users"),
87
+ "Subscriptions": v.get("subscriptions"),
88
+ "Workspace Id": v.get("workspaceId"),
89
+ "Report Flags": v.get("reportFlags"),
90
+ }
91
+ )
92
+
93
+ if rows:
94
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
95
+
96
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
97
+
98
+ return df
99
+
100
+
101
+ def _resolve_report_id(report: str | UUID) -> str:
102
+ if _is_valid_uuid(report):
103
+ return report
104
+ else:
105
+ df = list_reports()
106
+ df_filt = df[df["Report Name"] == report]
107
+ if df_filt.empty:
108
+ raise ValueError(f"{icons.red_dot} The '{report}' report does not exist.")
109
+ return df_filt["Report Id"].iloc[0]
110
+
111
+
112
+ def list_report_users(report: str | UUID) -> pd.DataFrame:
113
+ """
114
+ Shows a list of users that have access to the specified report.
115
+
116
+ This is a wrapper function for the following API: `Admin - Reports GetDatasetUsersAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/datasets-get-report-users-as-admin>`_.
117
+
118
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
119
+
120
+ Parameters
121
+ ----------
122
+ report : str | uuid.UUID
123
+ The name or ID of the report.
124
+
125
+ Returns
126
+ -------
127
+ pandas.DataFrame
128
+ A pandas dataframe showing a list of users that have access to the specified report.
129
+ """
130
+
131
+ report_id = _resolve_report_id(report)
132
+
133
+ columns = {
134
+ "User Name": "string",
135
+ "Email Address": "string",
136
+ "Report User Access Right": "string",
137
+ "Identifier": "string",
138
+ "Graph Id": "string",
139
+ "Principal Type": "string",
140
+ }
141
+
142
+ df = _create_dataframe(columns=columns)
143
+
144
+ url = f"/v1.0/myorg/admin/reports/{report_id}/users"
145
+ response = _base_api(request=url, client="fabric_sp")
146
+
147
+ rows = []
148
+ for v in response.json().get("value", []):
149
+ rows.append(
150
+ {
151
+ "User Name": v.get("displayName"),
152
+ "Email Address": v.get("emailAddress"),
153
+ "Report User Access Right": v.get("reportUserAccessRight"),
154
+ "Identifier": v.get("identifier"),
155
+ "Graph Id": v.get("graphId"),
156
+ "Principal Type": v.get("principalType"),
157
+ }
158
+ )
159
+
160
+ if rows:
161
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
162
+
163
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
164
+
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
@@ -2,7 +2,6 @@ import sempy.fabric as fabric
2
2
  from typing import Optional, List
3
3
  from uuid import UUID
4
4
  from sempy.fabric.exceptions import FabricHTTPException
5
- import numpy as np
6
5
  import time
7
6
  import sempy_labs._icons as icons
8
7
  from sempy_labs.admin._basic_functions import list_workspaces
@@ -0,0 +1,76 @@
1
+ import pandas as pd
2
+ from sempy_labs._helper_functions import (
3
+ _base_api,
4
+ _create_dataframe,
5
+ )
6
+
7
+
8
+ def list_widely_shared_artifacts(
9
+ api_name: str = "LinksSharedToWholeOrganization",
10
+ ) -> pd.DataFrame:
11
+ """
12
+ Returns a list of Power BI reports that are shared with the whole organization through links or a list of Power BI items (such as reports or dashboards) that are published to the web.
13
+
14
+ This is a wrapper function for the following APIs:
15
+ `Admin - WidelySharedArtifacts LinksSharedToWholeOrganization <https://learn.microsoft.com/rest/api/power-bi/admin/widely-shared-artifacts-links-shared-to-whole-organization>`_.
16
+ `Admin - WidelySharedArtifacts PublishedToWeb <https://learn.microsoft.com/rest/api/power-bi/admin/widely-shared-artifacts-published-to-web>`_.
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
+ api_name : str, default = "LinksSharedToWholeOrganization"
23
+ The name of the API to call. Either "LinksSharedToWholeOrganization" or "PublishedToWeb".
24
+
25
+ Returns
26
+ -------
27
+ pandas.DataFrame
28
+ A pandas dataframe showing a list of Power BI reports that are shared with the whole organization through links or a list of Power BI items (such as reports or dashboards) that are published to the web.
29
+ """
30
+
31
+ columns = {
32
+ "Artifact Id": "string",
33
+ "Artifact Name": "string",
34
+ "Artifact Type": "string",
35
+ "Access Right": "string",
36
+ "Share Type": "string",
37
+ "Sharer Name": "string",
38
+ "Sharer Email Address": "string",
39
+ "Sharer Identifier": "string",
40
+ "Sharer Graph Id": "string",
41
+ "Sharer Principal Type": "string",
42
+ }
43
+
44
+ df = _create_dataframe(columns=columns)
45
+
46
+ api = (
47
+ "linksSharedToWholeOrganization"
48
+ if api_name == "LinksSharedToWholeOrganization"
49
+ else "publishedToWeb"
50
+ )
51
+
52
+ responses = _base_api(
53
+ request=f"/v1.0/myorg/admin/widelySharedArtifacts/{api}",
54
+ client="fabric_sp",
55
+ uses_pagination=True,
56
+ )
57
+
58
+ for r in responses:
59
+ for v in r.get("ArtifactAccessEntities", []):
60
+ sharer = v.get("sharer", {})
61
+ new_data = {
62
+ "Artifact Id": v.get("artifactId"),
63
+ "Artifact Name": v.get("displayName"),
64
+ "Artifact Type": v.get("artifactType"),
65
+ "Access Right": v.get("accessRight"),
66
+ "Share Type": v.get("shareType"),
67
+ "Sharer Name": sharer.get("displayName"),
68
+ "Sharer Email Address": sharer.get("emailAddress"),
69
+ "Sharer Identifier": sharer.get("identifier"),
70
+ "Sharer Graph Id": sharer.get("graphId"),
71
+ "Sharer Principal Type": sharer.get("principalType"),
72
+ }
73
+
74
+ df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
75
+
76
+ return df