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.
Files changed (48) hide show
  1. msfabricpysdkcore/adminapi.py +142 -2
  2. msfabricpysdkcore/coreapi.py +475 -8
  3. msfabricpysdkcore/item.py +6 -4
  4. msfabricpysdkcore/otheritems.py +93 -0
  5. msfabricpysdkcore/tests/__init__.py +0 -0
  6. msfabricpysdkcore/tests/test_admin_apis.py +174 -0
  7. msfabricpysdkcore/tests/test_connection.py +111 -0
  8. msfabricpysdkcore/tests/test_datapipelines.py +45 -0
  9. msfabricpysdkcore/tests/test_deployment_pipeline.py +63 -0
  10. msfabricpysdkcore/tests/test_domains.py +126 -0
  11. msfabricpysdkcore/tests/test_environments.py +114 -0
  12. msfabricpysdkcore/tests/test_evenhouses.py +56 -0
  13. msfabricpysdkcore/tests/test_evenstreams.py +52 -0
  14. msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
  15. msfabricpysdkcore/tests/test_fabric_azure_client.py +80 -0
  16. msfabricpysdkcore/tests/test_gateways.py +99 -0
  17. msfabricpysdkcore/tests/test_git.py +66 -0
  18. msfabricpysdkcore/tests/test_graphqlapi.py +44 -0
  19. msfabricpysdkcore/tests/test_items.py +97 -0
  20. msfabricpysdkcore/tests/test_jobs.py +96 -0
  21. msfabricpysdkcore/tests/test_kql_dashboards.py +63 -0
  22. msfabricpysdkcore/tests/test_kql_queryset.py +64 -0
  23. msfabricpysdkcore/tests/test_kqldatabases.py +56 -0
  24. msfabricpysdkcore/tests/test_lakehouse.py +93 -0
  25. msfabricpysdkcore/tests/test_managed_private_endpoints.py +61 -0
  26. msfabricpysdkcore/tests/test_mirroreddatabases.py +80 -0
  27. msfabricpysdkcore/tests/test_ml_experiments.py +47 -0
  28. msfabricpysdkcore/tests/test_ml_models.py +47 -0
  29. msfabricpysdkcore/tests/test_mounted_adf.py +64 -0
  30. msfabricpysdkcore/tests/test_notebooks.py +57 -0
  31. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +63 -0
  32. msfabricpysdkcore/tests/test_other_items.py +45 -0
  33. msfabricpysdkcore/tests/test_reflex.py +57 -0
  34. msfabricpysdkcore/tests/test_reports.py +56 -0
  35. msfabricpysdkcore/tests/test_semantic_model.py +56 -0
  36. msfabricpysdkcore/tests/test_shortcuts.py +60 -0
  37. msfabricpysdkcore/tests/test_spark.py +91 -0
  38. msfabricpysdkcore/tests/test_sparkjobdefinition.py +55 -0
  39. msfabricpysdkcore/tests/test_sqldatabases.py +45 -0
  40. msfabricpysdkcore/tests/test_warehouses.py +50 -0
  41. msfabricpysdkcore/tests/test_workspaces_capacities.py +159 -0
  42. msfabricpysdkcore/workspace.py +149 -5
  43. {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/METADATA +31 -5
  44. msfabricpysdkcore-0.2.2.dist-info/RECORD +65 -0
  45. {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/WHEEL +1 -1
  46. msfabricpysdkcore-0.2.1.dist-info/RECORD +0 -28
  47. {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/LICENSE +0 -0
  48. {msfabricpysdkcore-0.2.1.dist-info → msfabricpysdkcore-0.2.2.dist-info}/top_level.txt +0 -0
@@ -939,17 +939,21 @@ class FabricClientCore(FabricClient):
939
939
  "environments",
940
940
  "eventhouses",
941
941
  "eventstreams",
942
+ "GraphQLApis",
942
943
  "kqlDatabases",
943
944
  "kqlDashboards",
944
945
  "kqlQuerysets",
945
946
  "lakehouses",
946
947
  "mirroredDatabases",
947
948
  "mlExperiments",
948
- "mlModels",
949
- "notebooks",
949
+ "mlModels",
950
+ "mountedDataFactories",
951
+ "notebooks",
952
+ "reflexes",
950
953
  "reports",
951
954
  "semanticModels",
952
- "sparkJobDefinitions",
955
+ "sparkJobDefinitions",
956
+ "SQLDatabases",
953
957
  "warehouses"]:
954
958
 
955
959
  if type == "kqlDatabases":
@@ -975,6 +979,7 @@ class FabricClientCore(FabricClient):
975
979
  "environments": "Environment",
976
980
  "eventhouses": "Eventhouse",
977
981
  "eventstreams": "Eventstream",
982
+ "GraphQLApis": "GraphQLApi",
978
983
  "kqlDashboards": "KQLDashboard",
979
984
  "kqlDatabases": "KQLDatabase",
980
985
  "kqlQuerysets": "KQLQueryset",
@@ -982,10 +987,13 @@ class FabricClientCore(FabricClient):
982
987
  "mirroredDatabases": "MirroredDatabase",
983
988
  "mlExperiments": "MLExperiment",
984
989
  "mlModels": "MLModel",
985
- "notebooks": "Notebook",
990
+ "mountedDataFactories": "MountedDataFactory",
991
+ "notebooks": "Notebook",
992
+ "reflexes": "Reflex",
986
993
  "reports": "Report",
987
994
  "semanticModels": "SemanticModel",
988
- "sparkJobDefinitions": "SparkJobDefinition",
995
+ "sparkJobDefinitions": "SparkJobDefinition",
996
+ "SQLDatabases": "SQLDatabase",
989
997
  "warehouses": "Warehouse"
990
998
  }
991
999
 
@@ -1588,6 +1596,24 @@ class FabricClientCore(FabricClient):
1588
1596
  shortcut['itemId'] = item_id
1589
1597
  return [OneLakeShortcut.from_dict(shortcut, core_client=self) for shortcut in shortcuts]
1590
1598
 
1599
+
1600
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/onelake/resetShortcutCache
1601
+ def reset_shortcut_cache(self, workspace_id, wait_for_completion = False):
1602
+ """Reset the shortcut cache
1603
+
1604
+ Args:
1605
+ workspace_id (str): The ID of the workspace
1606
+
1607
+ Returns:
1608
+ int: The status code of the response
1609
+ """
1610
+
1611
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/onelake/resetShortcutCache"
1612
+ response = self.calling_routine(url=url, operation="POST", response_codes=[200, 202, 429], error_message="Error resetting shortcut cache",
1613
+ return_format="response", wait_for_completion = wait_for_completion)
1614
+
1615
+ return response.status_code
1616
+
1591
1617
  ### Workspaces
1592
1618
 
1593
1619
  def add_workspace_role_assignment(self, workspace_id, role, principal):
@@ -2243,8 +2269,23 @@ class FabricClientCore(FabricClient):
2243
2269
 
2244
2270
  item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2245
2271
  error_message="Error getting eventhouse", return_format="json")
