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/_connections.py
CHANGED
|
@@ -2,7 +2,131 @@ import sempy.fabric as fabric
|
|
|
2
2
|
import pandas as pd
|
|
3
3
|
from sempy.fabric.exceptions import FabricHTTPException
|
|
4
4
|
from typing import Optional
|
|
5
|
-
from sempy_labs._helper_functions import
|
|
5
|
+
from sempy_labs._helper_functions import (
|
|
6
|
+
pagination,
|
|
7
|
+
_is_valid_uuid,
|
|
8
|
+
)
|
|
9
|
+
from uuid import UUID
|
|
10
|
+
import sempy_labs._icons as icons
|
|
11
|
+
from sempy_labs._gateways import _resolve_gateway_id
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def delete_connection(connection: str | UUID):
|
|
15
|
+
"""
|
|
16
|
+
Delete a connection.
|
|
17
|
+
|
|
18
|
+
This is a wrapper function for the following API: `Connections - Delete Connection <https://learn.microsoft.com/rest/api/fabric/core/connections/delete-connection>`_.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
connection : str | UUID
|
|
23
|
+
The connection name or ID.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
connection_id = _resolve_connection_id(connection)
|
|
27
|
+
|
|
28
|
+
client = fabric.FabricRestClient()
|
|
29
|
+
response = client.delete(f"/v1/connections/{connection_id}")
|
|
30
|
+
|
|
31
|
+
if response.status_code != 200:
|
|
32
|
+
raise FabricHTTPException(response)
|
|
33
|
+
|
|
34
|
+
print(f"{icons.green_dot} The '{connection}' connection has been deleted.")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def delete_connection_role_assignment(connection: str | UUID, role_assignment_id: UUID):
|
|
38
|
+
"""
|
|
39
|
+
Delete the specified role assignment for the connection.
|
|
40
|
+
|
|
41
|
+
This is a wrapper function for the following API: `Connections - Delete Connection Role Assignment <https://learn.microsoft.com/rest/api/fabric/core/connections/delete-connection-role-assignment>`_.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
connection : str | UUID
|
|
46
|
+
The connection name or ID.
|
|
47
|
+
role_assignment_id : UUID
|
|
48
|
+
The role assignment ID.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
connection_id = _resolve_connection_id(connection)
|
|
52
|
+
|
|
53
|
+
client = fabric.FabricRestClient()
|
|
54
|
+
response = client.delete(
|
|
55
|
+
f"/v1/connections/{connection_id}/roleAssignments/{role_assignment_id}"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if response.status_code != 200:
|
|
59
|
+
raise FabricHTTPException(response)
|
|
60
|
+
|
|
61
|
+
print(
|
|
62
|
+
f"{icons.green_dot} The '{role_assignment_id}' role assignment Id has been deleted from the '{connection}' connection."
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _resolve_connection_id(connection: str | UUID) -> UUID:
|
|
67
|
+
|
|
68
|
+
dfC = list_connections()
|
|
69
|
+
if _is_valid_uuid(connection):
|
|
70
|
+
dfC_filt = dfC[dfC["Connection Id"] == connection]
|
|
71
|
+
else:
|
|
72
|
+
dfC_filt = dfC[dfC["Connection Name"] == connection]
|
|
73
|
+
|
|
74
|
+
if len(dfC_filt) == 0:
|
|
75
|
+
raise ValueError(
|
|
76
|
+
f"{icons.red_dot} The '{connection}' is not a valid connection."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return dfC_filt["Connection Id"].iloc[0]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def list_connection_role_assignments(connection: str | UUID) -> pd.DataFrame:
|
|
83
|
+
"""
|
|
84
|
+
Returns a list of connection role assignments.
|
|
85
|
+
|
|
86
|
+
This is a wrapper function for the following API: `Connections - List Connection Role Assignments <https://learn.microsoft.com/rest/api/fabric/core/connections/list-connection-role-assignments>`_.
|
|
87
|
+
|
|
88
|
+
Parameters
|
|
89
|
+
----------
|
|
90
|
+
connection : str | UUID
|
|
91
|
+
The connection name or ID.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
pandas.DataFrame
|
|
96
|
+
A pandas dataframe showing a list of connection role assignments.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
connection_id = _resolve_connection_id(connection)
|
|
100
|
+
|
|
101
|
+
client = fabric.FabricRestClient()
|
|
102
|
+
response = client.get(f"/v1/connections/{connection_id}/roleAssignments")
|
|
103
|
+
|
|
104
|
+
df = pd.DataFrame(
|
|
105
|
+
columns=[
|
|
106
|
+
"Connection Role Assignment Id",
|
|
107
|
+
"Principal Id",
|
|
108
|
+
"Principal Type",
|
|
109
|
+
"Role",
|
|
110
|
+
]
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if response.status_code != 200:
|
|
114
|
+
raise FabricHTTPException(response)
|
|
115
|
+
|
|
116
|
+
responses = pagination(client, response)
|
|
117
|
+
|
|
118
|
+
for r in responses:
|
|
119
|
+
for v in r.get("value", []):
|
|
120
|
+
new_data = {
|
|
121
|
+
"Connection Role Assignment Id": v.get("id"),
|
|
122
|
+
"Principal Id": v.get("principal", {}).get("id"),
|
|
123
|
+
"Principal Type": v.get("principal", {}).get("type"),
|
|
124
|
+
"Role": v.get("role"),
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
128
|
+
|
|
129
|
+
return df
|
|
6
130
|
|
|
7
131
|
|
|
8
132
|
def list_connections() -> pd.DataFrame:
|
|
@@ -21,6 +145,8 @@ def list_connections() -> pd.DataFrame:
|
|
|
21
145
|
if response.status_code != 200:
|
|
22
146
|
raise FabricHTTPException(response)
|
|
23
147
|
|
|
148
|
+
responses = pagination(client, response)
|
|
149
|
+
|
|
24
150
|
df = pd.DataFrame(
|
|
25
151
|
columns=[
|
|
26
152
|
"Connection Id",
|
|
@@ -36,40 +162,42 @@ def list_connections() -> pd.DataFrame:
|
|
|
36
162
|
"Skip Test Connection",
|
|
37
163
|
]
|
|
38
164
|
)
|
|
165
|
+
for r in responses:
|
|
166
|
+
for i in r.get("value", []):
|
|
167
|
+
connection_details = i.get("connectionDetails", {})
|
|
168
|
+
credential_details = i.get("credentialDetails", {})
|
|
39
169
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
170
|
+
new_data = {
|
|
171
|
+
"Connection Id": i.get("id"),
|
|
172
|
+
"Connection Name": i.get("displayName"),
|
|
173
|
+
"Gateway Id": i.get("gatewayId"),
|
|
174
|
+
"Connectivity Type": i.get("connectivityType"),
|
|
175
|
+
"Connection Path": connection_details.get("path"),
|
|
176
|
+
"Connection Type": connection_details.get("type"),
|
|
177
|
+
"Privacy Level": i.get("privacyLevel"),
|
|
178
|
+
"Credential Type": (
|
|
179
|
+
credential_details.get("credentialType")
|
|
180
|
+
if credential_details
|
|
181
|
+
else None
|
|
182
|
+
),
|
|
183
|
+
"Single Sign On Type": (
|
|
184
|
+
credential_details.get("singleSignOnType")
|
|
185
|
+
if credential_details
|
|
186
|
+
else None
|
|
187
|
+
),
|
|
188
|
+
"Connection Encryption": (
|
|
189
|
+
credential_details.get("connectionEncryption")
|
|
190
|
+
if credential_details
|
|
191
|
+
else None
|
|
192
|
+
),
|
|
193
|
+
"Skip Test Connection": (
|
|
194
|
+
credential_details.get("skipTestConnection")
|
|
195
|
+
if credential_details
|
|
196
|
+
else None
|
|
197
|
+
),
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
73
201
|
bool_cols = ["Skip Test Connection"]
|
|
74
202
|
df[bool_cols] = df[bool_cols].astype(bool)
|
|
75
203
|
|
|
@@ -82,6 +210,8 @@ def list_item_connections(
|
|
|
82
210
|
"""
|
|
83
211
|
Shows the list of connections that the specified item is connected to.
|
|
84
212
|
|
|
213
|
+
This is a wrapper function for the following API: `Items - List Item Connections <https://learn.microsoft.com/rest/api/fabric/core/items/list-item-connections>`_.
|
|
214
|
+
|
|
85
215
|
Parameters
|
|
86
216
|
----------
|
|
87
217
|
item_name : str
|
|
@@ -99,8 +229,6 @@ def list_item_connections(
|
|
|
99
229
|
A pandas dataframe showing the list of connections that the specified item is connected to.
|
|
100
230
|
"""
|
|
101
231
|
|
|
102
|
-
# https://learn.microsoft.com/en-us/rest/api/fabric/core/items/list-item-connections?tabs=HTTP
|
|
103
|
-
|
|
104
232
|
workspace = fabric.resolve_workspace_name(workspace)
|
|
105
233
|
workspace_id = fabric.resolve_workspace_id(workspace)
|
|
106
234
|
item_type = item_type[0].upper() + item_type[1:]
|
|
@@ -143,49 +271,115 @@ def list_item_connections(
|
|
|
143
271
|
return df
|
|
144
272
|
|
|
145
273
|
|
|
146
|
-
def
|
|
147
|
-
|
|
148
|
-
server_name: str,
|
|
149
|
-
database_name: str,
|
|
150
|
-
user_name: str,
|
|
151
|
-
password: str,
|
|
152
|
-
privacy_level: str,
|
|
274
|
+
def _list_supported_connection_types(
|
|
275
|
+
gateway: Optional[str | UUID] = None, show_all_creation_methods: bool = False
|
|
153
276
|
) -> pd.DataFrame:
|
|
154
277
|
|
|
155
|
-
|
|
278
|
+
url = f"/v1/connections/supportedConnectionTypes?showAllCreationMethods={show_all_creation_methods}&"
|
|
279
|
+
if gateway is not None:
|
|
280
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
281
|
+
url += f"gatewayId={gateway_id}"
|
|
156
282
|
|
|
157
283
|
df = pd.DataFrame(
|
|
158
284
|
columns=[
|
|
159
|
-
"Connection ID",
|
|
160
|
-
"Connection Name",
|
|
161
|
-
"Connectivity Type",
|
|
162
285
|
"Connection Type",
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
"Connection Encryption",
|
|
168
|
-
"Skip Test Connection",
|
|
286
|
+
"Creation Method",
|
|
287
|
+
"Supported Credential Types",
|
|
288
|
+
"Supported Connection Encryption Types",
|
|
289
|
+
"Supports Skip Test Connection",
|
|
169
290
|
]
|
|
170
291
|
)
|
|
171
292
|
|
|
293
|
+
url = url.rstrip("&")
|
|
172
294
|
client = fabric.FabricRestClient()
|
|
295
|
+
response = client.get(url)
|
|
296
|
+
if response.status_code != 200:
|
|
297
|
+
raise FabricHTTPException(response)
|
|
298
|
+
|
|
299
|
+
responses = pagination(client, response)
|
|
300
|
+
|
|
301
|
+
records = []
|
|
302
|
+
for r in responses:
|
|
303
|
+
for v in r.get("value", []):
|
|
304
|
+
records.append(
|
|
305
|
+
{
|
|
306
|
+
"Connection Type": v.get("type"),
|
|
307
|
+
"Creation Method": v["creationMethods"][0]["name"],
|
|
308
|
+
"Supported Credential Types": v.get("supportedCredentialTypes"),
|
|
309
|
+
"Supported Connection Encryption Types": v.get(
|
|
310
|
+
"supportedConnectionEncryptionTypes"
|
|
311
|
+
),
|
|
312
|
+
"Supports Skip Test Connection": v.get(
|
|
313
|
+
"supportsSkipTestConnection"
|
|
314
|
+
),
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
if records:
|
|
319
|
+
df = pd.DataFrame(records)
|
|
320
|
+
|
|
321
|
+
return df
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def create_cloud_connection(
|
|
325
|
+
name: str,
|
|
326
|
+
server_name: str,
|
|
327
|
+
database_name: str,
|
|
328
|
+
user_name: str,
|
|
329
|
+
password: str,
|
|
330
|
+
privacy_level: str,
|
|
331
|
+
connection_encryption: str = "NotEncrypted",
|
|
332
|
+
skip_test_connection: bool = False,
|
|
333
|
+
):
|
|
334
|
+
"""
|
|
335
|
+
Creates a shared cloud connection.
|
|
336
|
+
|
|
337
|
+
This is a wrapper function for the following API: `Connections - Create Connection <https://learn.microsoft.com/rest/api/fabric/core/connections/create-connection>`_.
|
|
338
|
+
|
|
339
|
+
Parameters
|
|
340
|
+
----------
|
|
341
|
+
name : str
|
|
342
|
+
The name of the connection.
|
|
343
|
+
server_name : str
|
|
344
|
+
The name of the server.
|
|
345
|
+
database_name : str
|
|
346
|
+
The name of the database.
|
|
347
|
+
user_name : str
|
|
348
|
+
The username.
|
|
349
|
+
password : str
|
|
350
|
+
The password.
|
|
351
|
+
privacy_level : str
|
|
352
|
+
The `privacy level <https://learn.microsoft.com/rest/api/fabric/core/connections/create-connection?tabs=HTTP#privacylevel>`_ of the connection.
|
|
353
|
+
connection_encryption : str, default="NotEncrypted"
|
|
354
|
+
The connection encrpytion.
|
|
355
|
+
skip_test_connection: bool, default=False
|
|
356
|
+
If True, skips the test connection.
|
|
357
|
+
"""
|
|
173
358
|
|
|
174
359
|
request_body = {
|
|
175
360
|
"connectivityType": "ShareableCloud",
|
|
176
|
-
"
|
|
361
|
+
"displayName": name,
|
|
177
362
|
"connectionDetails": {
|
|
178
363
|
"type": "SQL",
|
|
364
|
+
"creationMethod": "SQL",
|
|
179
365
|
"parameters": [
|
|
180
|
-
{
|
|
181
|
-
|
|
366
|
+
{
|
|
367
|
+
"dataType": "Text",
|
|
368
|
+
"name": "server",
|
|
369
|
+
"value": server_name,
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"dataType": "Text",
|
|
373
|
+
"name": "database",
|
|
374
|
+
"value": database_name,
|
|
375
|
+
},
|
|
182
376
|
],
|
|
183
377
|
},
|
|
184
378
|
"privacyLevel": privacy_level,
|
|
185
379
|
"credentialDetails": {
|
|
186
380
|
"singleSignOnType": "None",
|
|
187
|
-
"connectionEncryption":
|
|
188
|
-
"skipTestConnection":
|
|
381
|
+
"connectionEncryption": connection_encryption,
|
|
382
|
+
"skipTestConnection": skip_test_connection,
|
|
189
383
|
"credentials": {
|
|
190
384
|
"credentialType": "Basic",
|
|
191
385
|
"username": user_name,
|
|
@@ -194,77 +388,79 @@ def create_connection_cloud(
|
|
|
194
388
|
},
|
|
195
389
|
}
|
|
196
390
|
|
|
391
|
+
client = fabric.FabricRestClient()
|
|
197
392
|
response = client.post("/v1/connections", json=request_body)
|
|
198
393
|
|
|
199
|
-
if response.status_code !=
|
|
394
|
+
if response.status_code != 201:
|
|
200
395
|
raise FabricHTTPException(response)
|
|
201
|
-
o = response.json()
|
|
202
|
-
new_data = {
|
|
203
|
-
"Connection Id": o.get("id"),
|
|
204
|
-
"Connection Name": o.get("name"),
|
|
205
|
-
"Connectivity Type": o.get("connectivityType"),
|
|
206
|
-
"Connection Type": o.get("connectionDetails", {}).get("type"),
|
|
207
|
-
"Connection Path": o.get("connectionDetails", {}).get("path"),
|
|
208
|
-
"Privacy Level": o.get("privacyLevel"),
|
|
209
|
-
"Credential Type": o.get("credentialDetails", {}).get("credentialType"),
|
|
210
|
-
"Single Sign On Type": o.get("credentialDetails", {}).get("singleSignOnType"),
|
|
211
|
-
"Connection Encryption": o.get("credentialDetails", {}).get(
|
|
212
|
-
"connectionEncryption"
|
|
213
|
-
),
|
|
214
|
-
"Skip Test Connection": o.get("credentialDetails", {}).get(
|
|
215
|
-
"skipTestConnection"
|
|
216
|
-
),
|
|
217
|
-
}
|
|
218
|
-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
219
396
|
|
|
220
|
-
|
|
397
|
+
print(f"{icons.green_dot} The '{name}' cloud connection has been created.")
|
|
221
398
|
|
|
222
|
-
return df
|
|
223
399
|
|
|
224
|
-
|
|
225
|
-
def create_connection_on_prem(
|
|
400
|
+
def create_on_prem_connection(
|
|
226
401
|
name: str,
|
|
227
|
-
|
|
402
|
+
gateway: str | UUID,
|
|
228
403
|
server_name: str,
|
|
229
404
|
database_name: str,
|
|
230
405
|
credentials: str,
|
|
231
406
|
privacy_level: str,
|
|
232
|
-
|
|
407
|
+
connection_encryption: str = "NotEncrypted",
|
|
408
|
+
skip_test_connection: bool = False,
|
|
409
|
+
):
|
|
410
|
+
"""
|
|
411
|
+
Creates an on-premises connection.
|
|
233
412
|
|
|
234
|
-
|
|
235
|
-
columns=[
|
|
236
|
-
"Connection ID",
|
|
237
|
-
"Connection Name",
|
|
238
|
-
"Gateway ID",
|
|
239
|
-
"Connectivity Type",
|
|
240
|
-
"Connection Type",
|
|
241
|
-
"Connection Path",
|
|
242
|
-
"Privacy Level",
|
|
243
|
-
"Credential Type",
|
|
244
|
-
"Single Sign On Type",
|
|
245
|
-
"Connection Encryption",
|
|
246
|
-
"Skip Test Connection",
|
|
247
|
-
]
|
|
248
|
-
)
|
|
413
|
+
This is a wrapper function for the following API: `Connections - Create Connection <https://learn.microsoft.com/rest/api/fabric/core/connections/create-connection>`_.
|
|
249
414
|
|
|
250
|
-
|
|
415
|
+
Parameters
|
|
416
|
+
----------
|
|
417
|
+
name : str
|
|
418
|
+
The name of the connection.
|
|
419
|
+
gateway : str | UUID
|
|
420
|
+
The name or Id of the gateway.
|
|
421
|
+
server_name : str
|
|
422
|
+
The name of the server.
|
|
423
|
+
database_name : str
|
|
424
|
+
The name of the database.
|
|
425
|
+
user_name : str
|
|
426
|
+
The username.
|
|
427
|
+
password : str
|
|
428
|
+
The password.
|
|
429
|
+
privacy_level : str
|
|
430
|
+
The `privacy level <https://learn.microsoft.com/rest/api/fabric/core/connections/create-connection?tabs=HTTP#privacylevel>`_ of the connection.
|
|
431
|
+
connection_encryption : str, default="NotEncrypted"
|
|
432
|
+
The connection encrpytion.
|
|
433
|
+
skip_test_connection: bool, default=False
|
|
434
|
+
If True, skips the test connection.
|
|
435
|
+
"""
|
|
436
|
+
|
|
437
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
251
438
|
|
|
252
439
|
request_body = {
|
|
253
|
-
"connectivityType": "
|
|
440
|
+
"connectivityType": "OnPremisesGateway",
|
|
254
441
|
"gatewayId": gateway_id,
|
|
255
|
-
"
|
|
442
|
+
"displayName": name,
|
|
256
443
|
"connectionDetails": {
|
|
257
444
|
"type": "SQL",
|
|
445
|
+
"creationMethod": "SQL",
|
|
258
446
|
"parameters": [
|
|
259
|
-
{
|
|
260
|
-
|
|
447
|
+
{
|
|
448
|
+
"dataType": "Text",
|
|
449
|
+
"name": "server",
|
|
450
|
+
"value": server_name,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"dataType": "Text",
|
|
454
|
+
"name": "database",
|
|
455
|
+
"value": database_name,
|
|
456
|
+
},
|
|
261
457
|
],
|
|
262
458
|
},
|
|
263
459
|
"privacyLevel": privacy_level,
|
|
264
460
|
"credentialDetails": {
|
|
265
461
|
"singleSignOnType": "None",
|
|
266
|
-
"connectionEncryption":
|
|
267
|
-
"skipTestConnection":
|
|
462
|
+
"connectionEncryption": connection_encryption,
|
|
463
|
+
"skipTestConnection": skip_test_connection,
|
|
268
464
|
"credentials": {
|
|
269
465
|
"credentialType": "Windows",
|
|
270
466
|
"values": [{"gatewayId": gateway_id, "credentials": credentials}],
|
|
@@ -272,79 +468,80 @@ def create_connection_on_prem(
|
|
|
272
468
|
},
|
|
273
469
|
}
|
|
274
470
|
|
|
471
|
+
client = fabric.FabricRestClient()
|
|
275
472
|
response = client.post("/v1/connections", json=request_body)
|
|
276
473
|
|
|
277
|
-
if response.status_code !=
|
|
474
|
+
if response.status_code != 201:
|
|
278
475
|
raise FabricHTTPException(response)
|
|
279
|
-
o = response.json()
|
|
280
|
-
new_data = {
|
|
281
|
-
"Connection Id": o.get("id"),
|
|
282
|
-
"Connection Name": o.get("name"),
|
|
283
|
-
"Gateway ID": o.get("gatewayId"),
|
|
284
|
-
"Connectivity Type": o.get("connectivityType"),
|
|
285
|
-
"Connection Type": o.get("connectionDetails", {}).get("type"),
|
|
286
|
-
"Connection Path": o.get("connectionDetails", {}).get("path"),
|
|
287
|
-
"Privacy Level": o.get("privacyLevel"),
|
|
288
|
-
"Credential Type": o.get("credentialDetails", {}).get("credentialType"),
|
|
289
|
-
"Single Sign On Type": o.get("credentialDetails", {}).get("singleSignOnType"),
|
|
290
|
-
"Connection Encryption": o.get("credentialDetails", {}).get(
|
|
291
|
-
"connectionEncryption"
|
|
292
|
-
),
|
|
293
|
-
"Skip Test Connection": o.get("credentialDetails", {}).get(
|
|
294
|
-
"skipTestConnection"
|
|
295
|
-
),
|
|
296
|
-
}
|
|
297
|
-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
298
|
-
|
|
299
|
-
df["Skip Test Connection"] = df["Skip Test Connection"].astype(bool)
|
|
300
476
|
|
|
301
|
-
|
|
477
|
+
print(f"{icons.green_dot} The '{name}' on-prem connection has been created.")
|
|
302
478
|
|
|
303
479
|
|
|
304
|
-
def
|
|
480
|
+
def create_vnet_connection(
|
|
305
481
|
name: str,
|
|
306
|
-
|
|
482
|
+
gateway: str | UUID,
|
|
307
483
|
server_name: str,
|
|
308
484
|
database_name: str,
|
|
309
485
|
user_name: str,
|
|
310
486
|
password: str,
|
|
311
487
|
privacy_level: str,
|
|
312
|
-
|
|
488
|
+
connection_encryption: Optional[str] = "NotEncrypted",
|
|
489
|
+
skip_test_connection: bool = False,
|
|
490
|
+
):
|
|
491
|
+
"""
|
|
492
|
+
Creates a virtual network gateway connection.
|
|
313
493
|
|
|
314
|
-
|
|
315
|
-
columns=[
|
|
316
|
-
"Connection ID",
|
|
317
|
-
"Connection Name",
|
|
318
|
-
"Gateway ID",
|
|
319
|
-
"Connectivity Type",
|
|
320
|
-
"Connection Type",
|
|
321
|
-
"Connection Path",
|
|
322
|
-
"Privacy Level",
|
|
323
|
-
"Credential Type",
|
|
324
|
-
"Single Sign On Type",
|
|
325
|
-
"Connection Encryption",
|
|
326
|
-
"Skip Test Connection",
|
|
327
|
-
]
|
|
328
|
-
)
|
|
494
|
+
This is a wrapper function for the following API: `Connections - Create Connection <https://learn.microsoft.com/rest/api/fabric/core/connections/create-connection>`_.
|
|
329
495
|
|
|
330
|
-
|
|
496
|
+
Parameters
|
|
497
|
+
----------
|
|
498
|
+
name : str
|
|
499
|
+
The name of the connection.
|
|
500
|
+
gateway : str | UUID
|
|
501
|
+
The name or Id of the gateway.
|
|
502
|
+
server_name : str
|
|
503
|
+
The name of the server.
|
|
504
|
+
database_name : str
|
|
505
|
+
The name of the database.
|
|
506
|
+
user_name : str
|
|
507
|
+
The username.
|
|
508
|
+
password : str
|
|
509
|
+
The password.
|
|
510
|
+
privacy_level : str
|
|
511
|
+
The `privacy level <https://learn.microsoft.com/rest/api/fabric/core/connections/create-connection?tabs=HTTP#privacylevel>`_ of the connection.
|
|
512
|
+
connection_encryption : str, default="NotEncrypted"
|
|
513
|
+
The connection encrpytion.
|
|
514
|
+
skip_test_connection: bool, default=False
|
|
515
|
+
If True, skips the test connection.
|
|
516
|
+
"""
|
|
517
|
+
|
|
518
|
+
gateway_id = _resolve_gateway_id(gateway)
|
|
331
519
|
|
|
332
520
|
request_body = {
|
|
333
|
-
"connectivityType": "
|
|
521
|
+
"connectivityType": "VirtualNetworkGateway",
|
|
334
522
|
"gatewayId": gateway_id,
|
|
335
|
-
"
|
|
523
|
+
"displayName": name,
|
|
336
524
|
"connectionDetails": {
|
|
337
525
|
"type": "SQL",
|
|
526
|
+
"creationMethod": "SQL",
|
|
338
527
|
"parameters": [
|
|
339
|
-
{
|
|
340
|
-
|
|
528
|
+
{
|
|
529
|
+
"dataType": "Text",
|
|
530
|
+
"name": "server",
|
|
531
|
+
"value": server_name,
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"dataType": "Text",
|
|
535
|
+
"name": "database",
|
|
536
|
+
"value": database_name,
|
|
537
|
+
},
|
|
341
538
|
],
|
|
342
539
|
},
|
|
343
540
|
"privacyLevel": privacy_level,
|
|
344
541
|
"credentialDetails": {
|
|
345
542
|
"singleSignOnType": "None",
|
|
346
|
-
"connectionEncryption":
|
|
347
|
-
"skipTestConnection":
|
|
543
|
+
"connectionEncryption": connection_encryption,
|
|
544
|
+
"skipTestConnection": skip_test_connection,
|
|
348
545
|
"credentials": {
|
|
349
546
|
"credentialType": "Basic",
|
|
350
547
|
"username": user_name,
|
|
@@ -353,30 +550,12 @@ def create_connection_vnet(
|
|
|
353
550
|
},
|
|
354
551
|
}
|
|
355
552
|
|
|
553
|
+
client = fabric.FabricRestClient()
|
|
356
554
|
response = client.post("/v1/connections", json=request_body)
|
|
357
555
|
|
|
358
|
-
if response.status_code !=
|
|
556
|
+
if response.status_code != 201:
|
|
359
557
|
raise FabricHTTPException(response)
|
|
360
|
-
o = response.json()
|
|
361
|
-
new_data = {
|
|
362
|
-
"Connection Id": o.get("id"),
|
|
363
|
-
"Connection Name": o.get("name"),
|
|
364
|
-
"Gateway ID": o.get("gatewayId"),
|
|
365
|
-
"Connectivity Type": o.get("connectivityType"),
|
|
366
|
-
"Connection Type": o.get("connectionDetails", {}).get("type"),
|
|
367
|
-
"Connection Path": o.get("connectionDetails", {}).get("path"),
|
|
368
|
-
"Privacy Level": o.get("privacyLevel"),
|
|
369
|
-
"Credential Type": o.get("credentialDetails", {}).get("credentialType"),
|
|
370
|
-
"Single Sign On Type": o.get("credentialDetails", {}).get("singleSignOnType"),
|
|
371
|
-
"Connection Encryption": o.get("credentialDetails", {}).get(
|
|
372
|
-
"connectionEncryption"
|
|
373
|
-
),
|
|
374
|
-
"Skip Test Connection": o.get("credentialDetails", {}).get(
|
|
375
|
-
"skipTestConnection"
|
|
376
|
-
),
|
|
377
|
-
}
|
|
378
|
-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
|
|
379
|
-
|
|
380
|
-
df["Skip Test Connection"] = df["Skip Test Connection"].astype(bool)
|
|
381
558
|
|
|
382
|
-
|
|
559
|
+
print(
|
|
560
|
+
f"{icons.green_dot} The '{name}' virtual network gateway connection has been created."
|
|
561
|
+
)
|
sempy_labs/_dataflows.py
CHANGED