msfabricpysdkcore 0.1.8__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.
Files changed (49) hide show
  1. msfabricpysdkcore/adminapi.py +178 -12
  2. msfabricpysdkcore/coreapi.py +1479 -99
  3. msfabricpysdkcore/item.py +45 -6
  4. msfabricpysdkcore/job_instance.py +2 -1
  5. msfabricpysdkcore/otheritems.py +159 -10
  6. msfabricpysdkcore/tests/__init__.py +0 -0
  7. msfabricpysdkcore/tests/test_admin_apis.py +174 -0
  8. msfabricpysdkcore/tests/test_connection.py +111 -0
  9. msfabricpysdkcore/tests/test_datapipelines.py +45 -0
  10. msfabricpysdkcore/tests/test_deployment_pipeline.py +63 -0
  11. msfabricpysdkcore/tests/test_domains.py +126 -0
  12. msfabricpysdkcore/tests/test_environments.py +114 -0
  13. msfabricpysdkcore/tests/test_evenhouses.py +56 -0
  14. msfabricpysdkcore/tests/test_evenstreams.py +52 -0
  15. msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
  16. msfabricpysdkcore/tests/test_fabric_azure_client.py +80 -0
  17. msfabricpysdkcore/tests/test_gateways.py +99 -0
  18. msfabricpysdkcore/tests/test_git.py +66 -0
  19. msfabricpysdkcore/tests/test_graphqlapi.py +44 -0
  20. msfabricpysdkcore/tests/test_items.py +97 -0
  21. msfabricpysdkcore/tests/test_jobs.py +96 -0
  22. msfabricpysdkcore/tests/test_kql_dashboards.py +63 -0
  23. msfabricpysdkcore/tests/test_kql_queryset.py +64 -0
  24. msfabricpysdkcore/tests/test_kqldatabases.py +56 -0
  25. msfabricpysdkcore/tests/test_lakehouse.py +93 -0
  26. msfabricpysdkcore/tests/test_managed_private_endpoints.py +61 -0
  27. msfabricpysdkcore/tests/test_mirroreddatabases.py +80 -0
  28. msfabricpysdkcore/tests/test_ml_experiments.py +47 -0
  29. msfabricpysdkcore/tests/test_ml_models.py +47 -0
  30. msfabricpysdkcore/tests/test_mounted_adf.py +64 -0
  31. msfabricpysdkcore/tests/test_notebooks.py +57 -0
  32. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +63 -0
  33. msfabricpysdkcore/tests/test_other_items.py +45 -0
  34. msfabricpysdkcore/tests/test_reflex.py +57 -0
  35. msfabricpysdkcore/tests/test_reports.py +56 -0
  36. msfabricpysdkcore/tests/test_semantic_model.py +56 -0
  37. msfabricpysdkcore/tests/test_shortcuts.py +60 -0
  38. msfabricpysdkcore/tests/test_spark.py +91 -0
  39. msfabricpysdkcore/tests/test_sparkjobdefinition.py +55 -0
  40. msfabricpysdkcore/tests/test_sqldatabases.py +45 -0
  41. msfabricpysdkcore/tests/test_warehouses.py +50 -0
  42. msfabricpysdkcore/tests/test_workspaces_capacities.py +159 -0
  43. msfabricpysdkcore/workspace.py +295 -16
  44. {msfabricpysdkcore-0.1.8.dist-info → msfabricpysdkcore-0.2.2.dist-info}/METADATA +261 -16
  45. msfabricpysdkcore-0.2.2.dist-info/RECORD +65 -0
  46. {msfabricpysdkcore-0.1.8.dist-info → msfabricpysdkcore-0.2.2.dist-info}/WHEEL +1 -1
  47. msfabricpysdkcore-0.1.8.dist-info/RECORD +0 -28
  48. {msfabricpysdkcore-0.1.8.dist-info → msfabricpysdkcore-0.2.2.dist-info}/LICENSE +0 -0
  49. {msfabricpysdkcore-0.1.8.dist-info → msfabricpysdkcore-0.2.2.dist-info}/top_level.txt +0 -0
msfabricpysdkcore/item.py CHANGED
@@ -45,15 +45,18 @@ class Item:
45
45
 
46
46
  return self.core_client.delete_item(self.workspace_id, self.id, type=type)
47
47
 
48
- def get_definition(self, type = None, format = None):
48
+ def get_definition(self, type = None, format = None, **kwargs):
49
49
  """Get the definition of the item"""
50
- resp_dict = self.core_client.get_item_definition(self.workspace_id, self.id, type=type, format=format)
50
+ resp_dict = self.core_client.get_item_definition(self.workspace_id, self.id, type=type, format=format, **kwargs)
51
51
 
52
52
  self.definition = resp_dict['definition']
53
53
  return resp_dict
54
54
 
55
+ def list_connections(self):
56
+ """List connections of an item in a workspace"""
57
+ return self.core_client.list_item_connections(workspace_id=self.workspace_id, item_id=self.id)
55
58
 
56
- def update(self, display_name = None, description = None, type = None, return_item="Default"):
59
+ def update(self, display_name = None, description = None, type = None, return_item=False):
57
60
  """Update the item"""