2246
- return Eventhouse.from_dict(item_dict, core_client=self)
2272
+ ev = Eventhouse.from_dict(item_dict, core_client=self)
2273
+ ev.get_definition()
2274
+ return ev
2247
2275
 
2276
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventhouses/{eventhouseId}/getDefinition
2277
+
2278
+ def get_eventhouse_definition(self, workspace_id, eventhouse_id, format = None):
2279
+ """Get the definition of an eventhouse
2280
+ Args:
2281
+ workspace_id (str): The ID of the workspace
2282
+ eventhouse_id (str): The ID of the eventhouse
2283
+ format (str): The format of the definition
2284
+ Returns:
2285
+ dict: The eventhouse definition
2286
+ """
2287
+ return self.get_item_definition(workspace_id, eventhouse_id, type="eventhouses", format=format)
2288
+
2248
2289
  def list_eventhouses(self, workspace_id, with_properties = False):
2249
2290
  """List eventhouses in a workspace
2250
2291
  Args:
@@ -2268,6 +2309,19 @@ class FabricClientCore(FabricClient):
2268
2309
  return self.update_item(workspace_id=workspace_id, item_id=eventhouse_id,
2269
2310
  display_name=display_name, description=description, type="eventhouses", return_item=return_item)
2270
2311
 
2312
+ def update_eventhouse_definition(self, workspace_id, eventhouse_id, definition, update_metadata = None):
2313
+ """Update the definition of an eventhouse
2314
+ Args:
2315
+ workspace_id (str): The ID of the workspace
2316
+ eventhouse_id (str): The ID of the eventhouse
2317
+ definition (dict): The definition of the eventhouse
2318
+ update_metadata (bool): Whether to update the metadata
2319
+ Returns:
2320
+ dict: The updated eventhouse definition
2321
+ """
2322
+ return self.update_item_definition(workspace_id, eventhouse_id, type="eventhouses", definition=definition, update_metadata=update_metadata)
2323
+
2324
+
2271
2325
  # eventstreams
2272
2326
 
2273
2327
  def create_eventstream(self, workspace_id, display_name, description = None):
@@ -2309,8 +2363,24 @@ class FabricClientCore(FabricClient):
2309
2363
 
2310
2364
  item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2311
2365
  error_message="Error getting eventstream", return_format="json")
2312
- return Eventstream.from_dict(item_dict, core_client=self)
2366
+ es = Eventstream.from_dict(item_dict, core_client=self)
2367
+ es.get_definition()
2368
+ return es
2313
2369
 
2370
+ def get_eventstream_definition(self, workspace_id, eventstream_id, format = None):
2371
+ """Get the definition of an eventstream
2372
+
2373
+ Args:
2374
+ workspace_id (str): The ID of the workspace
2375
+ eventstream_id (str): The ID of the eventstream
2376
+ format (str): The format of the definition
2377
+ Returns:
2378
+ dict: The eventstream definition
2379
+ """
2380
+
2381
+ return self.get_item_definition(workspace_id, eventstream_id, type="eventstreams", format=format)
2382
+
2383
+
2314
2384
  def delete_eventstream(self, workspace_id, eventstream_id):
2315
2385
  """Delete an eventstream from a workspace
