msfabricpysdkcore 0.2.8__py3-none-any.whl → 0.2.10__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.
@@ -4,7 +4,7 @@ from msfabricpysdkcore.adminapi import FabricClientAdmin
4
4
  class Domain:
5
5
  """Class to represent a domain in Microsoft Fabric"""
6
6
 
7
- def __init__(self, id, display_name, description, parent_domain_id, contributors_scope, core_client: FabricClientAdmin):
7
+ def __init__(self, id, display_name, description, parent_domain_id, default_label_id, contributors_scope, core_client: FabricClientAdmin):
8
8
  """Constructor for the Domain class
9
9
 
10
10
  Args:
@@ -12,6 +12,7 @@ class Domain:
12
12
  display_name (str): The display name of the domain
13
13
  description (str): The description of the domain
14
14
  parent_domain_id (str): The parent domain ID of the domain
15
+ default_label_id (str): The default label ID of the domain
15
16
  contributors_scope (str): The contributors scope of the domain
16
17
  Returns:
17
18
  Domain: The Domain object created"""
@@ -20,6 +21,7 @@ class Domain:
20
21
  self.display_name = display_name
21
22
  self.description = description
22
23
  self.parent_domain_id = parent_domain_id
24
+ self.default_label_id = default_label_id
23
25
  self.contributors_scope = contributors_scope
24
26
 
25
27
  self.core_client = core_client
@@ -35,6 +37,7 @@ class Domain:
35
37
  'display_name': self.display_name,
36
38
  'description': self.description,
37
39
  'parent_domain_id': self.parent_domain_id,
40
+ 'default_label_id': self.default_label_id,
38
41
  'contributors_scope': self.contributors_scope
39
42
  }
40
43
  return json.dumps(dic, indent=2)
@@ -59,10 +62,20 @@ class Domain:
59
62
  else:
60
63
  dic["parent_domain_id"] = None
61
64
  if "contributors_scope" not in dic:
62
- dic["contributors_scope"] = dic["contributorsScope"]
65
+ if "contributorsScope" in dic:
66
+ dic["contributors_scope"] = dic["contributorsScope"]
67
+ else:
68
+ dic["contributors_scope"] = None
69
+
70
+ if "default_label_id" not in dic:
71
+ if "defaultLabelId" in dic:
72
+ dic["default_label_id"] = dic["defaultLabelId"]
73
+ else:
74
+ dic["default_label_id"] = None
75
+
63
76
  return Domain(id=dic['id'], display_name=dic['display_name'],
64
- description=dic['description'], parent_domain_id=dic['parent_domain_id'],
65
- contributors_scope=dic['contributors_scope'], core_client=core_client)
77
+ description=dic['description'], parent_domain_id=dic['parent_domain_id'], default_label_id=dic.get('default_label_id', None),
78
+ contributors_scope=dic.get('contributors_scope', None), core_client=core_client)
66
79
 
67
80
  def list_domain_workspaces(self, workspace_objects = False):
68
81
  """Method to list the workspaces in the domain
@@ -179,4 +192,22 @@ class Domain:
179
192
  Returns:
180
193
  int: The status code of the response
181
194
  """
182
- return self.core_client.unassign_domain_workspaces_by_ids(self.id, workspace_ids)
195
+ return self.core_client.unassign_domain_workspaces_by_ids(self.id, workspace_ids)
196
+
197
+ def list_role_assignments(self):
198
+ """Method to list role assignments in the domain
199
+
200
+ Returns:
201
+ list: The list of role assignments in the domain
202
+ """
203
+ return self.core_client.list_role_assignments(domain_id=self.id)
204
+
205
+ def sync_role_assignments_to_subdomains(self, role):
206
+ """Method to sync role assignments to subdomains
207
+
208
+ Args:
209
+ role (str): The role to sync
210
+ Returns:
211
+ int: The status code of the response
212
+ """
213
+ return self.core_client.sync_role_assignments_to_subdomains(self.id, role)
msfabricpysdkcore/item.py CHANGED
@@ -95,6 +95,11 @@ class Item:
95
95
  return self.core_client.create_shortcut(workspace_id=self.workspace_id, item_id=self.id,
96
96
  path=path, name=name, target=target)
97
97
 
98
+ def create_shortcuts_bulk(self, create_shortcut_requests):
99
+ """Create multiple shortcuts in the item"""
100
+ return self.core_client.create_shortcuts_bulk(workspace_id=self.workspace_id, item_id=self.id,
101
+ create_shortcut_requests=create_shortcut_requests)
102
+
98
103
  def delete_shortcut(self, path, name):