58
61
 
59
62
  resp_dict = self.core_client.update_item(workspace_id=self.workspace_id, item_id=self.id,
@@ -66,10 +69,12 @@ class Item:
66
69
 
67
70
  return resp_dict
68
71
 
69
- def update_definition(self, definition, type = None):
72
+ def update_definition(self, definition, type = None, **kwargs):
70
73
  """Update the item definition"""
74
+ if not type:
75
+ type = self.type
71
76
  response = self.core_client.update_item_definition(workspace_id=self.workspace_id, item_id=self.id,
72
- definition=definition, type=type)
77
+ definition=definition, type=type, **kwargs)
73
78
 
74
79
  self.definition = definition
75
80
  return response
@@ -100,15 +105,49 @@ class Item:
100
105
  """Cancel a job instance ofjob the item"""
101
106
  return self.core_client.cancel_item_job_instance(workspace_id=self.workspace_id, item_id=self.id,
102
107
  job_instance_id=job_instance_id)
103
-
108
+
109
+ def create_item_schedule(self, job_type, configuration, enabled):
110
+ """Create a schedule for the job instance"""
111
+ return self.core_client.create_item_schedule(workspace_id=self.workspace_id,
112
+ item_id=self.id,
113
+ job_type=job_type,
114
+ configuration=configuration,
115
+ enabled=enabled)
116
+
104
117
  def get_item_job_instance(self, job_instance_id):
105
118
  """Get the job instance of the item"""
106
119
  return self.core_client.get_item_job_instance(workspace_id=self.workspace_id, item_id=self.id,
107
120
  job_instance_id=job_instance_id)
121
+ def get_item_schedule(self, job_type, schedule_id):
122
+ """Get the schedule for the job instance"""
123
+ return self.core_client.get_item_schedule(workspace_id=self.workspace_id,
124
+ item_id=self.id,
125
+ job_type=job_type,
126
+ schedule_id=schedule_id)
127
+
128
+ def list_item_job_instances(self):
129
+ """List all job instances for the job instance"""
130
+ return self.core_client.list_item_job_instances(workspace_id=self.workspace_id,
131
+ item_id=self.id)
132
+
133
+ def list_item_schedules(self, job_type):
134
+ """List all schedules for the job instance"""
135
+ return self.core_client.list_item_schedules(workspace_id=self.workspace_id,
136
+ item_id=self.id,
137
+ job_type=job_type)
108
138
 
109
139
  def run_on_demand_item_job(self, job_type, execution_data = None):
110
140
  return self.core_client.run_on_demand_item_job(workspace_id=self.workspace_id, item_id=self.id,
111
141
  job_type=job_type, execution_data=execution_data)
142
+
143
+ def update_item_schedule(self, job_type, schedule_id, configuration, enabled):
144
+ """Update the schedule for the job instance"""
145
+ return self.core_client.update_item_schedule(workspace_id=self.workspace_id,
146
+ item_id=self.id,
147
+ job_type=job_type,
148
+ schedule_id=schedule_id,
149
+ configuration=configuration,
150
+ enabled=enabled)
112
151
 
113
152
 
114
153
  # External Data Shares
@@ -51,4 +51,5 @@ class JobInstance:
51
51
  """Cancel the job instance"""