2316
2386
  Args:
@@ -2343,6 +2413,94 @@ class FabricClientCore(FabricClient):
2343
2413
  """
2344
2414
  return self.update_item(workspace_id, eventstream_id, display_name = display_name, description = description,
2345
2415
  type= "eventstreams", return_item=return_item)
2416
+
2417
+ def update_eventstream_definition(self, workspace_id, eventstream_id, definition, update_metadata = None):
2418
+ """Update the definition of an eventstream
2419
+ Args:
2420
+ workspace_id (str): The ID of the workspace
2421
+ eventstream_id (str): The ID of the eventstream
2422
+ definition (dict): The definition of the eventstream
2423
+ update_metadata (bool): Whether to update the metadata
2424
+ Returns:
2425
+ dict: The updated definition of the eventstream
2426
+ """
2427
+ return self.update_item_definition(workspace_id, eventstream_id, type="eventstreams", definition=definition, update_metadata=update_metadata)
2428
+
2429
+ # graphqlapis
2430
+
2431
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/GraphQLApis
2432
+ def create_graphql_api(self, workspace_id, display_name, description = None):
2433
+ """Create a graphql api in a workspace
2434
+ Args:
2435
+ workspace_id (str): The ID of the workspace
2436
+ display_name (str): The display name of the graphql api
2437
+ description (str): The description of the graphql api
2438
+ Returns:
2439
+ dict: The created graphql api
2440
+ """
2441
+ return self.create_item(workspace_id = workspace_id,
2442
+ display_name = display_name,
2443
+ type = "GraphQLApis",
2444
+ description = description)
2445
+
2446
+ def delete_graphql_api(self, workspace_id, graphql_api_id):
2447
+ """Delete a graphql api from a workspace
2448
+ Args:
2449
+ workspace_id (str): The ID of the workspace
2450
+ graphql_api_id (str): The ID of the graphql api
2451
+ Returns:
2452
+ int: The status code of the response
2453
+ """
2454
+ return self.delete_item(workspace_id, graphql_api_id, type="GraphQLApis")
2455
+
2456
+ def get_graphql_api(self, workspace_id, graphql_api_id = None, graphql_api_name = None):
2457
+ """Get a graphql api from a workspace
2458
+ Args:
2459
+ workspace_id (str): The ID of the workspace
2460
+ graphql_api_id (str): The ID of the graphql api
2461
+ graphql_api_name (str): The name of the graphql api
2462
+ Returns:
2463
+ dict: The graphql api
2464
+ """
2465
+ from msfabricpysdkcore.otheritems import GraphQLApi
2466
+ if graphql_api_id is None and graphql_api_name is not None:
2467
+ graphql_apis = self.list_graphql_apis(workspace_id)
2468
+ graphql_apis = [ga for ga in graphql_apis if ga.display_name == graphql_api_name]
2469
+ if len(graphql_apis) == 0:
2470
+ raise Exception(f"Graphql api with name {graphql_api_name} not found")
2471
+ graphql_api_id = graphql_apis[0].id
2472
+ if graphql_api_id is None:
2473
+ raise Exception("graphql_api_id or the graphql_api_name is required")
2474
+
2475
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/GraphQLApis/{graphql_api_id}"
2476
+
2477
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2478
+ error_message="Error getting graphql api", return_format="json")
2479
+ graphql = GraphQLApi.from_dict(item_dict, core_client=self)
2480
+ return graphql
2481
+
2482
+ def list_graphql_apis(self, workspace_id, with_properties = False):
2483
+ """List graphql apis in a workspace
2484
+ Args:
2485
+ workspace_id (str): The ID of the workspace
2486
+ with_properties (bool): Whether to get the item object with properties
2487
+ Returns:
2488
+ list: The list of graphql apis
2489
+ """
2490
+ return self.list_items(workspace_id=workspace_id, type="GraphQLApis", with_properties=with_properties)
2491
+
2492
+ def update_graphql_api(self, workspace_id, graphql_api_id, display_name = None, description = None, return_item=False):
2493
+ """Update a graphql api in a workspace
2494
+ Args:
2495
+ workspace_id (str): The ID of the workspace
2496
+ graphql_api_id (str): The ID of the graphql api
2497
+ display_name (str): The display name of the graphql api
2498
+ description (str): The description of the graphql api
2499
+ Returns:
2500
+ dict: The updated graphql api
2501
+ """
2502
+ return self.update_item(workspace_id, graphql_api_id, display_name = display_name, description = description,
2503
+ type= "GraphQLApis", return_item=return_item)
2346
2504
 
2347
2505
  # kqlDashboard
2348
2506
  def create_kql_dashboard(self, workspace_id, display_name, description = None):
@@ -2495,7 +2653,20 @@ class FabricClientCore(FabricClient):
2495
2653
 
2496
2654
  item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2497
2655
  error_message="Error getting kql database", return_format="json")
2498
- return KQLDatabase.from_dict(item_dict, core_client=self)
2656
+ kqldb = KQLDatabase.from_dict(item_dict, core_client=self)
2657
+ kqldb.get_definition()
2658
+ return kqldb
2659
+
2660
+ def get_kql_database_definition(self, workspace_id, kql_database_id, format=None):
2661
+ """Get the definition of a kql database
2662
+ Args:
2663
+ workspace_id (str): The ID of the workspace
2664
+ kql_database_id (str): The ID of the kql database
2665
+ format (str): The format of the definition
2666
+ Returns:
2667
+ dict: The definition of the kql database
2668
+ """
2669
+ return self.get_item_definition(workspace_id, kql_database_id, type="kqlDatabases", format=format)
2499
2670
 
2500
2671
  def list_kql_databases(self, workspace_id, with_properties = False):
2501
2672
  """List kql databases in a workspace
