msfabricpysdkcore 0.2.1__py3-none-any.whl → 0.2.2__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.
- msfabricpysdkcore/adminapi.py +142 -2
- msfabricpysdkcore/coreapi.py +475 -8
- msfabricpysdkcore/item.py +6 -4
- msfabricpysdkcore/otheritems.py +93 -0
- msfabricpysdkcore/tests/__init__.py +0 -0
- msfabricpysdkcore/tests/test_admin_apis.py +174 -0
- msfabricpysdkcore/tests/test_connection.py +111 -0
- msfabricpysdkcore/tests/test_datapipelines.py +45 -0
- msfabricpysdkcore/tests/test_deployment_pipeline.py +63 -0
- msfabricpysdkcore/tests/test_domains.py +126 -0
- msfabricpysdkcore/tests/test_environments.py +114 -0
- msfabricpysdkcore/tests/test_evenhouses.py +56 -0
- msfabricpysdkcore/tests/test_evenstreams.py +52 -0
- msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
- msfabricpysdkcore/tests/test_fabric_azure_client.py +80 -0
- msfabricpysdkcore/tests/test_gateways.py +99 -0
- msfabricpysdkcore/tests/test_git.py +66 -0
- msfabricpysdkcore/tests/test_graphqlapi.py +44 -0
- msfabricpysdkcore/tests/test_items.py +97 -0
- msfabricpysdkcore/tests/test_jobs.py +96 -0
- msfabricpysdkcore/tests/test_kql_dashboards.py +63 -0
- msfabricpysdkcore/tests/test_kql_queryset.py +64 -0
- msfabricpysdkcore/tests/test_kqldatabases.py +56 -0
- msfabricpysdkcore/tests/test_lakehouse.py +93 -0
- msfabricpysdkcore/tests/test_managed_private_endpoints.py +61 -0
- msfabricpysdkcore/tests/test_mirroreddatabases.py +80 -0
- msfabricpysdkcore/tests/test_ml_experiments.py +47 -0
- msfabricpysdkcore/tests/test_ml_models.py +47 -0
- msfabricpysdkcore/tests/test_mounted_adf.py +64 -0
- msfabricpysdkcore/tests/test_notebooks.py +57 -0
- msfabricpysdkcore/tests/test_one_lake_data_access_security.py +63 -0
- msfabricpysdkcore/tests/test_other_items.py +45 -0
- msfabricpysdkcore/tests/test_reflex.py +57 -0
- msfabricpysdkcore/tests/test_reports.py +56 -0
- msfabricpysdkcore/tests/test_semantic_model.py +56 -0
- msfabricpysdkcore/tests/test_shortcuts.py +60 -0
- msfabricpysdkcore/tests/test_spark.py +91 -0
- msfabricpysdkcore/tests/test_sparkjobdefinition.py +55 -0
- msfabricpysdkcore/tests/test_sqldatabases.py +45 -0
- msfabricpysdkcore/tests/test_warehouses.py +50 -0
- msfabricpysdkcore/tests/test_workspaces_capacities.py +159 -0
- msfabricpysdkcore/workspace.py +149 -5
- {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/METADATA +31 -5
- msfabricpysdkcore-0.2.2.dist-info/RECORD +65 -0
- {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/WHEEL +1 -1
- msfabricpysdkcore-0.2.1.dist-info/RECORD +0 -28
- {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/LICENSE +0 -0
- {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/top_level.txt +0 -0
msfabricpysdkcore/otheritems.py
CHANGED
@@ -20,6 +20,14 @@ class Eventhouse(Item):
|
|
20
20
|
properties=item_dict.get('properties', None),
|
21
21
|
description=item_dict.get('description', ""), core_client=core_client)
|
22
22
|
|
23
|
+
def get_definition(self, type=None, format=None):
|
24
|
+
"""Method to get the definition of the eventhouse"""
|
25
|
+
return super().get_definition(type="eventhouses", format=format)
|
26
|
+
|
27
|
+
def update_definition(self, definition):
|
28
|
+
"""Method to update the definition of the eventhouse"""
|
29
|
+
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="eventhouses")
|
30
|
+
|
23
31
|
def create_kql_database(self, display_name = None, description= None):
|
24
32
|
from msfabricpysdkcore.coreapi import FabricClientCore
|
25
33
|
"""Method to create a kql database in the eventhouse"""
|
@@ -90,6 +98,14 @@ class KQLDatabase(Item):
|
|
90
98
|
properties=item_dict.get('properties', None),
|
91
99
|
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
92
100
|
|
101
|
+
def get_definition(self, type=None, format=None):
|
102
|
+
"""Method to get the definition of the kql database"""
|
103
|
+
return super().get_definition(type="kqlDatabases", format=format)
|
104
|
+
|
105
|
+
def update_definition(self, definition):
|
106
|
+
"""Method to update the definition of the kql database"""
|
107
|
+
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="kqlDatabases")
|
108
|
+
|
93
109
|
class KQLQueryset(Item):
|
94
110
|
"""Class to represent a kql database in Microsoft Fabric"""
|
95
111
|
|
@@ -109,6 +125,8 @@ class KQLQueryset(Item):
|
|
109
125
|
"""Method to update the definition of the kql queryset"""
|
110
126
|
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="kqlQuerysets",
|
111
127
|
update_metadata=update_metadata)
|
128
|
+
|
129
|
+
|
112
130
|
|
113
131
|
class Eventstream(Item):
|
114
132
|
"""Class to represent a eventstream in Microsoft Fabric"""
|
@@ -121,6 +139,25 @@ class Eventstream(Item):
|
|
121
139
|
properties=item_dict.get('properties', None),
|
122
140
|
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
123
141
|
|
142
|
+
def get_definition(self, type=None, format=None):
|
143
|
+
"""Method to get the definition of the eventstream"""
|
144
|
+
return super().get_definition(type="eventstreams", format=format)
|
145
|
+
|
146
|
+
def update_definition(self, definition):
|
147
|
+
"""Method to update the definition of the eventstream"""
|
148
|
+
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="eventstreams")
|
149
|
+
|
150
|
+
class GraphQLApi(Item):
|
151
|
+
"""Class to represent a graphql api in Microsoft Fabric"""
|
152
|
+
|
153
|
+
def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
|
154
|
+
super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
|
155
|
+
|
156
|
+
def from_dict(item_dict, core_client):
|
157
|
+
return GraphQLApi(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
|
158
|
+
properties=item_dict.get('properties', None),
|
159
|
+
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
160
|
+
|
124
161
|
class MirroredDatabase(Item):
|
125
162
|
"""Class to represent a mirrored database in Microsoft Fabric"""
|
126
163
|
|
@@ -177,6 +214,25 @@ class MLModel(Item):
|
|
177
214
|
properties=item_dict.get('properties', None),
|
178
215
|
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
179
216
|
|
217
|
+
class MountedDataFactory(Item):
|
218
|
+
"""Class to represent a mounted data factory in Microsoft Fabric"""
|
219
|
+
|
220
|
+
def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
|
221
|
+
super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
|
222
|
+
|
223
|
+
def from_dict(item_dict, core_client):
|
224
|
+
return MountedDataFactory(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
|
225
|
+
properties=item_dict.get('properties', None),
|
226
|
+
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
227
|
+
|
228
|
+
def get_definition(self, type=None, format=None):
|
229
|
+
"""Method to get the definition of the mountedDataFactory"""
|
230
|
+
return super().get_definition(type="mountedDataFactories", format=format)
|
231
|
+
|
232
|
+
def update_definition(self, definition):
|
233
|
+
"""Method to update the definition of the mountedDataFactory"""
|
234
|
+
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="mountedDataFactories")
|
235
|
+
|
180
236
|
class Notebook(Item):
|
181
237
|
"""Class to represent a notebook in Microsoft Fabric"""
|
182
238
|
|
@@ -196,6 +252,25 @@ class Notebook(Item):
|
|
196
252
|
"""Method to update the definition of the notebook"""
|
197
253
|
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="notebooks")
|
198
254
|
|
255
|
+
class Reflex(Item):
|
256
|
+
"""Class to represent a reflex in Microsoft Fabric"""
|
257
|
+
|
258
|
+
def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
|
259
|
+
super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
|
260
|
+
|
261
|
+
def from_dict(item_dict, core_client):
|
262
|
+
return Reflex(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
|
263
|
+
properties=item_dict.get('properties', None),
|
264
|
+
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
265
|
+
|
266
|
+
def get_definition(self, type=None, format=None):
|
267
|
+
"""Method to get the definition of the reflex"""
|
268
|
+
return super().get_definition(type="reflexes", format=format)
|
269
|
+
|
270
|
+
def update_definition(self, definition):
|
271
|
+
"""Method to update the definition of the reflex"""
|
272
|
+
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="reflexes")
|
273
|
+
|
199
274
|
class Report(Item):
|
200
275
|
"""Class to represent a report in Microsoft Fabric"""
|
201
276
|
|
@@ -234,6 +309,17 @@ class SemanticModel(Item):
|
|
234
309
|
"""Method to update the definition of the semantic model"""
|
235
310
|
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="semanticModels")
|
236
311
|
|
312
|
+
class SQLDatabase(Item):
|
313
|
+
"""Class to represent a sql database in Microsoft Fabric"""
|
314
|
+
|
315
|
+
def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
|
316
|
+
super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
|
317
|
+
|
318
|
+
def from_dict(item_dict, core_client):
|
319
|
+
return SQLDatabase(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
|
320
|
+
properties=item_dict.get('properties', None),
|
321
|
+
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
322
|
+
|
237
323
|
class DataPipeline(Item):
|
238
324
|
"""Class to represent a spark job definition in Microsoft Fabric"""
|
239
325
|
|
@@ -245,6 +331,13 @@ class DataPipeline(Item):
|
|
245
331
|
properties=item_dict.get('properties', None),
|
246
332
|
definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
|
247
333
|
|
334
|
+
def get_definition(self, type=None, format=None, **kwargs):
|
335
|
+
return super().get_definition(type="dataPipelines", format=format, **kwargs)
|
336
|
+
|
337
|
+
def update_definition(self, definition):
|
338
|
+
"""Method to update the definition of the dataPipeline"""
|
339
|
+
return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="dataPipelines")
|
340
|
+
|
248
341
|
def run_on_demand_item_job(self, execution_data=None):
|
249
342
|
return self.core_client.run_on_demand_item_job(workspace_id=self.workspace_id, item_id=self.id, job_type="Pipeline", execution_data=execution_data)
|
250
343
|
|
File without changes
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientAdmin
|
4
|
+
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fca = FabricClientAdmin()
|
12
|
+
|
13
|
+
def test_admin_api(self):
|
14
|
+
fca = self.fca
|
15
|
+
|
16
|
+
user_id = '1dc64c6e-7a10-4ea9-8488-85d0739a377d'
|
17
|
+
|
18
|
+
# List workspaces
|
19
|
+
ws = fca.list_workspaces(name="testitems")[0]
|
20
|
+
|
21
|
+
self.assertEqual(ws.name, "testitems")
|
22
|
+
|
23
|
+
# Get workspace
|
24
|
+
ws_clone = fca.get_workspace(workspace_id=ws.id)
|
25
|
+
|
26
|
+
self.assertEqual(ws.id, ws_clone.id)
|
27
|
+
|
28
|
+
# Discover git connections
|
29
|
+
|
30
|
+
git_connections = fca.discover_git_connections()
|
31
|
+
|
32
|
+
self.assertGreater(len(git_connections), 0)
|
33
|
+
|
34
|
+
git_conn = [g for g in git_connections if g['workspaceId'] == '63aa9e13-4912-4abe-9156-8a56e565b7a3'][0]
|
35
|
+
self.assertEqual(git_conn['gitProviderDetails']['ownerName'], 'DaSenf1860')
|
36
|
+
|
37
|
+
# List workspace access details
|
38
|
+
|
39
|
+
ws_access = fca.list_workspace_access_details(ws.id)
|
40
|
+
principials = ws_access["accessDetails"]
|
41
|
+
principials_ids = [p["principal"]["id"] for p in principials]
|
42
|
+
self.assertIn(user_id, principials_ids)
|
43
|
+
|
44
|
+
# Get access entities
|
45
|
+
|
46
|
+
access_entities = fca.list_access_entities(user_id, type="Notebook")
|
47
|
+
self.assertGreater(len(access_entities), 0)
|
48
|
+
|
49
|
+
# List tenant settings
|
50
|
+
|
51
|
+
settings = fca.list_tenant_settings()
|
52
|
+
monitoring_setting = [setting for setting in settings if setting['settingName'] == 'PlatformMonitoringTenantSetting'][0]
|
53
|
+
|
54
|
+
self.assertIsNotNone(monitoring_setting)
|
55
|
+
|
56
|
+
# List tenant settings capacity overrides
|
57
|
+
|
58
|
+
settings_capa = fca.list_capacities_tenant_settings_overrides()
|
59
|
+
setting = [s for s in settings_capa if s['id'] == '9E7E757D-D567-4FB3-BC4F-D230AABF2A00']
|
60
|
+
|
61
|
+
self.assertGreater(len(setting), 0)
|
62
|
+
|
63
|
+
|
64
|
+
# List tenant settings overrides on domains
|
65
|
+
|
66
|
+
domain_overrides = fca.list_domain_tenant_settings_overrides()
|
67
|
+
len(domain_overrides) == 0
|
68
|
+
self.assertEqual(len(domain_overrides), 0)
|
69
|
+
|
70
|
+
# List tenant settings overrides on workspaces
|
71
|
+
|
72
|
+
workspace_overrides = fca.list_workspace_tenant_settings_overrides()
|
73
|
+
wover = [w for w in workspace_overrides if w["id"] == "192333b2-5f89-4da5-ae69-64a3ee4c649c"]
|
74
|
+
self.assertIsNotNone(wover)
|
75
|
+
|
76
|
+
# Update tenant settings
|
77
|
+
|
78
|
+
if monitoring_setting["enabled"] == False:
|
79
|
+
changed_settings = fca.update_tenant_setting("PlatformMonitoringTenantSetting", enabled=True)
|
80
|
+
"tenantSettings" in changed_settings and len(changed_settings["tenantSettings"]) > 0 and changed_settings["tenantSettings"][0]["enabled"] == True
|
81
|
+
else:
|
82
|
+
changed_settings = fca.update_tenant_setting("PlatformMonitoringTenantSetting", enabled=False)
|
83
|
+
"tenantSettings" in changed_settings and len(changed_settings["tenantSettings"]) > 0 and changed_settings["tenantSettings"][0]["enabled"] == False
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
# Update tenant settings capacity overrides
|
88
|
+
|
89
|
+
|
90
|
+
enabledSecurityGroups = [{'graphId': '73ba0244-b701-41ed-96d9-79917b74f5f8', 'name': 'fabricadmins'}]
|
91
|
+
excludedSecurityGroups = [{'graphId': '16450670-829a-4b70-b80e-6524eea067cb', 'name': 'fabricuser'}]
|
92
|
+
feedback = fca.update_capacity_tenant_setting_override("9e7e757d-d567-4fb3-bc4f-d230aabf2a00",
|
93
|
+
"PlatformMonitoringTenantSetting",
|
94
|
+
enabled=True,
|
95
|
+
excluded_security_groups=excludedSecurityGroups,
|
96
|
+
enabled_security_groups=enabledSecurityGroups)
|
97
|
+
|
98
|
+
|
99
|
+
# List tenant settings overrides by capacity id
|
100
|
+
|
101
|
+
settings_capa = fca.list_capacity_tenant_settings_overrides_by_capacity_id("9e7e757d-d567-4fb3-bc4f-d230aabf2a00")
|
102
|
+
setting = [s for s in settings_capa if s['settingName'] == 'PlatformMonitoringTenantSetting']
|
103
|
+
|
104
|
+
self.assertGreater(len(setting), 0)
|
105
|
+
|
106
|
+
# Update tenant settings capacity overrides
|
107
|
+
|
108
|
+
status_code = fca.delete_capacity_tenant_setting_override("9e7e757d-d567-4fb3-bc4f-d230aabf2a00", "PlatformMonitoringTenantSetting")
|
109
|
+
|
110
|
+
self.assertEqual(status_code, 200)
|
111
|
+
|
112
|
+
settings = [set for set in fca.list_capacity_tenant_settings_overrides_by_capacity_id("9e7e757d-d567-4fb3-bc4f-d230aabf2a00") if set["settingName"] == "PlatformMonitoringTenantSetting"]
|
113
|
+
|
114
|
+
self.assertEqual(len(settings), 0)
|
115
|
+
|
116
|
+
self.assertIn("overrides", feedback)
|
117
|
+
self.assertGreater(len(feedback["overrides"]), 0)
|
118
|
+
self.assertEqual(feedback["overrides"][0]["enabled"], True)
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
# List items
|
127
|
+
|
128
|
+
item_list = fca.list_items(workspace_id=ws.id)
|
129
|
+
self.assertGreater(len(item_list), 0)
|
130
|
+
|
131
|
+
# Get item
|
132
|
+
|
133
|
+
item = fca.get_item(workspace_id=ws.id, item_id=item_list[0].id)
|
134
|
+
self.assertEqual(item.id, item_list[0].id)
|
135
|
+
|
136
|
+
# Get item access details
|
137
|
+
|
138
|
+
item_access = fca.list_item_access_details(workspace_id=ws.id, item_id=item_list[0].id)
|
139
|
+
principials = item_access["accessDetails"]
|
140
|
+
|
141
|
+
principials_ids = [p["principal"]["id"] for p in principials]
|
142
|
+
|
143
|
+
self.assertIn(user_id, principials_ids)
|
144
|
+
|
145
|
+
|
146
|
+
def test_labels(self):
|
147
|
+
|
148
|
+
fca = self.fca
|
149
|
+
|
150
|
+
items = [{"id": "9cdd3192-bcd0-4cbe-b945-29f5964e7ab7", "type": "Lakehouse"}]
|
151
|
+
label_id = "defa4170-0d19-0005-0007-bc88714345d2"
|
152
|
+
resp = fca.bulk_set_labels(items=items, label_id=label_id)
|
153
|
+
self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
|
154
|
+
resp = fca.bulk_remove_labels(items=items)
|
155
|
+
self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
|
156
|
+
|
157
|
+
def test_admin_external_data_shares(self):
|
158
|
+
|
159
|
+
fca = self.fca
|
160
|
+
|
161
|
+
data_shares = fca.list_external_data_shares()
|
162
|
+
ws_id = "63aa9e13-4912-4abe-9156-8a56e565b7a3"
|
163
|
+
|
164
|
+
data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
|
165
|
+
|
166
|
+
self.assertGreater(len(data_shares), 0)
|
167
|
+
# fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
168
|
+
# item_id = data_shares[0]['itemId'],
|
169
|
+
# workspace_id = data_shares[0]['workspaceId'])
|
170
|
+
# data_shares = fca.list_external_data_shares()
|
171
|
+
|
172
|
+
# data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
|
173
|
+
|
174
|
+
# self.assertEqual(data_shares[0]['status'], 'Revoked')
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import unittest
|
2
|
+
from datetime import datetime
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
from time import sleep
|
5
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
6
|
+
|
7
|
+
load_dotenv()
|
8
|
+
|
9
|
+
class TestFabricClientCore(unittest.TestCase):
|
10
|
+
|
11
|
+
def __init__(self, *args, **kwargs):
|
12
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
+
#load_dotenv()
|
14
|
+
self.fc = FabricClientCore()
|
15
|
+
|
16
|
+
def test_connection(self):
|
17
|
+
|
18
|
+
datetime_str = datetime.now().strftime("%Y%m%H%M%S")
|
19
|
+
datetime_str
|
20
|
+
fc = self.fc
|
21
|
+
|
22
|
+
# display_name = "ContosoCloudConnection" + datetime_str
|
23
|
+
|
24
|
+
# cr = {"connectivityType": "ShareableCloud",
|
25
|
+
# "displayName": display_name,
|
26
|
+
# "connectionDetails": {
|
27
|
+
# 'type': "SQL",
|
28
|
+
# 'creationMethod': 'SQL',
|
29
|
+
# "parameters": [
|
30
|
+
# {
|
31
|
+
# "dataType": "Text",
|
32
|
+
# "name": "server",
|
33
|
+
# "value": "dfsdemo.database.windows.net"
|
34
|
+
# },
|
35
|
+
# {
|
36
|
+
# "dataType": "Text",
|
37
|
+
# "name": "database",
|
38
|
+
# "value": "dfsdemo"
|
39
|
+
# }
|
40
|
+
# ]},
|
41
|
+
# 'privacyLevel': 'Organizational',
|
42
|
+
# 'credentialDetails': {'credentials':{'credentialType': 'Basic',
|
43
|
+
# 'userName': 'new_user',
|
44
|
+
# 'password': 'StrongPassword123!'},
|
45
|
+
# 'singleSignOnType': 'None',
|
46
|
+
# 'connectionEncryption': 'NotEncrypted',
|
47
|
+
# 'skipTestConnection': False}
|
48
|
+
# }
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
# connection = fc.create_connection(connection_request=cr)
|
53
|
+
# self.assertIsNotNone(connection)
|
54
|
+
# self.assertIn('id', connection)
|
55
|
+
# self.assertIn('displayName', connection)
|
56
|
+
# self.assertEqual(connection['displayName'], display_name)
|
57
|
+
|
58
|
+
# connection2 = fc.get_connection(connection_name=display_name)
|
59
|
+
# self.assertEqual(connection['id'], connection2['id'])
|
60
|
+
|
61
|
+
|
62
|
+
# connections = fc.list_connections()
|
63
|
+
# connection_names = [conn['displayName'] for conn in connections]
|
64
|
+
# self.assertIn(display_name, connection_names)
|
65
|
+
|
66
|
+
# id = connection['id']
|
67
|
+
|
68
|
+
# role_assis = fc.list_connection_role_assignments(connection_id=id)
|
69
|
+
# self.assertEqual(len(role_assis), 1)
|
70
|
+
|
71
|
+
# principal = {"id" : "755f273c-98f8-408c-a886-691794938bd8",
|
72
|
+
# "type" : "ServicePrincipal"}
|
73
|
+
|
74
|
+
# add_role_assi = fc.add_connection_role_assignment(connection_id=id, principal=principal, role='User')
|
75
|
+
# self.assertIsNotNone(add_role_assi)
|
76
|
+
# self.assertIn('id', add_role_assi)
|
77
|
+
# role_assi_id = add_role_assi['id']
|
78
|
+
|
79
|
+
# role_assis = fc.list_connection_role_assignments(connection_id=id)
|
80
|
+
# self.assertEqual(len(role_assis), 2)
|
81
|
+
|
82
|
+
# role_assi = fc.get_connection_role_assignment(connection_id=id,
|
83
|
+
# connection_role_assignment_id=role_assi_id)
|
84
|
+
# self.assertEqual(role_assi['id'], role_assi_id)
|
85
|
+
|
86
|
+
# role_assi = fc.update_connection_role_assignment(connection_id=id,
|
87
|
+
# connection_role_assignment_id=role_assi_id,
|
88
|
+
# role='UserWithReshare')
|
89
|
+
# self.assertEqual(role_assi['role'], 'UserWithReshare')
|
90
|
+
|
91
|
+
# status_code = fc.delete_connection_role_assignment(connection_id=id,
|
92
|
+
# connection_role_assignment_id=role_assi_id)
|
93
|
+
# self.assertEqual(status_code, 200)
|
94
|
+
|
95
|
+
|
96
|
+
# cr = {
|
97
|
+
# "connectivityType": "ShareableCloud",
|
98
|
+
# "displayName": f"sqlserver{datetime_str}"
|
99
|
+
# }
|
100
|
+
|
101
|
+
# updated_connection = fc.update_connection(connection_id=id, connection_request=cr)
|
102
|
+
# self.assertIsNotNone(updated_connection)
|
103
|
+
|
104
|
+
|
105
|
+
# connection2 = fc.get_connection(connection_id=id)
|
106
|
+
# self.assertEqual(connection['id'], connection2['id'])
|
107
|
+
# self.assertEqual(connection2['displayName'], f"sqlserver{datetime_str}")
|
108
|
+
|
109
|
+
# status_code = fc.delete_connection(connection_id=id)
|
110
|
+
# self.assertEqual(status_code, 200)
|
111
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import unittest
|
2
|
+
from datetime import datetime
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
from time import sleep
|
5
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
6
|
+
|
7
|
+
load_dotenv()
|
8
|
+
|
9
|
+
class TestFabricClientCore(unittest.TestCase):
|
10
|
+
|
11
|
+
def __init__(self, *args, **kwargs):
|
12
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
+
#load_dotenv()
|
14
|
+
self.fc = FabricClientCore()
|
15
|
+
|
16
|
+
def test_data_pipelines(self):
|
17
|
+
|
18
|
+
fc = self.fc
|
19
|
+
workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
|
20
|
+
datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
21
|
+
pipeline_name = f"pipeline_{datetime_str}"
|
22
|
+
|
23
|
+
dp = fc.create_data_pipeline(workspace_id, display_name=pipeline_name, description="asda")
|
24
|
+
dp.update_definition(dp.definition)
|
25
|
+
|
26
|
+
dps = fc.list_data_pipelines(workspace_id)
|
27
|
+
dp_names = [dp.display_name for dp in dps]
|
28
|
+
self.assertGreater(len(dps), 0)
|
29
|
+
self.assertIn(pipeline_name, dp_names)
|
30
|
+
|
31
|
+
self.assertEqual(dp.display_name, pipeline_name)
|
32
|
+
pipeline_name2 = f"pipeline_{datetime_str}_2"
|
33
|
+
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name=pipeline_name2, return_item=True)
|
34
|
+
|
35
|
+
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
36
|
+
self.assertEqual(dp.display_name, pipeline_name2)
|
37
|
+
self.assertEqual(dp.id, dp2.id)
|
38
|
+
|
39
|
+
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name=pipeline_name, return_item=True)
|
40
|
+
|
41
|
+
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
42
|
+
self.assertEqual(dp.display_name, pipeline_name)
|
43
|
+
self.assertEqual(dp.id, dp2.id)
|
44
|
+
status_code = fc.delete_data_pipeline(workspace_id, dp.id)
|
45
|
+
self.assertEqual(status_code, 200)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import unittest
|
2
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
|
8
|
+
class TestFabricClientCore(unittest.TestCase):
|
9
|
+
|
10
|
+
def __init__(self, *args, **kwargs):
|
11
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
12
|
+
self.fc = FabricClientCore()
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
def test_spark_workspace_custom_pools(self):
|
17
|
+
fc = self.fc
|
18
|
+
|
19
|
+
dep_pipes = fc.list_deployment_pipelines()
|
20
|
+
|
21
|
+
self.assertGreater(len(dep_pipes), 0)
|
22
|
+
|
23
|
+
self.assertIn("sdkpipe", [pipe.display_name for pipe in dep_pipes])
|
24
|
+
|
25
|
+
for pipe in dep_pipes:
|
26
|
+
if pipe.display_name == 'sdkpipe':
|
27
|
+
pipe_id = pipe.id
|
28
|
+
break
|
29
|
+
|
30
|
+
pipe = fc.get_deployment_pipeline(pipe_id)
|
31
|
+
|
32
|
+
self.assertEqual(pipe.display_name, 'sdkpipe')
|
33
|
+
self.assertEqual(pipe.id, pipe_id)
|
34
|
+
|
35
|
+
stages = fc.list_deployment_pipeline_stages(pipe_id)
|
36
|
+
|
37
|
+
self.assertGreater(len(stages), 0)
|
38
|
+
names = [stage.display_name for stage in stages]
|
39
|
+
self.assertIn("Development", names)
|
40
|
+
self.assertIn("Production", names)
|
41
|
+
|
42
|
+
dev_stage = [stage for stage in stages if stage.display_name == "Development"][0]
|
43
|
+
prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
|
44
|
+
|
45
|
+
items = fc.list_deployment_pipeline_stages_items(deployment_pipeline_id=pipe_id, stage_id=dev_stage.id)
|
46
|
+
|
47
|
+
self.assertGreater(len(items), 0)
|
48
|
+
self.assertIn("cicdlakehouse", [item["itemDisplayName"] for item in items])
|
49
|
+
|
50
|
+
items = [item for item in dev_stage.list_items() if item["itemDisplayName"] == 'cicdlakehouse']
|
51
|
+
item = items[0]
|
52
|
+
item = {"sourceItemId": item["itemId"],
|
53
|
+
"itemType": item["itemType"]}
|
54
|
+
items = [item]
|
55
|
+
|
56
|
+
response = fc.deploy_stage_content(deployment_pipeline_id=pipe_id, source_stage_id=dev_stage.id,target_stage_id=prod_stage.id, items=items)
|
57
|
+
|
58
|
+
self.assertEqual(response["status"], "Succeeded")
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from datetime import datetime
|
4
|
+
from msfabricpysdkcore import FabricClientCore, FabricClientAdmin
|
5
|
+
|
6
|
+
|
7
|
+
load_dotenv()
|
8
|
+
|
9
|
+
class TestFabricClientCore(unittest.TestCase):
|
10
|
+
|
11
|
+
def __init__(self, *args, **kwargs):
|
12
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
+
|
14
|
+
|
15
|
+
def test_domains(self):
|
16
|
+
fcc = FabricClientCore()
|
17
|
+
fca = FabricClientAdmin()
|
18
|
+
|
19
|
+
ws = fcc.get_workspace_by_name("sdktestdomains")
|
20
|
+
cap = fcc.get_capacity(capacity_id=ws.capacity_id)
|
21
|
+
principal = {'id': '1dc64c6e-7a10-4ea9-8488-85d0739a377d', 'type': 'User'}
|
22
|
+
|
23
|
+
# Delete if exists
|
24
|
+
try:
|
25
|
+
domain = fca.get_domain_by_name("sdktestdomains")
|
26
|
+
domain.delete()
|
27
|
+
except:
|
28
|
+
pass
|
29
|
+
try:
|
30
|
+
domain = fca.get_domain_by_name("sdktestdomains2")
|
31
|
+
domain.delete()
|
32
|
+
except:
|
33
|
+
pass
|
34
|
+
|
35
|
+
# Create domain
|
36
|
+
domain_name = "sdktestdomains" + datetime.now().strftime("%Y%m%d%H%M%S")
|
37
|
+
domain = fca.create_domain(display_name=domain_name)
|
38
|
+
self.assertIsNotNone(domain.id)
|
39
|
+
self.assertEqual(domain.display_name, domain_name)
|
40
|
+
|
41
|
+
# Get domain by name
|
42
|
+
domain_clone = fca.get_domain_by_name(domain_name)
|
43
|
+
self.assertIsNotNone(domain_clone.id)
|
44
|
+
self.assertEqual(domain_clone.display_name, domain_name)
|
45
|
+
|
46
|
+
# Get domain by id
|
47
|
+
domain_clone = fca.get_domain_by_id(domain.id)
|
48
|
+
self.assertIsNotNone(domain_clone.id)
|
49
|
+
self.assertEqual(domain_clone.display_name, domain_name)
|
50
|
+
|
51
|
+
# List domains
|
52
|
+
domains = fca.list_domains()
|
53
|
+
self.assertGreater(len(domains), 0)
|
54
|
+
domains_ids = [d.id for d in domains]
|
55
|
+
self.assertIn(domain.id, domains_ids)
|
56
|
+
|
57
|
+
# Update domain
|
58
|
+
domain_new_name = f"{domain_name}2"
|
59
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name, return_item=True)
|
60
|
+
self.assertEqual(domain_clone.display_name, domain_new_name)
|
61
|
+
|
62
|
+
# Assign domain workspaces by Ids
|
63
|
+
status_code = fca.assign_domain_workspaces_by_ids(domain.id, [ws.id])
|
64
|
+
self.assertEqual(status_code, 200)
|
65
|
+
|
66
|
+
# List domain workspaces
|
67
|
+
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
68
|
+
self.assertGreater(len(workspaces), 0)
|
69
|
+
workspaces_ids = [w.id for w in workspaces]
|
70
|
+
self.assertIn(ws.id, workspaces_ids)
|
71
|
+
|
72
|
+
# Unassign domain workspaces by ids
|
73
|
+
status_code = fca.unassign_domain_workspaces_by_ids(domain.id, [ws.id])
|
74
|
+
self.assertEqual(status_code, 200)
|
75
|
+
|
76
|
+
workspaces = fca.list_domain_workspaces(domain.id)
|
77
|
+
self.assertEqual(len(workspaces), 0)
|
78
|
+
|
79
|
+
# Assign domain workspaces by capacities
|
80
|
+
status_code = fca.assign_domain_workspaces_by_capacities(domain.id, [cap.id])
|
81
|
+
self.assertEqual(status_code, 202)
|
82
|
+
|
83
|
+
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
84
|
+
self.assertGreater(len(workspaces), 0)
|
85
|
+
workspaces_ids = [w.id for w in workspaces]
|
86
|
+
self.assertIn(ws.id, workspaces_ids)
|
87
|
+
|
88
|
+
# Unassign all domain workspaces
|
89
|
+
status_code = fca.unassign_all_domain_workspaces(domain.id)
|
90
|
+
self.assertEqual(status_code, 200)
|
91
|
+
|
92
|
+
workspaces = fca.list_domain_workspaces(domain.id)
|
93
|
+
self.assertEqual(len(workspaces), 0)
|
94
|
+
|
95
|
+
# Assign domain workspaces by principals
|
96
|
+
status_code = fca.assign_domains_workspaces_by_principals(domain.id, [principal], wait_for_completion=True)
|
97
|
+
|
98
|
+
self.assertEqual(status_code, 202)
|
99
|
+
|
100
|
+
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
101
|
+
self.assertGreater(len(workspaces), 0)
|
102
|
+
workspaces_ids = [w.id for w in workspaces]
|
103
|
+
self.assertIn(ws.id, workspaces_ids)
|
104
|
+
|
105
|
+
# Role assignments bulk assign
|
106
|
+
|
107
|
+
principal_2 = {'id': 'e0505016-ef55-4ca7-b106-e085cc201823', 'type': 'User'}
|
108
|
+
principals = [principal, principal_2]
|
109
|
+
|
110
|
+
status_code = fca.role_assignments_bulk_assign(domain.id, "Contributors", principals)
|
111
|
+
|
112
|
+
self.assertEqual(status_code, 200)
|
113
|
+
|
114
|
+
# Role assignments bulk unassign
|
115
|
+
status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [principal_2])
|
116
|
+
|
117
|
+
self.assertEqual(status_code, 200)
|
118
|
+
|
119
|
+
# Delete domain
|
120
|
+
status_code = fca.delete_domain(domain.id)
|
121
|
+
|
122
|
+
self.assertEqual(status_code, 200)
|
123
|
+
|
124
|
+
domains = fca.list_domains()
|
125
|
+
domains_ids = [d.id for d in domains]
|
126
|
+
self.assertNotIn(domain.id, domains_ids)
|