99
104
  """Delete the shortcut in the item"""
100
105
  return self.core_client.delete_shortcut(workspace_id=self.workspace_id, item_id=self.id,
@@ -32,4 +32,48 @@ class Lakehouse(Item):
32
32
 
33
33
  def get_livy_session(self, livy_id):
34
34
  """Get a livy session in the lakehouse"""
35
- return self.core_client.get_lakehouse_livy_session(self.workspace_id, self.id, livy_id)
35
+ return self.core_client.get_lakehouse_livy_session(self.workspace_id, self.id, livy_id)
36
+
37
+ def create_refresh_materialized_lake_view_schedule(self, enabled, configuration):
38
+ """Create a refresh materialized lake view schedule
39
+ Args:
40
+ enabled (bool): Whether the schedule is enabled
41
+ configuration (dict): The configuration of the schedule
42
+ Returns:
43
+ dict: The created schedule
44
+ """
45
+ return self.core_client.create_refresh_materialized_lake_view_schedule(workspace_id=self.workspace_id, lakehouse_id=self.id,
46
+ enabled=enabled, configuration=configuration)
47
+
48
+ def delete_refresh_materialized_lake_view_schedule(self, schedule_id):
49
+ """Delete a refresh materialized lake view schedule
50
+ Args:
51
+ schedule_id (str): The ID of the schedule
52
+ Returns:
53
+ int: The status code of the response
54
+ """
55
+ return self.core_client.delete_refresh_materialized_lake_view_schedule(workspace_id=self.workspace_id, lakehouse_id=self.id,
56
+ schedule_id=schedule_id)
57
+
58
+ def run_on_demand_refresh_materialized_lake_view(self, job_type="RefreshMaterializedLakeViews"):
59
+ """Run refresh materialized lake view
60
+ Args:
61
+ job_type (str): The job type
62
+ Returns:
63
+ dict: The operation result or response value
64
+ """
65
+ return self.core_client.run_on_demand_refresh_materialized_lake_view(workspace_id=self.workspace_id, lakehouse_id=self.id, job_type=job_type)
66
+
67
+ def update_refresh_materialized_lake_view_schedule(self, schedule_id, enabled, configuration):
68
+ """Update a refresh materialized lake view schedule
69
+ Args:
70
+ schedule_id (str): The ID of the schedule
71
+ schedule_id (str): The ID of the schedule
72
+ enabled (bool): Whether the schedule is enabled
73
+ configuration (dict): The configuration of the schedule
74
+ Returns:
75
+ dict: The updated schedule
76
+ """
77
+ return self.core_client.update_refresh_materialized_lake_view_schedule(workspace_id=self.workspace_id, lakehouse_id=self.id,
78
+ schedule_id=schedule_id, enabled=enabled,
79
+ configuration=configuration)
@@ -1,5 +1,25 @@
1
1
  from msfabricpysdkcore.item import Item
2
2
 
3
+ class AnomalyDetector(Item):
4
+ """Class to represent an anomaly detector in Microsoft Fabric"""
5
+
6
+ def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
7
+ super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
8
+
9
+ def from_dict(item_dict, core_client):
10
+ return AnomalyDetector(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
11
+ properties=item_dict.get('properties', None),
12
+ definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
13
+
14
+ def get_definition(self, format=None):
15
+ """Method to get the definition of the anomaly detector"""
16
+ return super().get_definition(type="anomalydetectors", format=format)
17
+
18
+ def update_definition(self, definition, update_metadata=None):
19
+ """Method to update the definition of the anomaly detector"""
20
+ return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="anomalydetectors",
21
+ update_metadata=update_metadata)
22
+
3
23
  class ApacheAirflowJob(Item):
4
24
  """Class to represent a ApacheAirflowJob in Microsoft Fabric"""
5
25
 
@@ -32,7 +52,10 @@ class Dataflow(Item):
32
52
  return Dataflow(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
33
53
  properties=item_dict.get('properties', None),
34
54
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
35
-
55
+
56
+ def discover_parameters(self):
57
+ return self.core_client.discover_dataflow_parameters(workspace_id=self.workspace_id, dataflow_id=self.id)
58
+
36
59
  class DataPipeline(Item):
37
60
  """Class to represent a spark job definition in Microsoft Fabric"""
38
61
 
@@ -158,6 +181,66 @@ class Warehouse(Item):
158
181
  properties=item_dict.get('properties', None),
159
182
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
160
183
 
184
+ def get_connection_string(self, guest_tenant_id = None, private_link_type = None):
185
+ return self.core_client.get_warehouse_connection_string(workspace_id=self.workspace_id, warehouse_id=self.id,
186
+ guest_tenant_id=guest_tenant_id, private_link_type=private_link_type)
187
+
188
+ def create_restore_point(self, display_name = None, description = None):
189
+ return self.core_client.create_warehouse_restore_point(workspace_id=self.workspace_id, warehouse_id=self.id,
190
+ display_name=display_name, description=description)
191
+
192
+ def delete_restore_point(self, restore_point_id):
193
+ return self.core_client.delete_warehouse_restore_point(workspace_id=self.workspace_id, warehouse_id=self.id,
194
+ restore_point_id=restore_point_id)
195
+
196
+ def get_restore_point(self, restore_point_id):
197
+ return self.core_client.get_warehouse_restore_point(workspace_id=self.workspace_id, warehouse_id=self.id,
198
+ restore_point_id=restore_point_id)
199
+
200
+ def list_restore_points(self):
201
+ return self.core_client.list_warehouse_restore_points(workspace_id=self.workspace_id, warehouse_id=self.id)
202
+
203
+ def restore_to_restore_point(self, restore_point_id, wait_for_completion = False):
204
+ return self.core_client.restore_warehouse_to_restore_point(workspace_id=self.workspace_id, warehouse_id=self.id,
205
+ restore_point_id=restore_point_id,
206
+ wait_for_completion=wait_for_completion)
207
+
208
+ def update_restore_point(self, restore_point_id, display_name = None, description = None):
209
+ return self.core_client.update_warehouse_restore_point(workspace_id=self.workspace_id, warehouse_id=self.id,
210
+ restore_point_id=restore_point_id,
211
+ display_name=display_name, description=description)
212
+
213
+ def get_sql_audit_settings(self):
214
+ """Get the audit settings of a warehouse
215
+ Returns:
216
+ dict: The audit settings of the warehouse
217
+ """
218
+
219
+ return self.core_client.get_warehouse_sql_audit_settings(self.workspace_id, self.id)
220
+
221
+ def set_warehouse_audit_actions_and_groups(self, set_audit_actions_and_groups_request):
222
+ """Set the audit actions and groups of a warehouse
223
+ Args:
224
+ set_audit_actions_and_groups_request (list): The list of audit actions and groups
225
+ Returns:
226
+ dict: The updated audit settings of the warehouse
227
+ """
228
+ return self.core_client.set_warehouse_audit_actions_and_groups(workspace_id=self.workspace_id,
229
+ warehouse_id=self.id,
230
+ set_audit_actions_and_groups_request=set_audit_actions_and_groups_request)
231
+
232
+ def update_warehouse_sql_audit_settings(self, retention_days, state):
233
+ """Update the audit settings of a warehouse
234
+ Args:
235
+ retention_days (int): The number of days to retain the audit logs
236
+ state (str): The state of the audit settings
237
+ Returns:
238
+ dict: The updated audit settings of the warehouse
239
+ """
240
+ return self.core_client.update_warehouse_sql_audit_settings(self.workspace_id, self.id,
241
+ retention_days, state)
242
+
243
+
161
244
  class WarehouseSnapshot(Item):
162
245
  """Class to represent a warehouse snapshot in Microsoft Fabric"""
163
246
 
@@ -296,6 +379,133 @@ class MLModel(Item):
296
379
  return MLModel(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
297
380
  properties=item_dict.get('properties', None),
298
381
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
382
+
383
+
384
+ def activate_ml_model_endpoint_version(self, name, wait_for_completion = False):
385
+ """Activate an ml model endpoint version
386
+ Args:
387
+ name (str): The name of the endpoint version
388
+ wait_for_completion (bool): Whether to wait for the operation to complete
389
+ Returns:
390
+ dict: The activated endpoint version
391
+ """
392
+
393
+ return self.core_client.activate_ml_model_endpoint_version(workspace_id=self.workspace_id, model_id=self.id,
394
+ name=name, wait_for_completion=wait_for_completion)
395
+
396
+ def deactivate_all_ml_model_endpoint_versions(self, wait_for_completion = False):
397
+ """Deactivate all ml model endpoint versions
398
+ Args:
399
+ wait_for_completion (bool): Whether to wait for the operation to complete
400
+ Returns:
401
+ Response: The operation result
402
+ """
403
+ return self.core_client.deactivate_all_ml_model_endpoint_versions(workspace_id=self.workspace_id, model_id=self.id,
404
+ wait_for_completion=wait_for_completion)
405
+
406
+ def deactivate_ml_model_endpoint_version(self, name, wait_for_completion = False):
407
+ """Deactivate an ml model endpoint version
408
+ Args:
409
+ name (str): The name of the endpoint version
410
+ wait_for_completion (bool): Whether to wait for the operation to complete
411
+ Returns:
412
+ Response: The operation result
413
+ """
414
+ return self.core_client.deactivate_ml_model_endpoint_version(workspace_id=self.workspace_id, model_id=self.id,
415
+ name=name, wait_for_completion=wait_for_completion)
416
+
417
+ def get_ml_model_endpoint(self):
418
+ """Get the ml model endpoint
419
+ Returns:
420
+ dict: The ml model endpoint
421
+ """
422
+ return self.core_client.get_ml_model_endpoint(workspace_id=self.workspace_id, model_id=self.id)
423
+
424
+ def get_ml_model_endpoint_version(self, name):
425
+ """Get an ml model endpoint version
426
+ Args:
427
+ name (str): The name of the endpoint version
428
+ Returns:
429
+ dict: The ml model endpoint version
430
+ """
431
+ return self.core_client.get_ml_model_endpoint_version(workspace_id=self.workspace_id, model_id=self.id, name=name)
432
+
433
+ def list_ml_model_endpoint_versions(self):
434
+ """List all ml model endpoint versions
435
+
436
+ Returns:
437
+ list: The list of ml model endpoint versions
438
+ """
439
+ return self.core_client.list_ml_model_endpoint_versions(workspace_id=self.workspace_id, model_id=self.id)
440
+
441
+ def score_ml_model_endpoint(self, inputs, format_type = None, orientation = None):
442
+ """Score an ml model endpoint
443
+ Args:
444
+ inputs (list): The inputs to score
445
+ format_type (str): The format type
446
+ orientation (str): The orientation
447
+ Returns:
448
+ dict: The scoring result
449
+ """
450
+ return self.core_client.score_ml_model_endpoint(workspace_id=self.workspace_id, model_id=self.id, inputs=inputs,
451
+ format_type=format_type, orientation=orientation)
452
+
453
+ def score_ml_model_endpoint_version(self, name, inputs, format_type = None, orientation = None):
454
+ """Score an ml model endpoint version
455
+ Args:
456
+ name (str): The name of the endpoint version
457
+ inputs (list): The inputs to score
458
+ format_type (str): The format type
459
+ orientation (str): The orientation
460
+ Returns:
461
+ dict: The scoring result
462
+ """
463
+ return self.core_client.score_ml_model_endpoint_version(workspace_id=self.workspace_id, model_id=self.id, name=name,
464
+ inputs=inputs, format_type=format_type, orientation=orientation)
465
+
466
+ def update_ml_model_endpoint(self, default_version_assignment_behavior, default_version_name):
467
+ """Update an ml model endpoint
468
+ Args:
469
+ default_version_assignment_behavior (str): The default version assignment behavior
470
+ default_version_name (str): The default version name
471
+ Returns:
472
+ dict: The updated endpoint
473
+ """
474
+ return self.core_client.update_ml_model_endpoint(workspace_id=self.workspace_id, model_id=self.id,
475
+ default_version_assignment_behavior=default_version_assignment_behavior,
476
+ default_version_name=default_version_name)
477
+
478
+ def update_ml_model_endpoint_version(self, name, scale_rule):
479
+ """Update an ml model endpoint version
480
+ Args:
481
+ name (str): The name of the endpoint version
482
+ scale_rule (str): The scale rule
483
+ Returns:
484
+ dict: The updated endpoint version
485
+ """
486
+ return self.core_client.update_ml_model_endpoint_version(workspace_id=self.workspace_id, model_id=self.id,
487
+ name=name, scale_rule=scale_rule)
488
+
489
+
490
+ class Map(Item):
491
+ """Class to represent a map in Microsoft Fabric"""
492
+
493
+ def __init__(self, id, display_name, type, workspace_id, core_client, properties = None, definition=None, description=""):
494
+ super().__init__(id, display_name, type, workspace_id, core_client, properties, definition, description)
495
+
496
+ def from_dict(item_dict, core_client):
497
+ return Map(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
498
+ properties=item_dict.get('properties', None),
499
+ definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
500
+
501
+ def get_definition(self, format=None):
502
+ """Method to get the definition of the map"""
503
+ return super().get_definition(type="Maps", format=format)
504
+
505
+ def update_definition(self, definition, update_metadata=None):
506
+ """Method to update the definition of the map"""
507
+ return self.core_client.update_item_definition(self.workspace_id, self.id, definition, type="Maps",
508
+ update_metadata=update_metadata)
299
509
 
300
510
  class MountedDataFactory(Item):
301
511
  """Class to represent a mounted data factory in Microsoft Fabric"""
@@ -392,6 +602,11 @@ class SemanticModel(Item):
392
602
  properties=item_dict.get('properties', None),
393
603
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""), core_client=core_client)
394
604
 
605
+ def bind_connection(self, connection_binding):
606
+ """Bind a connection to the semantic model"""
607
+ return self.core_client.bind_semantic_model_connection(workspace_id=self.workspace_id, semantic_model_id=self.id,
608
+ connection_binding=connection_binding)
609
+
395
610
  def get_definition(self, format=None):
396
611
  """Method to get the definition of the semantic model"""
397
612
  return super().get_definition(type="semanticModels", format=format)
@@ -0,0 +1,60 @@
1
+ import unittest
2
+ from dotenv import load_dotenv
3
+ from msfabricpysdkcore import FabricClientCore
4
+ from datetime import datetime
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.fcc = FabricClientCore()
12
+
13
+ def test_anomaly_detectors(self):
14
+ fcc = self.fcc
15
+
16
+ workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
17
+ item_id = "9d47b06e-d7c3-40a3-8e6d-6263fb1779a2"
18
+
19
+ anomaly_detectors = fcc.list_anomaly_detectors(workspace_id=workspace_id)
20
+ for anomaly_detector in anomaly_detectors:
21
+ if anomaly_detector.id != item_id:
22
+ resp = fcc.delete_anomaly_detector(workspace_id=workspace_id, anomaly_detector_id=anomaly_detector.id)
23
+ self.assertEqual(resp, 200)
24
+
25
+ anomaly_detector_definition = fcc.get_anomaly_detector_definition(workspace_id=workspace_id, anomaly_detector_id=item_id)
26
+ self.assertIn("definition", anomaly_detector_definition)
27
+ definition = anomaly_detector_definition["definition"]
28
+
29
+ date_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
30
+ date_str = date_str.replace(" ", "T").replace(":", "").replace("-", "")
31
+ date_str = f"anomalydetector{date_str}"
32
+
33
+ anomaly_detector_new = fcc.create_anomaly_detector(workspace_id=workspace_id, display_name=date_str, definition=definition)
34
+
35
+ self.assertEqual(anomaly_detector_new.display_name, date_str)
36
+
37
+ anomaly_detector_get = fcc.get_anomaly_detector(workspace_id=workspace_id, anomaly_detector_id=anomaly_detector_new.id)
38
+ self.assertEqual(anomaly_detector_get.display_name, date_str)
39
+
40
+ anomaly_detectors = fcc.list_anomaly_detectors(workspace_id=workspace_id)
41
+ self.assertEqual(len(anomaly_detectors), 2)
42
+
43
+ date_str_updated = date_str + "_updated"
44
+ anomaly_detector_updated = fcc.update_anomaly_detector(workspace_id=workspace_id, anomaly_detector_id=anomaly_detector_new.id, display_name=date_str_updated, return_item=True)
45
+ self.assertEqual(anomaly_detector_updated.display_name, date_str_updated)
46
+
47
+ anomaly_detector_updated = fcc.update_anomaly_detector_definition(workspace_id=workspace_id, anomaly_detector_id=anomaly_detector_new.id, definition=definition)
48
+ self.assertEqual(anomaly_detector_updated.status_code, 200)
49
+
50
+ for anomaly_detector in anomaly_detectors:
51
+ if anomaly_detector.id != item_id:
52
+ resp = fcc.delete_anomaly_detector(workspace_id=workspace_id, anomaly_detector_id=anomaly_detector.id)
53
+ self.assertEqual(resp, 200)
54
+
55
+
56
+
57
+
58
+
59
+
60
+
@@ -16,6 +16,19 @@ class TestFabricClientCore(unittest.TestCase):
16
16
  workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
17
17
  item_id = "8bc6f2f1-2ef9-4dc1-ab47-f55aa90e4088"
18
18
 
19
+
20
+ resp = fcc.discover_dataflow_parameters(workspace_id, item_id)
21
+
22
+ self.assertIsInstance(resp, list)
23
+ self.assertGreater(len(resp), 0)
24
+
25
+ for param in resp:
26
+ self.assertIn("type", param)
27
+ self.assertIn("name", param)
28
+ self.assertIn("description", param)
29
+ self.assertIn("isRequired", param)
30
+ self.assertIn("defaultValue", param)
31
+
19
32
  dataflows = fcc.list_dataflows(workspace_id=workspace_id)
20
33
  for dataflow in dataflows:
21
34
  if dataflow.id != item_id:
@@ -0,0 +1,60 @@
1
+ import unittest
2
+ from dotenv import load_dotenv
3
+ from msfabricpysdkcore import FabricClientCore
4
+ from datetime import datetime
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.fcc = FabricClientCore()
12
+
13
+ def test_maps(self):
14
+ fcc = self.fcc
15
+
16
+ workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
17
+ item_id = "9dcf0419-0f08-4cf4-b282-7a0272d02ff0"
18
+
19
+ maps = fcc.list_maps(workspace_id=workspace_id)
20
+ for map in maps:
21
+ if map.id != item_id:
22
+ resp = fcc.delete_map(workspace_id=workspace_id, map_id=map.id)
23
+ self.assertEqual(resp, 200)
24
+
25
+ map_definition = fcc.get_map_definition(workspace_id=workspace_id, map_id=item_id)
26
+ self.assertIn("definition", map_definition)
27
+ definition = map_definition["definition"]
28
+
29
+ date_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
30
+ date_str = date_str.replace(" ", "T").replace(":", "").replace("-", "")
31
+ date_str = f"map{date_str}"
32
+
33
+ map_new = fcc.create_map(workspace_id=workspace_id, display_name=date_str, definition=definition)
34
+
35
+ self.assertEqual(map_new.display_name, date_str)
36
+
37
+ map_get = fcc.get_map(workspace_id=workspace_id, map_id=map_new.id)
38
+ self.assertEqual(map_get.display_name, date_str)
39
+
40
+ maps = fcc.list_maps(workspace_id=workspace_id)
41
+ self.assertEqual(len(maps), 2)
42
+
43
+ date_str_updated = date_str + "_updated"
44
+ map_updated = fcc.update_map(workspace_id=workspace_id, map_id=map_new.id, display_name=date_str_updated, return_item=True)
45
+ self.assertEqual(map_updated.display_name, date_str_updated)
46
+
47
+ map_updated = fcc.update_map_definition(workspace_id=workspace_id, map_id=map_new.id, definition=definition)
48
+ self.assertEqual(map_updated.status_code, 200)
49
+
50
+ for map in maps:
51
+ if map.id != item_id:
52
+ resp = fcc.delete_map(workspace_id=workspace_id, map_id=map.id)
53
+ self.assertEqual(resp, 200)
54
+
55
+
56
+
57
+
58
+
59
+
60
+
@@ -16,13 +16,19 @@ class TestFabricClientCore(unittest.TestCase):
16
16
  workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
17
17
  item_id = "d21012a1-f306-4cf1-a21b-f8ae55c17642"
18
18
 
19
- response = fcc.refresh_sql_endpoint_metadata(workspace_id=workspace_id, sql_endpoint_id=item_id, wait_for_completion=False)
20
- self.assertIn(response.status_code, [200, 202])
21
-
22
-
23
-
24
-
19
+ audit_settings = fcc.get_sql_endpoint_audit_settings(workspace_id=workspace_id, sql_endpoint_id=item_id)
25
20
 
21
+ self.assertIn("state", audit_settings)
22
+ self.assertIn("retentionDays", audit_settings)
23
+ self.assertIn("auditActionsAndGroups", audit_settings)
26
24
 
25
+ respo = fcc.update_sql_endpoint_audit_settings(workspace_id=workspace_id, sql_endpoint_id=item_id,
26
+ state="Enabled", retention_days=10)
27
+ self.assertEqual(respo.status_code, 200)
27
28
 
29
+ actionsandgroups = ["SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP"]
28
30
 
31
+ respo = fcc.set_sql_endpoint_audit_actions_and_groups(workspace_id=workspace_id, sql_endpoint_id=item_id,
32
+ set_audit_actions_and_groups_request=actionsandgroups)
33
+ self.assertEqual(respo.status_code, 200)
34
+
@@ -44,6 +44,61 @@ class TestFabricClientCore(unittest.TestCase):
44
44
 
45
45
  status_code = fc.delete_warehouse(workspace_id, warehouse.id)
46
46
  self.assertEqual(status_code, 200)
47
+
48
+ def test_other_warehouse_stuff(self):
49
+ fcc = self.fc
50
+ workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
51
+ item_id = "e4655180-815b-4339-984b-213a23524685"
52
+
53
+ resp = fcc.get_warehouse_connection_string(workspace_id, item_id)
54
+
55
+ self.assertIn('connectionString', resp)
56
+ self.assertIsInstance(resp['connectionString'], str)
57
+
58
+
59
+ resp = fcc.list_warehouse_restore_points(workspace_id, item_id)
60
+ self.assertGreater(len(resp), 0)
61
+ for rp in resp:
62
+ if rp['id'] != "1760452482000" and rp['creationMode'] != 'SystemCreated':
63
+ rp_to_delete = rp['id']
64
+ break
65
+
66
+ resp = fcc.create_warehouse_restore_point(workspace_id, item_id, "my second restore point", wait_for_completion=False)
67
+
68
+ self.assertIn(resp.status_code, [200, 201, 202])
69
+
70
+ resp = fcc.get_warehouse_restore_point(workspace_id, item_id, "1760452482000")
71
+ self.assertEqual(resp, {
72
+ 'id': '1760452482000',
73
+ 'displayName': 'my first restore point',
74
+ 'description': '',
75
+ })
76
+
77
+ resp = fcc.update_warehouse_restore_point(workspace_id, item_id, rp_to_delete, description="updated description")
78
+
79
+ self.assertEqual(resp['description'], "updated description")
80
+ resp = fcc.delete_warehouse_restore_point(workspace_id, item_id, rp_to_delete)
81
+ self.assertEqual(resp.status_code, 200)
82
+
83
+ resp = fcc.restore_warehouse_to_restore_point(workspace_id, item_id, "1760452482000")
84
+ self.assertIn(resp.status_code, [200, 201, 202])
85
+
86
+ audit_settings = fcc.get_warehouse_sql_audit_settings(workspace_id=workspace_id, warehouse_id=item_id)
87
+
88
+ self.assertIn("state", audit_settings)
89
+ self.assertIn("retentionDays", audit_settings)
90
+ self.assertIn("auditActionsAndGroups", audit_settings)
91
+
92
+ respo = fcc.update_warehouse_sql_audit_settings(workspace_id=workspace_id, warehouse_id=item_id,
93
+ state="Enabled", retention_days=10)
94
+ self.assertEqual(respo.status_code, 200)
95
+
96
+ actionsandgroups = ["SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP"]
97
+
98
+ respo = fcc.set_warehouse_audit_actions_and_groups(workspace_id=workspace_id, warehouse_id=item_id,
99
+ set_audit_actions_and_groups_request=actionsandgroups)
100
+ self.assertEqual(respo.status_code, 200)
101
+
47
102
 
48
103
 
49
104
  if __name__ == "__main__":
@@ -154,6 +154,18 @@ class TestFabricClientCore(unittest.TestCase):
154
154
  self.assertIsNotNone(cap.sku)
155
155
  self.assertIsNotNone(cap.region)
156
156
 
157
+ def test_network_communication_policy(self):
158
+ fcc = self.fc
159
+ workspace_id = "5902cade-5261-4afa-96f4-266167ac81a1"
160
+ policy = fcc.get_network_communication_policy(workspace_id=workspace_id)
161
+ self.assertIn('inbound', policy)
162
+ self.assertIn('outbound', policy)
163
+
164
+ inbound = {'publicAccessRules': {'defaultAction': 'Allow'}}
165
+ outbound = {'publicAccessRules': {'defaultAction': 'Allow'}}
166
+
167
+ resp = fcc.set_network_communication_policy(workspace_id=workspace_id, inbound=inbound, outbound=outbound)
168
+ self.assertEqual(resp.status_code, 200)
157
169
 
158
170
  if __name__ == "__main__":
159
171
  unittest.main()