@@ -2519,6 +2690,19 @@ class FabricClientCore(FabricClient):
2519
2690
  return self.update_item(workspace_id, kql_database_id, display_name = display_name,
2520
2691
  description = description, type= "kqlDatabases", return_item=return_item)
2521
2692
 
2693
+ def update_kql_database_definition(self, workspace_id, kql_database_id, definition, update_metadata = None):
2694
+ """Update the definition of a kql database
2695
+ Args:
2696
+ workspace_id (str): The ID of the workspace
2697
+ kql_database_id (str): The ID of the kql database
2698
+ definition (dict): The definition of the kql database
2699
+ update_metadata (bool): Whether to update the metadata
2700
+ Returns:
2701
+ dict: The updated definition of the kql database
2702
+ """
2703
+ return self.update_item_definition(workspace_id, kql_database_id,
2704
+ type="kqlDatabases", definition=definition, update_metadata=update_metadata)
2705
+
2522
2706
  # kqlQuerysets
2523
2707
 
2524
2708
  def create_kql_queryset(self, workspace_id, display_name, description = None, definition = None):
@@ -2959,6 +3143,7 @@ class FabricClientCore(FabricClient):
2959
3143
  return self.calling_routine(url, operation="POST", response_codes=[200, 429],
2960
3144
  error_message="Error stopping mirroring", return_format="response")
