semantic-link-labs 0.8.6__py3-none-any.whl → 0.8.7__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.6.dist-info → semantic_link_labs-0.8.7.dist-info}/METADATA +14 -6
- {semantic_link_labs-0.8.6.dist-info → semantic_link_labs-0.8.7.dist-info}/RECORD +34 -28
- {semantic_link_labs-0.8.6.dist-info → semantic_link_labs-0.8.7.dist-info}/WHEEL +1 -1
- sempy_labs/__init__.py +37 -6
- sempy_labs/_authentication.py +108 -0
- sempy_labs/_connections.py +355 -176
- sempy_labs/_dataflows.py +0 -1
- sempy_labs/_gateways.py +439 -0
- sempy_labs/_generate_semantic_model.py +51 -30
- sempy_labs/_git.py +13 -5
- sempy_labs/_helper_functions.py +14 -3
- sempy_labs/_list_functions.py +1 -1
- sempy_labs/_model_auto_build.py +4 -2
- sempy_labs/_model_bpa.py +2 -15
- sempy_labs/_model_bpa_bulk.py +4 -2
- sempy_labs/_refresh_semantic_model.py +6 -0
- sempy_labs/admin/__init__.py +19 -9
- sempy_labs/admin/_basic_functions.py +475 -548
- sempy_labs/admin/_external_data_share.py +97 -0
- sempy_labs/admin/_git.py +69 -0
- sempy_labs/admin/_items.py +264 -0
- sempy_labs/admin/_scanner.py +104 -0
- sempy_labs/directlake/_dl_helper.py +6 -2
- sempy_labs/directlake/_get_shared_expression.py +5 -35
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +3 -2
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +4 -2
- sempy_labs/report/_generate_report.py +10 -4
- sempy_labs/report/_report_bpa.py +1 -0
- sempy_labs/report/_report_helper.py +58 -0
- sempy_labs/report/_report_list_functions.py +2 -0
- sempy_labs/report/_reportwrapper.py +358 -175
- sempy_labs/tom/_model.py +1 -0
- {semantic_link_labs-0.8.6.dist-info → semantic_link_labs-0.8.7.dist-info}/LICENSE +0 -0
- {semantic_link_labs-0.8.6.dist-info → semantic_link_labs-0.8.7.dist-info}/top_level.txt +0 -0
sempy_labs/_gateways.py
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import sempy.fabric as fabric
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from sempy.fabric.exceptions import FabricHTTPException
|
|
5
|
+
from sempy_labs._helper_functions import (
|
|
6
|
+
pagination,
|
|
7
|
+
_is_valid_uuid,
|
|
8
|
+
resolve_capacity_id,
|
|
9
|
+
)
|
|
10
|
+
from uuid import UUID
|
|
11
|
+
import sempy_labs._icons as icons
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def list_gateways() -> pd.DataFrame:
|
|
15
|
+
"""
|
|
16
|
+
Returns a list of all gateways the user has permission for, including on-premises, on-premises (personal mode), and virtual network gateways.
|
|
17
|
+
|
|
18
|
+
This is a wrapper function for the following API: `Gateways - List Gateways <https://learn.microsoft.com/rest/api/fabric/core/gateways/list-gateways>`_.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
pandas.DataFrame
|
|
23
|
+
A pandas dataframe showing a list of all gateways the user has permission for, including on-premises, on-premises (personal mode), and virtual network gateways.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
client = fabric.FabricRestClient()
|
|
27
|
+
response = client.get("/v1/gateways")
|
|
28
|
+
|
|
29
|
+
if response.status_code != 200:
|
|
30
|
+
raise FabricHTTPException(response)
|
|
31
|
+
|
|
32
|
+
responses = pagination(client, response)
|
|
33
|
+
|
|
34
|
+
df = pd.DataFrame(
|
|
35
|
+
columns=[
|
|
36
|
+
"Gateway Name",
|
|
37
|
+
"Gateway Id",
|
|
38
|
+
"Type",
|
|
39
|
+
"Public Key Exponent",
|
|
40
|
+
"Public Key Modulus",
|
|
41
|
+
"Version",
|
|
42
|
+
"Number Of Member Gateways",
|
|
43
|
+
"Load Balancing Setting",
|
|
44
|
+
"Allow Cloud Connection Refresh",
|
|
45
|
+
"Allow Custom Connectors",
|
|
46
|
+
]
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
for r in responses:
|
|
50
|
+
for v in r.get("value", []):
|
|
51
|
+
new_data = {
|
|
52
|
+
"Gateway Name": v.get("displayName"),
|
|
53
|
+
"Gateway Id": v.get("id"),
|
|
54
|
+
"Type": v.get("type"),
|
|
55
|
+
"Public Key Exponent": v.get("publicKey", {}).get("exponent"),
|
|
56
|
+
"Public Key Modulus": v.get("publicKey", {}).get("modulus"),
|
|
57
|
+
"Version": v.get("version"),
|
|
58
|
+
"Number Of Member Gateways": v.get("numberOfMemberGateways", 0),
|
|
59
|
+
"Load Balancing Setting": v.get("loadBalancingSetting"),
|
|
60
|
+
"Allow Cloud Connection Refresh": v.get("allowCloudConnectionRefresh"),
|
|
61
|
+
"Allow Custom Connectors": v.get("allowCustomConnectors"),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
65
|
+
|
|
66
|
+
int_cols = ["Number Of Member Gateways"]
|
|
67
|
+
bool_cols = ["Allow Cloud Connection Refresh", "Allow Custom Connectors"]
|
|
68
|
+
df[bool_cols] = df[bool_cols].astype(bool)
|
|
69
|
+
df[int_cols] = df[int_cols].astype(int)
|
|
70
|
+
|
|
71
|
+
return df
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _resolve_gateway_id(gateway: str | UUID) -> UUID:
|
|
75
|
+
|
|
76
|
+
dfG = list_gateways()
|
|
77
|
+
if _is_valid_uuid(gateway):
|
|
78
|
+
dfG_filt = dfG[dfG["Gateway Id"] == gateway]
|
|
79
|
+
else:
|
|
80
|
+
dfG_filt = dfG[dfG["Gateway Name"] == gateway]
|
|
81
|
+
|
|
82
|
+
if len(dfG_filt) == 0:
|
|
83
|
+
raise ValueError(f"{icons.red_dot} The '{gateway}' does not exist.")
|
|
84
|
+
|
|
85
|
+
return dfG_filt["Gateway Id"].iloc[0]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def delete_gateway(gateway: str | UUID):
|
|
89
|
+
"""
|
|
90
|
+
Deletes a gateway.
|
|
91
|
+
|
|
92
|
+
This is a wrapper function for the following API: `Gateways - Delete Gateway <https://learn.microsoft.com/rest/api/fabric/core/gateways/delete-gateway>`_.
|
|
93
|
+
|
|
94
|
+
Parameters
|
|
95
|
+
----------
|
|
96
|
+
gateway : str | UUID
|
|
97
|
+
The gateway name or ID.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
101
|
+
client = fabric.FabricRestClient()
|
|
102
|
+
response = client.delete(f"/v1/gateways/{gateway_id}")
|
|
103
|
+
|
|
104
|
+
if response.status_code != 200:
|
|
105
|
+
raise FabricHTTPException(response)
|
|
106
|
+
|
|
107
|
+
print(f"{icons.green_dot} The '{gateway}' gateway has been deleted.")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def list_gateway_role_assigments(gateway: str | UUID) -> pd.DataFrame:
|
|
111
|
+
"""
|
|
112
|
+
Returns a list of gateway role assignments.
|
|
113
|
+
|
|
114
|
+
This is a wrapper function for the following API: `Gateways - List Gateway Role Assignments <https://learn.microsoft.com/rest/api/fabric/core/gateways/list-gateway-role-assignments>`_.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
gateway : str | UUID
|
|
119
|
+
The gateway name or ID.
|
|
120
|
+
|
|
121
|
+
Returns
|
|
122
|
+
-------
|
|
123
|
+
pandas.DataFrame
|
|
124
|
+
A pandas dataframe showing a list of gateway role assignments.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
128
|
+
client = fabric.FabricRestClient()
|
|
129
|
+
response = client.get(f"/v1/gateways/{gateway_id}/roleAssignments")
|
|
130
|
+
|
|
131
|
+
if response.status_code != 200:
|
|
132
|
+
raise FabricHTTPException(response)
|
|
133
|
+
|
|
134
|
+
df = pd.DataFrame(columns=[])
|
|
135
|
+
|
|
136
|
+
responses = pagination(client, response)
|
|
137
|
+
|
|
138
|
+
for r in responses:
|
|
139
|
+
for v in r.get("value", []):
|
|
140
|
+
new_data = {
|
|
141
|
+
"Gateway Role Assignment Id": v.get("id"),
|
|
142
|
+
"Principal Id": v.get("principal", {}).get("id"),
|
|
143
|
+
"Principal Type": v.get("principal", {}).get("type"),
|
|
144
|
+
"Role": v.get("role"),
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
148
|
+
|
|
149
|
+
return df
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def delete_gateway_role_assignment(gateway: str | UUID, role_assignement_id: UUID):
|
|
153
|
+
"""
|
|
154
|
+
Delete the specified role assignment for the gateway.
|
|
155
|
+
|
|
156
|
+
This is a wrapper function for the following API: `Gateways - Delete Gateway Role Assignment <https://learn.microsoft.com/rest/api/fabric/core/gateways/delete-gateway-role-assignment>`_.
|
|
157
|
+
|
|
158
|
+
Parameters
|
|
159
|
+
----------
|
|
160
|
+
gateway : str | UUID
|
|
161
|
+
The gateway name or ID.
|
|
162
|
+
role_assignement_id : UUID
|
|
163
|
+
The role assignment ID.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
167
|
+
client = fabric.FabricRestClient()
|
|
168
|
+
response = client.delete(
|
|
169
|
+
f"/v1/gateways/{gateway_id}/roleAssignments/{role_assignement_id}"
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
if response.status_code != 200:
|
|
173
|
+
raise FabricHTTPException(response)
|
|
174
|
+
|
|
175
|
+
print(
|
|
176
|
+
f"{icons.green_dot} The '{role_assignement_id}' role assignment for the '{gateway}' gateway has been deleted."
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _resolve_gateway_member_id(gateway: str | UUID, gateway_member: str | UUID) -> UUID:
|
|
181
|
+
|
|
182
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
183
|
+
dfM = list_gateway_members(gateway=gateway_id)
|
|
184
|
+
|
|
185
|
+
if _is_valid_uuid(gateway_member):
|
|
186
|
+
dfM_filt = dfM[dfM["Member Id"] == gateway_member]
|
|
187
|
+
else:
|
|
188
|
+
dfM_filt = dfM[dfM["Member Name"] == gateway_member]
|
|
189
|
+
if len(dfM_filt) == 0:
|
|
190
|
+
raise ValueError(
|
|
191
|
+
f"{icons.red_dot} The '{gateway_member}' gateway member does not exist within the '{gateway}' gateway."
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
return dfM_filt["Member Id"].iloc[0]
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def delete_gateway_member(gateway: str | UUID, gateway_member: str | UUID):
|
|
198
|
+
"""
|
|
199
|
+
Delete gateway member of an on-premises gateway.
|
|
200
|
+
|
|
201
|
+
This is a wrapper function for the following API: `Gateways - Delete Gateway Member <https://learn.microsoft.com/rest/api/fabric/core/gateways/delete-gateway-member>`_.
|
|
202
|
+
|
|
203
|
+
Parameters
|
|
204
|
+
----------
|
|
205
|
+
gateway : str | UUID
|
|
206
|
+
The gateway name or ID.
|
|
207
|
+
gateway_member : str | UUID
|
|
208
|
+
The gateway member name or ID.
|
|
209
|
+
"""
|
|
210
|
+
|
|
211
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
212
|
+
member_id = _resolve_gateway_member_id(
|
|
213
|
+
gateway=gateway_id, gateway_member=gateway_member
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
client = fabric.FabricRestClient()
|
|
217
|
+
response = client.delete(f"/v1/gateways/{gateway_id}/members/{member_id}")
|
|
218
|
+
|
|
219
|
+
if response.status_code != 200:
|
|
220
|
+
raise FabricHTTPException(response)
|
|
221
|
+
|
|
222
|
+
print(
|
|
223
|
+
f"{icons.green_dot} The '{member_id}' member for the '{gateway}' gateway has been deleted."
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def list_gateway_members(gateway: str | UUID) -> pd.DataFrame:
|
|
228
|
+
"""
|
|
229
|
+
Lists gateway members of an on-premises gateway.
|
|
230
|
+
|
|
231
|
+
This is a wrapper function for the following API: `Gateways - List Gateway Members <https://learn.microsoft.com/rest/api/fabric/core/gateways/list-gateway-members>`_.
|
|
232
|
+
|
|
233
|
+
Parameters
|
|
234
|
+
----------
|
|
235
|
+
gateway : str | UUID
|
|
236
|
+
The gateway name or ID.
|
|
237
|
+
|
|
238
|
+
Returns
|
|
239
|
+
-------
|
|
240
|
+
pandas.DataFrame
|
|
241
|
+
A pandas dataframe showing a list of gateway members of an on-premises gateway.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
245
|
+
client = fabric.FabricRestClient()
|
|
246
|
+
response = client.get(f"/v1/gateways/{gateway_id}/members")
|
|
247
|
+
|
|
248
|
+
if response.status_code != 200:
|
|
249
|
+
raise FabricHTTPException(response)
|
|
250
|
+
|
|
251
|
+
df = pd.DataFrame(
|
|
252
|
+
columns=[
|
|
253
|
+
"Member Id",
|
|
254
|
+
"Member Name",
|
|
255
|
+
"Public Key Exponent",
|
|
256
|
+
"Public Key Modulus",
|
|
257
|
+
"Version",
|
|
258
|
+
"Enabled",
|
|
259
|
+
]
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
for v in response.json().get("value", []):
|
|
263
|
+
new_data = {
|
|
264
|
+
"Member Id": v.get("id"),
|
|
265
|
+
"Member Name": v.get("displayName"),
|
|
266
|
+
"Public Key Exponent": v.get("publicKey", {}).get("exponent"),
|
|
267
|
+
"Public Key Modulus": v.get("publicKey", {}).get("modulus"),
|
|
268
|
+
"Version": v.get("version"),
|
|
269
|
+
"Enabled": v.get("enabled"),
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
273
|
+
|
|
274
|
+
bool_cols = ["Enabled"]
|
|
275
|
+
df[bool_cols] = df[bool_cols].astype(bool)
|
|
276
|
+
|
|
277
|
+
return df
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def create_vnet_gateway(
|
|
281
|
+
name: str,
|
|
282
|
+
capacity: str | UUID,
|
|
283
|
+
inactivity_minutes_before_sleep: int,
|
|
284
|
+
number_of_member_gateways: int,
|
|
285
|
+
subscription_id: str,
|
|
286
|
+
resource_group: str,
|
|
287
|
+
virtual_network: str,
|
|
288
|
+
subnet: str,
|
|
289
|
+
):
|
|
290
|
+
"""
|
|
291
|
+
Creates a virtual network gateway.
|
|
292
|
+
|
|
293
|
+
This is a wrapper function for the following API: `Gateways - Create Gateway <https://learn.microsoft.com/rest/api/fabric/core/gateways/create-gateway>`_.
|
|
294
|
+
|
|
295
|
+
Parameters
|
|
296
|
+
----------
|
|
297
|
+
name : str
|
|
298
|
+
The gateway name.
|
|
299
|
+
capacity : str | UUID
|
|
300
|
+
The capacity name or Id.
|
|
301
|
+
inactivity_minutes_before_sleep : int
|
|
302
|
+
The minutes of inactivity before the virtual network gateway goes into auto-sleep. Must be one of the following values: 30, 60, 90, 120, 150, 240, 360, 480, 720, 1440.
|
|
303
|
+
number_of_member_gateways: int
|
|
304
|
+
The number of member gateways. A number between 1 and 7.
|
|
305
|
+
subscription_id : str
|
|
306
|
+
The subscription ID.
|
|
307
|
+
resource_group : str
|
|
308
|
+
The name of the resource group.
|
|
309
|
+
virtual_network : str
|
|
310
|
+
The name of the virtual network.
|
|
311
|
+
subnet : str
|
|
312
|
+
The name of the subnet.
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
client = fabric.FabricRestClient()
|
|
316
|
+
|
|
317
|
+
capacity_id = resolve_capacity_id(capacity)
|
|
318
|
+
payload = {
|
|
319
|
+
"type": "VirtualNetwork",
|
|
320
|
+
"displayName": name,
|
|
321
|
+
"capacityId": capacity_id,
|
|
322
|
+
"virtualNetworkAzureResource": {
|
|
323
|
+
"subscriptionId": subscription_id,
|
|
324
|
+
"resourceGroupName": resource_group,
|
|
325
|
+
"virtualNetworkName": virtual_network,
|
|
326
|
+
"subnetName": subnet,
|
|
327
|
+
},
|
|
328
|
+
"inactivityMinutesBeforeSleep": inactivity_minutes_before_sleep,
|
|
329
|
+
"numberOfMemberGateways": number_of_member_gateways,
|
|
330
|
+
}
|
|
331
|
+
response = client.post("/v1/gateways", json=payload)
|
|
332
|
+
|
|
333
|
+
if response.status_code != 201:
|
|
334
|
+
raise FabricHTTPException(response)
|
|
335
|
+
|
|
336
|
+
print(
|
|
337
|
+
f"{icons.green_dot} The '{name}' gateway was created within the '{capacity}' capacity."
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def update_on_premises_gateway(
|
|
342
|
+
gateway: str,
|
|
343
|
+
allow_cloud_connection_refresh: Optional[bool] = None,
|
|
344
|
+
allow_custom_connectors: Optional[bool] = None,
|
|
345
|
+
load_balancing_setting: Optional[str] = None,
|
|
346
|
+
):
|
|
347
|
+
"""
|
|
348
|
+
Updates an on-premises gateway.
|
|
349
|
+
|
|
350
|
+
This is a wrapper function for the following API: `Gateways - Update Gateway <https://learn.microsoft.com/rest/api/fabric/core/gateways/update-gateway>`_.
|
|
351
|
+
|
|
352
|
+
Parameters
|
|
353
|
+
----------
|
|
354
|
+
gateway : str | UUID
|
|
355
|
+
The gateway name or ID.
|
|
356
|
+
allow_cloud_connection_refresh : bool, default=None
|
|
357
|
+
Whether to allow cloud connections to refresh through this on-premises gateway. True - Allow, False - Do not allow.
|
|
358
|
+
allow_custom_connectors : bool, default=None
|
|
359
|
+
Whether to allow custom connectors to be used with this on-premises gateway. True - Allow, False - Do not allow.
|
|
360
|
+
load_balancing_setting : str, default=None
|
|
361
|
+
The `load balancing setting <https://learn.microsoft.com/rest/api/fabric/core/gateways/update-gateway?tabs=HTTP#loadbalancingsetting>`_ of the on-premises gateway.
|
|
362
|
+
"""
|
|
363
|
+
|
|
364
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
365
|
+
|
|
366
|
+
payload = {}
|
|
367
|
+
|
|
368
|
+
if allow_cloud_connection_refresh is not None:
|
|
369
|
+
payload["allowCloudConnectionRefresh"] = allow_cloud_connection_refresh
|
|
370
|
+
if allow_custom_connectors is not None:
|
|
371
|
+
payload["allowCustomConnectors"] = allow_custom_connectors
|
|
372
|
+
if load_balancing_setting is not None:
|
|
373
|
+
payload["loadBalancingSetting"] = load_balancing_setting
|
|
374
|
+
|
|
375
|
+
if not payload:
|
|
376
|
+
raise ValueError(
|
|
377
|
+
f"{icons.yellow_dot} The '{gateway}' gateway has not been update as no valid settings were provided."
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
payload["type"] = "OnPremises"
|
|
381
|
+
|
|
382
|
+
client = fabric.FabricRestClient()
|
|
383
|
+
response = client.patch(f"/v1/gateways/{gateway_id}", json=payload)
|
|
384
|
+
|
|
385
|
+
if response.status_code != 200:
|
|
386
|
+
raise FabricHTTPException(response)
|
|
387
|
+
|
|
388
|
+
print(f"{icons.green_dot} The '{gateway}' has been updated accordingly.")
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def update_vnet_gateway(
|
|
392
|
+
gateway: str,
|
|
393
|
+
capacity: str | UUID,
|
|
394
|
+
inactivity_minutes_before_sleep: Optional[int] = None,
|
|
395
|
+
number_of_member_gateways: Optional[int] = None,
|
|
396
|
+
):
|
|
397
|
+
"""
|
|
398
|
+
Updates a virtual network gateway.
|
|
399
|
+
|
|
400
|
+
This is a wrapper function for the following API: `Gateways - Update Gateway <https://learn.microsoft.com/rest/api/fabric/core/gateways/update-gateway>`_.
|
|
401
|
+
|
|
402
|
+
Parameters
|
|
403
|
+
----------
|
|
404
|
+
gateway : str | UUID
|
|
405
|
+
The gateway name or ID.
|
|
406
|
+
capacity: str | UUID
|
|
407
|
+
The capacity name or ID.
|
|
408
|
+
inactivity_minutes_before_sleep : int, default=None
|
|
409
|
+
The minutes of inactivity before the virtual network gateway goes into auto-sleep. Must be one of the following values: 30, 60, 90, 120, 150, 240, 360, 480, 720, 1440.
|
|
410
|
+
number_of_member_gateways : int, default=None
|
|
411
|
+
The number of member gateways. A number between 1 and 7.
|
|
412
|
+
"""
|
|
413
|
+
|
|
414
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
415
|
+
|
|
416
|
+
payload = {}
|
|
417
|
+
|
|
418
|
+
if capacity is not None:
|
|
419
|
+
capacity_id = resolve_capacity_id(capacity)
|
|
420
|
+
payload["capacityId"] = capacity_id
|
|
421
|
+
if inactivity_minutes_before_sleep is not None:
|
|
422
|
+
payload["inactivityMinutesBeforeSleep"] = inactivity_minutes_before_sleep
|
|
423
|
+
if number_of_member_gateways is not None:
|
|
424
|
+
payload["numberOfMemberGateways"] = number_of_member_gateways
|
|
425
|
+
|
|
426
|
+
if not payload:
|
|
427
|
+
raise ValueError(
|
|
428
|
+
f"{icons.yellow_dot} The '{gateway}' gateway has not been update as no valid settings were provided."
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
payload["type"] = "VirtualNetwork"
|
|
432
|
+
|
|
433
|
+
client = fabric.FabricRestClient()
|
|
434
|
+
response = client.patch(f"/v1/gateways/{gateway_id}", json=payload)
|
|
435
|
+
|
|
436
|
+
if response.status_code != 200:
|
|
437
|
+
raise FabricHTTPException(response)
|
|
438
|
+
|
|
439
|
+
print(f"{icons.green_dot} The '{gateway}' has been updated accordingly.")
|
|
@@ -54,40 +54,60 @@ def create_blank_semantic_model(
|
|
|
54
54
|
f"{icons.red_dot} Compatiblity level must be at least {min_compat}."
|
|
55
55
|
)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
# If the model does not exist
|
|
58
|
+
if len(dfD_filt) == 0:
|
|
59
|
+
tmsl = f"""
|
|
60
|
+
{{
|
|
61
|
+
"createOrReplace": {{
|
|
62
|
+
"object": {{
|
|
63
|
+
"database": '{dataset}'
|
|
64
|
+
}},
|
|
65
|
+
"database": {{
|
|
66
|
+
"name": '{dataset}',
|
|
67
|
+
"compatibilityLevel": {compatibility_level},
|
|
68
|
+
"model": {{
|
|
69
|
+
"cultures": [
|
|
70
|
+
{{
|
|
71
|
+
"name": "en-US",
|
|
72
|
+
"linguisticMetadata": {{
|
|
73
|
+
"content": {{
|
|
74
|
+
"Version": "1.0.0",
|
|
75
|
+
"Language": "en-US"
|
|
76
|
+
}},
|
|
77
|
+
"contentType": "json"
|
|
78
|
+
}}
|
|
76
79
|
}}
|
|
80
|
+
],
|
|
81
|
+
"collation": "Latin1_General_100_BIN2_UTF8",
|
|
82
|
+
"dataAccessOptions": {{
|
|
83
|
+
"legacyRedirects": true,
|
|
84
|
+
"returnErrorValuesAsNull": true,
|
|
85
|
+
}},
|
|
86
|
+
"defaultPowerBIDataSourceVersion": "powerBI_V3",
|
|
87
|
+
"sourceQueryCulture": "en-US",
|
|
77
88
|
}}
|
|
78
|
-
],
|
|
79
|
-
"collation": "Latin1_General_100_BIN2_UTF8",
|
|
80
|
-
"dataAccessOptions": {{
|
|
81
|
-
"legacyRedirects": true,
|
|
82
|
-
"returnErrorValuesAsNull": true,
|
|
83
|
-
}},
|
|
84
|
-
"defaultPowerBIDataSourceVersion": "powerBI_V3",
|
|
85
|
-
"sourceQueryCulture": "en-US",
|
|
86
89
|
}}
|
|
87
90
|
}}
|
|
88
91
|
}}
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
"""
|
|
93
|
+
else:
|
|
94
|
+
tmsl = f"""
|
|
95
|
+
{{
|
|
96
|
+
"createOrReplace": {{
|
|
97
|
+
"object": {{
|
|
98
|
+
"database": '{dataset}'
|
|
99
|
+
}},
|
|
100
|
+
"database": {{
|
|
101
|
+
"name": '{dataset}',
|
|
102
|
+
"compatibilityLevel": {compatibility_level},
|
|
103
|
+
"model": {{
|
|
104
|
+
"culture": "en-US",
|
|
105
|
+
"defaultPowerBIDataSourceVersion": "powerBI_V3"
|
|
106
|
+
}}
|
|
107
|
+
}}
|
|
108
|
+
}}
|
|
109
|
+
}}
|
|
110
|
+
"""
|
|
91
111
|
|
|
92
112
|
fabric.execute_tmsl(script=tmsl, workspace=workspace)
|
|
93
113
|
|
|
@@ -221,7 +241,7 @@ def update_semantic_model_from_bim(
|
|
|
221
241
|
json=request_body,
|
|
222
242
|
)
|
|
223
243
|
|
|
224
|
-
lro(client, response, status_codes=[200, 202])
|
|
244
|
+
lro(client, response, status_codes=[200, 202], return_status_code=True)
|
|
225
245
|
|
|
226
246
|
print(
|
|
227
247
|
f"{icons.green_dot} The '{dataset}' semantic model has been updated within the '{workspace}' workspace."
|
|
@@ -288,6 +308,7 @@ def deploy_semantic_model(
|
|
|
288
308
|
dataset=target_dataset,
|
|
289
309
|
bim_file=bim,
|
|
290
310
|
workspace=target_workspace,
|
|
311
|
+
overwrite=overwrite,
|
|
291
312
|
)
|
|
292
313
|
# Update the semantic model if the model exists
|
|
293
314
|
else:
|
sempy_labs/_git.py
CHANGED
|
@@ -217,7 +217,7 @@ def get_git_connection(workspace: Optional[str] = None) -> pd.DataFrame:
|
|
|
217
217
|
return df
|
|
218
218
|
|
|
219
219
|
|
|
220
|
-
def initialize_git_connection(workspace: Optional[str] = None):
|
|
220
|
+
def initialize_git_connection(workspace: Optional[str] = None) -> str:
|
|
221
221
|
"""
|
|
222
222
|
Initializes a connection for a workspace that is connected to Git.
|
|
223
223
|
|
|
@@ -229,6 +229,11 @@ def initialize_git_connection(workspace: Optional[str] = None):
|
|
|
229
229
|
The Fabric workspace name.
|
|
230
230
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
231
231
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
232
|
+
|
|
233
|
+
Returns
|
|
234
|
+
-------
|
|
235
|
+
str
|
|
236
|
+
Remote full SHA commit hash.
|
|
232
237
|
"""
|
|
233
238
|
|
|
234
239
|
workspace, workspace_id = resolve_workspace_name_and_id(workspace)
|
|
@@ -245,6 +250,8 @@ def initialize_git_connection(workspace: Optional[str] = None):
|
|
|
245
250
|
f"{icons.green_dot} The '{workspace}' workspace git connection has been initialized."
|
|
246
251
|
)
|
|
247
252
|
|
|
253
|
+
return response.json().get("remoteCommitHash")
|
|
254
|
+
|
|
248
255
|
|
|
249
256
|
def commit_to_git(
|
|
250
257
|
comment: str, item_ids: str | List[str] = None, workspace: Optional[str] = None
|
|
@@ -324,14 +331,15 @@ def update_from_git(
|
|
|
324
331
|
|
|
325
332
|
Parameters
|
|
326
333
|
----------
|
|
327
|
-
|
|
328
|
-
Full SHA hash that the workspace is synced to. This value may be null only after Initialize Connection.
|
|
329
|
-
In other cases, the system will validate that the given value is aligned with the head known to the system.
|
|
330
|
-
remove_commit_hash : str
|
|
334
|
+
remote_commit_hash : str
|
|
331
335
|
Remote full SHA commit hash.
|
|
332
336
|
confilict_resolution_policy : str
|
|
333
337
|
The `conflict resolution policy <https://learn.microsoft.com/rest/api/fabric/core/git/update-from-git?tabs=HTTP#conflictresolutionpolicy>`_.
|
|
338
|
+
workspace_head : str
|
|
339
|
+
Full SHA hash that the workspace is synced to. This value may be null only after Initialize Connection.
|
|
340
|
+
In other cases, the system will validate that the given value is aligned with the head known to the system.
|
|
334
341
|
allow_override : bool, default=False
|
|
342
|
+
User consent to override incoming items during the update from Git process. When incoming items are present and the allow override items is not specified or is provided as false, the update operation will not start. Default value is false.
|
|
335
343
|
workspace : str, default=None
|
|
336
344
|
The Fabric workspace name.
|
|
337
345
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
sempy_labs/_helper_functions.py
CHANGED
|
@@ -17,6 +17,17 @@ import numpy as np
|
|
|
17
17
|
from IPython.display import display, HTML
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def _build_url(url: str, params: dict) -> str:
|
|
21
|
+
"""
|
|
22
|
+
Build the url with a list of parameters
|
|
23
|
+
"""
|
|
24
|
+
url_parts = list(urllib.parse.urlparse(url))
|
|
25
|
+
url_parts[4] = urllib.parse.urlencode(params)
|
|
26
|
+
url = urllib.parse.urlunparse(url_parts)
|
|
27
|
+
|
|
28
|
+
return url
|
|
29
|
+
|
|
30
|
+
|
|
20
31
|
def create_abfss_path(
|
|
21
32
|
lakehouse_id: UUID, lakehouse_workspace_id: UUID, delta_table_name: str
|
|
22
33
|
) -> str:
|
|
@@ -1219,7 +1230,7 @@ def _show_chart(spec, title):
|
|
|
1219
1230
|
<div id="vis"></div>
|
|
1220
1231
|
</td>
|
|
1221
1232
|
</tr>
|
|
1222
|
-
</table>
|
|
1233
|
+
</table>
|
|
1223
1234
|
<script type="text/javascript">
|
|
1224
1235
|
var spec = {spec};
|
|
1225
1236
|
var opt = {{"renderer": "canvas", "actions": false}};
|
|
@@ -1264,8 +1275,8 @@ def _process_and_display_chart(df, title, widget):
|
|
|
1264
1275
|
}
|
|
1265
1276
|
},
|
|
1266
1277
|
"x": {
|
|
1267
|
-
"field": "Start",
|
|
1268
|
-
"type": "quantitative",
|
|
1278
|
+
"field": "Start",
|
|
1279
|
+
"type": "quantitative",
|
|
1269
1280
|
"title": "milliseconds",
|
|
1270
1281
|
"axis": {
|
|
1271
1282
|
"titleFontSize": 20
|
sempy_labs/_list_functions.py
CHANGED
|
@@ -1371,7 +1371,7 @@ def list_report_semantic_model_objects(
|
|
|
1371
1371
|
Shows a list of semantic model objects (i.e. columns, measures, hierarchies) used in all reports which feed data from
|
|
1372
1372
|
a given semantic model.
|
|
1373
1373
|
|
|
1374
|
-
|
|
1374
|
+
Note: As with all functions which rely on the ReportWrapper, this function requires the report(s) to be in the 'PBIR' format.
|
|
1375
1375
|
|
|
1376
1376
|
Parameters
|
|
1377
1377
|
----------
|
sempy_labs/_model_auto_build.py
CHANGED
|
@@ -2,7 +2,7 @@ import sempy.fabric as fabric
|
|
|
2
2
|
import pandas as pd
|
|
3
3
|
from sempy_labs.tom import connect_semantic_model
|
|
4
4
|
from sempy_labs._generate_semantic_model import create_blank_semantic_model
|
|
5
|
-
from sempy_labs.directlake.
|
|
5
|
+
from sempy_labs.directlake._generate_shared_expression import generate_shared_expression
|
|
6
6
|
from typing import Optional
|
|
7
7
|
from sempy._utils._log import log
|
|
8
8
|
|
|
@@ -58,7 +58,9 @@ def model_auto_build(
|
|
|
58
58
|
) as tom:
|
|
59
59
|
|
|
60
60
|
# DL Only
|
|
61
|
-
expr =
|
|
61
|
+
expr = generate_shared_expression(
|
|
62
|
+
item_name=lakehouse, item_type="Lakehouse", workspace=lakehouse_workspace
|
|
63
|
+
)
|
|
62
64
|
tom.add_expression(name="DatbaseQuery", expression=expr)
|
|
63
65
|
|
|
64
66
|
for sheet in sheets:
|
sempy_labs/_model_bpa.py
CHANGED
|
@@ -400,23 +400,10 @@ def run_model_bpa(
|
|
|
400
400
|
dfExport["Timestamp"] = now
|
|
401
401
|
dfExport["RunId"] = runId
|
|
402
402
|
dfExport["Configured By"] = configured_by
|
|
403
|
-
|
|
404
403
|
dfExport["RunId"] = dfExport["RunId"].astype("int")
|
|
405
404
|
|
|
406
|
-
|
|
407
|
-
dfExport
|
|
408
|
-
colName = "Capacity Id"
|
|
409
|
-
dfExport.insert(1, colName, dfExport.pop(colName))
|
|
410
|
-
colName = "Workspace Name"
|
|
411
|
-
dfExport.insert(2, colName, dfExport.pop(colName))
|
|
412
|
-
colName = "Workspace Id"
|
|
413
|
-
dfExport.insert(3, colName, dfExport.pop(colName))
|
|
414
|
-
colName = "Dataset Name"
|
|
415
|
-
dfExport.insert(4, colName, dfExport.pop(colName))
|
|
416
|
-
colName = "Configured By"
|
|
417
|
-
dfExport.insert(5, colName, dfExport.pop(colName))
|
|
418
|
-
|
|
419
|
-
dfExport.columns = dfExport.columns.str.replace(" ", "_")
|
|
405
|
+
dfExport = dfExport[list(icons.bpa_schema.keys())]
|
|
406
|
+
dfExport["RunId"] = dfExport["RunId"].astype("int")
|
|
420
407
|
schema = {
|
|
421
408
|
key.replace(" ", "_"): value for key, value in icons.bpa_schema.items()
|
|
422
409
|
}
|