52
52
  return self.core_client.cancel_item_job_instance(workspace_id=self.workspace_id,
53
53
  item_id=self.item_id,
54
- job_instance_id=self.id)
54
+ job_instance_id=self.id)
55
+
@@ -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"""
@@ -40,9 +48,7 @@ class SparkJobDefinition(Item):
40
48
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
41
49
 
42
50
  def get_definition(self, format=None):
43
- resp_dict = self.core_client.get_spark_job_definition_definition(self.workspace_id, self.id, format=format)
44
- self.definition = resp_dict['definition']
45
- return resp_dict
51
+ return super().get_definition(type="sparkJobDefinitions", format=format)
46
52
 
47
53
  def update_definition(self, definition):
48
54
  return self.core_client.update_spark_job_definition_definition(self.workspace_id, self.id, definition)
@@ -62,6 +68,25 @@ class Warehouse(Item):
62
68
  properties=item_dict.get('properties', None),
63
69
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
64
70
 
71
+ class KQLDashboard(Item):
72
+ """Class to represent a kql dashboard in Microsoft Fabric"""
73
+
74
+ def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
75
+ super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
76
+
77
+ def from_dict(item_dict, core_client):
78
+ return KQLDashboard(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
79
+ properties=item_dict.get('properties', None),
80
+ definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
81
+
82
+ def get_definition(self, format=None):
83
+ """Method to get the definition of the kql dashboard"""
84
+ return super().get_definition(type="kqlDashboards", format=format)
85
+
86
+ def update_definition(self, definition):
87
+ """Method to update the definition of the kql dashboard"""
88
+ return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="kqlDashboards")
89
+
65
90
  class KQLDatabase(Item):
66
91
  """Class to represent a kql database in Microsoft Fabric"""
67
92
 
@@ -73,6 +98,14 @@ class KQLDatabase(Item):
73
98
  properties=item_dict.get('properties', None),
74
99
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
75
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
+
76
109
  class KQLQueryset(Item):
77
110
  """Class to represent a kql database in Microsoft Fabric"""
78
111
 
@@ -83,6 +116,17 @@ class KQLQueryset(Item):
83
116
  return KQLQueryset(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
84
117
  properties=item_dict.get('properties', None),
85
118
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
119
+
120
+ def get_definition(self, format=None):
121
+ """Method to get the definition of the kql queryset"""
122
+ return super().get_definition(type="kqlQuerysets", format=format)
123
+
124
+ def update_definition(self, definition, update_metadata=None):
125
+ """Method to update the definition of the kql queryset"""
126
+ return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="kqlQuerysets",
127
+ update_metadata=update_metadata)
128
+
129
+
86
130
 
87
131
  class Eventstream(Item):
88
132
  """Class to represent a eventstream in Microsoft Fabric"""
@@ -94,7 +138,60 @@ class Eventstream(Item):
94
138
  return Eventstream(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
95
139
  properties=item_dict.get('properties', None),
96
140
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
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)
97
160
 
161
+ class MirroredDatabase(Item):
162
+ """Class to represent a mirrored database in Microsoft Fabric"""
163
+
164
+ def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
165
+ super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
166
+
167
+ def from_dict(item_dict, core_client):
168
+ return MirroredDatabase(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
169
+ properties=item_dict.get('properties', None),
170
+ definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
171
+
172
+ def get_definition(self):
173
+ """Method to get the definition of the mirrored database"""
174
+ return super().get_definition(type="mirroredDatabases")
175
+
176
+ def update_definition(self, definition):
177
+ """Method to update the definition of the mirrored database"""
178
+ return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="mirroredDatabases")
179
+
180
+ def get_mirrored_database_definition(self, mirrored_database_id):
181
+ return self.core_client.get_mirrored_database_definition(workspace_id=self.id,
182
+ mirrored_database_id=mirrored_database_id)
183
+ def get_mirroring_status(self):
184
+ return self.core_client.get_mirroring_status(workspace_id=self.workspace_id, mirrored_database_id=self.id)
185
+
186
+ def get_tables_mirroring_status(self):
187
+ return self.core_client.get_tables_mirroring_status(workspace_id=self.workspace_id, mirrored_database_id=self.id)
188
+
189
+ def start_mirroring(self):
190
+ return self.core_client.start_mirroring(workspace_id=self.workspace_id, mirrored_database_id=self.id)
191
+
192
+ def stop_mirroring(self):
193
+ return self.core_client.stop_mirroring(workspace_id=self.workspace_id, mirrored_database_id=self.id)
194
+
98
195
  class MLExperiment(Item):
99
196
  """Class to represent a ml experiment in Microsoft Fabric"""
100
197
 
@@ -117,6 +214,25 @@ class MLModel(Item):
117
214
  properties=item_dict.get('properties', None),
118
215
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
119
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
+
120
236
  class Notebook(Item):
121
237
  """Class to represent a notebook in Microsoft Fabric"""
122
238
 
@@ -130,14 +246,31 @@ class Notebook(Item):
130
246
 
131
247
  def get_definition(self, format=None):
132
248
  """Method to get the definition of the notebook"""
133
- definition = self.core_client.get_item_definition(self.workspace_id, self.id, type="notebooks", format=format)
134
- self.definition = definition
135
- return definition
249
+ return super().get_definition(type="notebooks", format=format)
136
250
 
137
251
  def update_definition(self, definition):
138
252
  """Method to update the definition of the notebook"""
139
253
  return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="notebooks")
140
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
+
141
274
  class Report(Item):
142
275
  """Class to represent a report in Microsoft Fabric"""
143
276
 
@@ -151,8 +284,7 @@ class Report(Item):
151
284
 
152
285
  def get_definition(self, type=None, format=None):
153
286
  """Method to get the definition of the report"""
154
- self.definition = self.core_client.get_item_definition(self.workspace_id, self.id, type="reports", format=format)
155
- return self.definition
287
+ return super().get_definition(type="reports", format=format)
156
288
 
157
289
  def update_definition(self, definition):
158
290
  """Method to update the definition of the report"""
@@ -171,13 +303,23 @@ class SemanticModel(Item):
171
303
 
172
304
  def get_definition(self, format=None):
173
305
  """Method to get the definition of the semantic model"""
174
- self.definition = self.core_client.get_item_definition(self.workspace_id, self.id, type="semanticModels", format=format)
175
- return self.definition
306
+ return super().get_definition(type="semanticModels", format=format)
176
307
 
177
308
  def update_definition(self, definition):
178
309
  """Method to update the definition of the semantic model"""
179
310
  return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="semanticModels")
180
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
+
181
323
  class DataPipeline(Item):
182
324
  """Class to represent a spark job definition in Microsoft Fabric"""
183
325
 
@@ -189,6 +331,13 @@ class DataPipeline(Item):
189
331
  properties=item_dict.get('properties', None),
190
332
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
191
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
+
192
341
  def run_on_demand_item_job(self, execution_data=None):
193
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)
194
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
+