2961
3145
 
3146
+
2962
3147
  # mlExperiments
2963
3148
 
2964
3149
  def create_ml_experiment(self, workspace_id, display_name, description = None):
@@ -3105,7 +3290,106 @@ class FabricClientCore(FabricClient):
3105
3290
  """
3106
3291
  return self.update_item(workspace_id, ml_model_id, display_name = display_name, description = description,
3107
3292
  type="mlModels", return_item=return_item)
3293
+
3294
+ # mounted data factory
3295
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/mountedDataFactories
3296
+
3297
+ def create_mounted_data_factory(self, workspace_id, display_name, description = None, definition = None):
3298
+ """Create a mounted data factory in a workspace
3299
+ Args:
3300
+ workspace_id (str): The ID of the workspace
3301
+ display_name (str): The display name of the mounted data factory
3302
+ description (str): The description of the mounted data factory
3303
+ definition (dict): The definition of the mounted data factory
3304
+ Returns:
3305
+ dict: The created mounted data factory
3306
+ """
3307
+ return self.create_item(workspace_id = workspace_id, display_name = display_name, type = "mountedDataFactories",
3308
+ description = description, definition = definition)
3309
+
3310
+ def delete_mounted_data_factory(self, workspace_id, mounted_data_factory_id):
3311
+ """Delete a mounted data factory from a workspace
3312
+ Args:
3313
+ workspace_id (str): The ID of the workspace
3314
+ mounted_data_factory_id (str): The ID of the mounted data factory
3315
+ Returns:
3316
+ int: The status code of the response
3317
+ """
3318
+ return self.delete_item(workspace_id, mounted_data_factory_id, type="mountedDataFactories")
3319
+
3320
+ def get_mounted_data_factory(self, workspace_id, mounted_data_factory_id = None, mounted_data_factory_name = None):
3321
+ """Get a mounted data factory from a workspace
3322
+ Args:
3323
+ workspace_id (str): The ID of the workspace
3324
+ mounted_data_factory_id (str): The ID of the mounted data factory
3325
+ mounted_data_factory_name (str): The name of the mounted data factory
3326
+ Returns:
3327
+ MountedDataFactory: The mounted data factory object
3328
+ """
3329
+ from msfabricpysdkcore.otheritems import MountedDataFactory
3330
+ if mounted_data_factory_id is None and mounted_data_factory_name is not None:
3331
+ mounted_data_factories = self.list_mounted_data_factories(workspace_id)
3332
+ mounted_data_factories = [mdf for mdf in mounted_data_factories if mdf.display_name == mounted_data_factory_name]
3333
+ if len(mounted_data_factories) == 0:
3334
+ raise Exception(f"Mounted data factory with name {mounted_data_factory_name} not found")
3335
+ mounted_data_factory_id = mounted_data_factories[0].id
3336
+ if mounted_data_factory_id is None:
3337
+ raise Exception("mounted_data_factory_id or the mounted_data_factory_name is required")
3338
+
3339
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/mountedDataFactories/{mounted_data_factory_id}"
3340
+
3341
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3342
+ error_message="Error getting mounted data factory", return_format="json")
3343
+
3344
+ mdf = MountedDataFactory.from_dict(item_dict, core_client=self)
3345
+ mdf.get_definition()
3346
+ return mdf
3347
+
3348
+ def get_mounted_data_factory_definition(self, workspace_id, mounted_data_factory_id, format = None):
3349
+ """Get the definition of a mounted data factory
3350
+ Args:
3351
+ workspace_id (str): The ID of the workspace
3352
+ mounted_data_factory_id (str): The ID of the mounted data factory
3353
+ format (str): The format of the definition
3354
+ Returns:
3355
+ dict: The definition of the mounted data factory
3356
+ """
3357
+ return self.get_item_definition(workspace_id, mounted_data_factory_id, type="mountedDataFactories", format=format)
3358
+
3359
+ def list_mounted_data_factories(self, workspace_id, with_properties = False):
3360
+ """List mounted data factories in a workspace
3361
+ Args:
3362
+ workspace_id (str): The ID of the workspace
3363
+ with_properties (bool): Whether to get the item object with properties
3364
+ Returns:
3365
+ list: The list of mounted data factories
3366
+ """
3367
+ return self.list_items(workspace_id=workspace_id, type="mountedDataFactories", with_properties = with_properties)
3108
3368
 
3369
+ def update_mounted_data_factory(self, workspace_id, mounted_data_factory_id, display_name = None, description = None, return_item=False):
3370
+ """Update a mounted data factory in a workspace
3371
+ Args:
3372
+ workspace_id (str): The ID of the workspace
3373
+ mounted_data_factory_id (str): The ID of the mounted data factory
3374
+ display_name (str): The display name of the mounted data factory
3375
+ description (str): The description of the mounted data factory
3376
+ Returns:
3377
+ dict: The updated mounted data factory
3378
+ """
3379
+ return self.update_item(workspace_id, mounted_data_factory_id, display_name = display_name, description = description,
3380
+ type="mountedDataFactories", return_item=return_item)
3381
+
3382
+ def update_mounted_data_factory_definition(self, workspace_id, mounted_data_factory_id, definition, update_metadata = None):
3383
+ """Update the definition of a mounted data factory
3384
+ Args:
3385
+ workspace_id (str): The ID of the workspace
3386
+ mounted_data_factory_id (str): The ID of the mounted data factory
3387
+ definition (dict): The definition of the mounted data factory
3388
+ Returns:
3389
+ dict: The updated definition of the mounted data factory
3390
+ """
3391
+ return self.update_item_definition(workspace_id, mounted_data_factory_id, definition, type="mountedDataFactories", update_metadata=update_metadata)
3392
+
3109
3393
  # notebooks
3110
3394
 
3111
3395
  def create_notebook(self, workspace_id, display_name, definition = None, description = None):
@@ -3222,6 +3506,103 @@ class FabricClientCore(FabricClient):
3222
3506
  return self.update_item(workspace_id, paginated_report_id, display_name = display_name, description = description,
3223
3507
  type="paginatedReports", return_item=return_item)
3224
3508
 
3509
+ # reflex
3510
+
3511
+ def create_reflex(self, workspace_id, display_name, description = None, definition = None):
3512
+ """Create a reflex in a workspace
3513
+ Args:
3514
+ workspace_id (str): The ID of the workspace
3515
+ display_name (str): The display name of the reflex
3516
+ description (str): The description of the reflex
3517
+ definition (dict): The definition of the reflex
3518
+ Returns:
3519
+ dict: The created reflex
3520
+ """
3521
+ return self.create_item(workspace_id = workspace_id, display_name = display_name, type = "reflexes", description = description, definition = definition)
3522
+
3523
+ def delete_reflex(self, workspace_id, reflex_id):
3524
+ """Delete a reflex from a workspace
3525
+ Args:
3526
+ workspace_id (str): The ID of the workspace
3527
+ reflex_id (str): The ID of the reflex
3528
+ Returns:
3529
+ int: The status code of the response
3530
+ """
3531
+ return self.delete_item(workspace_id, reflex_id, type="reflexes")
3532
+
3533
+ def get_reflex(self, workspace_id, reflex_id = None, reflex_name = None):
3534
+ """Get a reflex from a workspace
3535
+ Args:
3536
+ workspace_id (str): The ID of the workspace
3537
+ reflex_id (str): The ID of the reflex
3538
+ reflex_name (str): The name of the reflex
3539
+ Returns:
3540
+ Reflex: The reflex object
3541
+ """
3542
+ from msfabricpysdkcore.otheritems import Reflex
3543
+ if reflex_id is None and reflex_name is not None:
3544
+ reflexes = self.list_reflexes(workspace_id)
3545
+ reflexes = [rf for rf in reflexes if rf.display_name == reflex_name]
3546
+ if len(reflexes) == 0:
3547
+ raise Exception(f"Reflex with name {reflex_name} not found")
3548
+ reflex_id = reflexes[0].id
3549
+ if reflex_id is None:
3550
+ raise Exception("reflex_id or the reflex_name is required")
3551
+
3552
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/reflexes/{reflex_id}"
3553
+
3554
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3555
+ error_message="Error getting reflex", return_format="json")
3556
+
3557
+ refl = Reflex.from_dict(item_dict, core_client=self)
3558
+ refl.get_definition()
3559
+ return refl
3560
+
3561
+ def get_reflex_definition(self, workspace_id, reflex_id, format = None):
3562
+ """Get the definition of a reflex
3563
+ Args:
3564
+ workspace_id (str): The ID of the workspace
3565
+ reflex_id (str): The ID of the reflex
3566
+ format (str): The format of the definition
3567
+ Returns:
3568
+ dict: The definition of the reflex
3569
+ """
3570
+ return self.get_item_definition(workspace_id, reflex_id, type="reflexes", format=format)
3571
+
3572
+ def list_reflexes(self, workspace_id, with_properties = False):
3573
+ """List reflexes in a workspace
3574
+ Args:
3575
+ workspace_id (str): The ID of the workspace
3576
+ with_properties (bool): Whether to get the item object with properties
3577
+ Returns:
3578
+ list: The list of reflexes
3579
+ """
3580
+ return self.list_items(workspace_id = workspace_id, type = "reflexes", with_properties = with_properties)
3581
+
3582
+ def update_reflex(self, workspace_id, reflex_id, display_name = None, description = None, return_item=False):
3583
+ """Update a reflex in a workspace
3584
+ Args:
3585
+ workspace_id (str): The ID of the workspace
3586
+ reflex_id (str): The ID of the reflex
3587
+ display_name (str): The display name of the reflex
3588
+ description (str): The description of the reflex
3589
+ Returns:
3590
+ dict: The updated reflex
3591
+ """
3592
+ return self.update_item(workspace_id, reflex_id, display_name = display_name, description = description,
3593
+ type="reflexes", return_item=return_item)
3594
+
3595
+ def update_reflex_definition(self, workspace_id, reflex_id, definition, update_metadata = None):
3596
+ """Update the definition of a reflex
3597
+ Args:
3598
+ workspace_id (str): The ID of the workspace
3599
+ reflex_id (str): The ID of the reflex
3600
+ definition (dict): The definition of the reflex
3601
+ Returns:
3602
+ dict: The updated reflex
3603
+ """
3604
+ return self.update_item_definition(workspace_id, reflex_id, definition, type="reflexes", update_metadata=update_metadata)
3605
+
3225
3606
  # reports
3226
3607
 
3227
3608
  def create_report(self, workspace_id, display_name, definition = None, description = None):
@@ -3296,6 +3677,19 @@ class FabricClientCore(FabricClient):
3296
3677
  """
3297
3678
  return self.list_items(workspace_id = workspace_id, type = "reports", with_properties = with_properties)
3298
3679
 
3680
+ def update_report(self, workspace_id, report_id, display_name = None, description = None, return_item=False):
3681
+ """Update a report in a workspace
3682
+ Args:
3683
+ workspace_id (str): The ID of the workspace
3684
+ report_id (str): The ID of the report
3685
+ display_name (str): The display name of the report
3686
+ description (str): The description of the report
3687
+ Returns:
3688
+ dict: The updated report
3689
+ """
3690
+ return self.update_item(workspace_id, report_id, display_name = display_name, description = description,
3691
+ type="reports", return_item=return_item)
3692
+
3299
3693
  def update_report_definition(self, workspace_id, report_id, definition):
3300
3694
  """Update the definition of a report
3301
3695
  Args:
@@ -3690,7 +4084,80 @@ class FabricClientCore(FabricClient):
3690
4084
  item_id = spark_job_definition_id,
3691
4085
  job_instance_id = job_instance_id)
3692
4086
 
4087
+ # sql database
4088
+
4089
+ def create_sql_database(self, workspace_id, display_name, description = None, definition = None):
4090
+ """Create a SQL database in a workspace
4091
+ Args:
4092
+ workspace_id (str): The ID of the workspace
4093
+ display_name (str): The display name of the SQL database
4094
+ description (str): The description of the SQL database
4095
+ definition (dict): The definition of the SQL database
4096
+ Returns:
4097
+ dict: The created SQL database
4098
+ """
4099
+ return self.create_item(workspace_id = workspace_id, display_name = display_name, type = "SQLDatabases", definition = definition, description = description)
3693
4100
 
4101
+ def delete_sql_database(self, workspace_id, sql_database_id):
4102
+ """Delete a SQL database from a workspace
4103
+ Args:
4104
+ workspace_id (str): The ID of the workspace
4105
+ sql_database_id (str): The ID of the SQL database
4106
+ Returns:
4107
+ int: The status code of the response
4108
+ """
4109
+ return self.delete_item(workspace_id, sql_database_id, type="SQLDatabases")
4110
+
4111
+ def get_sql_database(self, workspace_id, sql_database_id = None, sql_database_name = None):
4112
+ """Get a SQL database from a workspace
4113
+ Args:
4114
+ workspace_id (str): The ID of the workspace
4115
+ sql_database_id (str): The ID of the SQL database
4116
+ sql_database_name (str): The name of the SQL database
4117
+ Returns:
4118
+ SQLDatabase: The SQL database object
4119
+ """
4120
+ from msfabricpysdkcore.otheritems import SQLDatabase
4121
+ if sql_database_id is None and sql_database_name is not None:
4122
+ sql_databases = self.list_sql_databases(workspace_id)
4123
+ sql_databases = [sd for sd in sql_databases if sd.display_name == sql_database_name]
4124
+ if len(sql_databases) == 0:
4125
+ raise Exception(f"SQL database with name {sql_database_name} not found")
4126
+ sql_database_id = sql_databases[0].id
4127
+ elif sql_database_id is None:
4128
+ raise Exception("sql_database_id or the sql_database_name is required")
4129
+
4130
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/SQLDatabases/{sql_database_id}"
4131
+
4132
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
4133
+ error_message="Error getting SQL database", return_format="json")
4134
+
4135
+ return SQLDatabase.from_dict(item_dict, core_client=self)
4136
+
4137
+ def list_sql_databases(self, workspace_id, with_properties = False):
4138
+ """List SQL databases in a workspace
4139
+ Args:
4140
+ workspace_id (str): The ID of the workspace
4141
+ with_properties (bool): Whether to get the item object with properties
4142
+ Returns:
4143
+ list: The list of SQL databases
4144
+ """
4145
+ return self.list_items(workspace_id = workspace_id, type = "SQLDatabases", with_properties = with_properties)
4146
+
4147
+ def update_sql_database(self, workspace_id, sql_database_id, display_name = None, description = None, return_item=False):
4148
+ """Update a SQL database in a workspace
4149
+ Args:
4150
+ workspace_id (str): The ID of the workspace
4151
+ sql_database_id (str): The ID of the SQL database
4152
+ display_name (str): The display name of the SQL database
4153
+ description (str): The description of the SQL database
4154
+ Returns:
4155
+ dict: The updated SQL database
4156
+ """
4157
+ return self.update_item(workspace_id, sql_database_id, display_name = display_name, description = description,
4158
+ type="SQLDatabases", return_item=return_item)
4159
+
4160
+
3694
4161
  # warehouses
3695
4162
 
3696
4163
  def create_warehouse(self, workspace_id, display_name, description = None):
msfabricpysdkcore/item.py CHANGED
@@ -45,9 +45,9 @@ 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
@@ -69,10 +69,12 @@ class Item:
69
69
 
70
70
  return resp_dict
71
71
 
72
- def update_definition(self, definition, type = None):
72
+ def update_definition(self, definition, type = None, **kwargs):
73
73
  """Update the item definition"""
74
+ if not type:
75
+ type = self.type
74
76
  response = self.core_client.update_item_definition(workspace_id=self.workspace_id, item_id=self.id,
75
- definition=definition, type=type)
77
+ definition=definition, type=type, **kwargs)
76
78
 
77
79
  self.definition = definition
78
80
  return response