msfabricpysdkcore 0.0.5__py3-none-any.whl → 0.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- msfabricpysdkcore/coreapi.py +346 -0
- msfabricpysdkcore/item.py +7 -3
- msfabricpysdkcore/otheritems.py +55 -0
- msfabricpysdkcore/tests/test_items_incl_lakehouse.py +388 -7
- msfabricpysdkcore/workspace.py +539 -84
- {msfabricpysdkcore-0.0.5.dist-info → msfabricpysdkcore-0.0.6.dist-info}/METADATA +8 -3
- {msfabricpysdkcore-0.0.5.dist-info → msfabricpysdkcore-0.0.6.dist-info}/RECORD +10 -10
- {msfabricpysdkcore-0.0.5.dist-info → msfabricpysdkcore-0.0.6.dist-info}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.5.dist-info → msfabricpysdkcore-0.0.6.dist-info}/WHEEL +0 -0
- {msfabricpysdkcore-0.0.5.dist-info → msfabricpysdkcore-0.0.6.dist-info}/top_level.txt +0 -0
msfabricpysdkcore/workspace.py
CHANGED
@@ -4,8 +4,9 @@ from time import sleep
|
|
4
4
|
from msfabricpysdkcore.item import Item
|
5
5
|
from msfabricpysdkcore.lakehouse import Lakehouse
|
6
6
|
from msfabricpysdkcore.long_running_operation import check_long_running_operation
|
7
|
-
from msfabricpysdkcore.otheritems import SparkJobDefinition
|
8
|
-
from msfabricpysdkcore.otheritems import Warehouse
|
7
|
+
from msfabricpysdkcore.otheritems import DataPipeline, Eventstream, KQLDatabase, KQLQueryset, SparkJobDefinition
|
8
|
+
from msfabricpysdkcore.otheritems import MLExperiment, MLModel, Notebook, Report, SemanticModel, Warehouse
|
9
|
+
|
9
10
|
|
10
11
|
class Workspace:
|
11
12
|
"""Class to represent a workspace in Microsoft Fabric"""
|
@@ -221,18 +222,55 @@ class Workspace:
|
|
221
222
|
self.capacity_id = None
|
222
223
|
return response.status_code
|
223
224
|
|
225
|
+
def get_item_specific(self, item_dict):
|
226
|
+
if item_dict["type"] == "DataPipeline":
|
227
|
+
return self.get_data_pipeline(item_dict["id"])
|
228
|
+
if item_dict["type"] == "Eventstream":
|
229
|
+
return self.get_eventstream(item_dict["id"])
|
230
|
+
if item_dict["type"] == "KQLDatabase":
|
231
|
+
return self.get_kql_database(item_dict["id"])
|
232
|
+
if item_dict["type"] == "KQLQueryset":
|
233
|
+
return self.get_kql_queryset(item_dict["id"])
|
234
|
+
if item_dict["type"] == "Lakehouse":
|
235
|
+
return self.get_lakehouse(item_dict["id"])
|
236
|
+
if item_dict["type"] == "MLExperiment":
|
237
|
+
return self.get_ml_experiment(item_dict["id"])
|
238
|
+
if item_dict["type"] == "MLModel":
|
239
|
+
return self.get_ml_model(item_dict["id"])
|
240
|
+
if item_dict["type"] == "Notebook":
|
241
|
+
return self.get_notebook(item_dict["id"])
|
242
|
+
if item_dict["type"] == "Report":
|
243
|
+
return self.get_report(item_dict["id"])
|
244
|
+
if item_dict["type"] == "SemanticModel":
|
245
|
+
return self.get_semantic_model(item_dict["id"])
|
246
|
+
if item_dict["type"] == "SparkJobDefinition":
|
247
|
+
return self.get_spark_job_definition(item_dict["id"])
|
248
|
+
if item_dict["type"] == "Warehouse":
|
249
|
+
return self.get_warehouse(item_dict["id"])
|
250
|
+
|
251
|
+
item_obj = Item.from_dict(item_dict, auth=self.auth)
|
252
|
+
return item_obj
|
253
|
+
|
224
254
|
def create_item(self, display_name, type, definition = None, description = None):
|
225
255
|
"""Create an item in a workspace"""
|
226
256
|
|
227
257
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/items"
|
228
|
-
|
229
258
|
body = {
|
230
259
|
'displayName': display_name,
|
231
|
-
'type': type
|
232
|
-
'definition': definition,
|
233
|
-
'description': description
|
260
|
+
'type': type
|
234
261
|
}
|
235
262
|
|
263
|
+
if definition:
|
264
|
+
body['definition'] = definition
|
265
|
+
if description:
|
266
|
+
body['description'] = description
|
267
|
+
|
268
|
+
if type in ["eventstreams", "lakehouses", "mlExperiments", "mlModels", "notebooks", "reports", "semanticModels",
|
269
|
+
"sparkJobDefinitions", "warehouses"]:
|
270
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/{type}"
|
271
|
+
body.pop('type')
|
272
|
+
|
273
|
+
|
236
274
|
for _ in range(10):
|
237
275
|
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
238
276
|
if response.status_code == 429:
|
@@ -250,19 +288,34 @@ class Workspace:
|
|
250
288
|
item_dict = json.loads(response.text)
|
251
289
|
if item_dict is None:
|
252
290
|
print("Item not returned by API, trying to get it by name")
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
291
|
+
item = None
|
292
|
+
i = 0
|
293
|
+
|
294
|
+
type_mapping = {"eventstreams": "Eventstream",
|
295
|
+
"lakehouses": "Lakehouse",
|
296
|
+
"mlExperiments": "MLExperiment",
|
297
|
+
"mlModels": "MLModel",
|
298
|
+
"notebooks": "Notebook",
|
299
|
+
"reports": "Report",
|
300
|
+
"semanticModels": "SemanticModel",
|
301
|
+
"sparkJobDefinitions": "SparkJobDefinition",
|
302
|
+
"warehouses": "Warehouse"}
|
303
|
+
|
304
|
+
if type in type_mapping.keys():
|
305
|
+
type = type_mapping[type]
|
306
|
+
while item is None and i < 12:
|
307
|
+
item = self.get_item_by_name(display_name, type)
|
308
|
+
if item is not None:
|
309
|
+
return item
|
310
|
+
print("Item not found, waiting 5 seconds")
|
311
|
+
sleep(5)
|
312
|
+
i += 1
|
313
|
+
|
314
|
+
print("Item not found after 1 minute, returning None")
|
315
|
+
return None
|
316
|
+
|
317
|
+
return self.get_item_specific(item_dict)
|
318
|
+
|
266
319
|
|
267
320
|
def get_item_by_name(self, item_name, item_type):
|
268
321
|
"""Get an item from a workspace by name"""
|
@@ -288,56 +341,35 @@ class Workspace:
|
|
288
341
|
|
289
342
|
item_dict = json.loads(response.text)
|
290
343
|
return item_dict
|
291
|
-
|
292
|
-
def get_lakehouse(self, lakehouse_id = None, lakehouse_name = None):
|
293
|
-
"""Get a lakehouse from a workspace"""
|
294
|
-
|
295
|
-
if lakehouse_id is None and lakehouse_name is not None:
|
296
|
-
return self.get_item_by_name(lakehouse_name, "Lakehouse")
|
297
|
-
elif lakehouse_id is None:
|
298
|
-
raise Exception("lakehouse_id or the lakehouse_name is required")
|
299
|
-
|
300
|
-
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/lakehouses/{lakehouse_id}"
|
301
|
-
|
302
|
-
item_dict = self.get_item_internal(url)
|
303
|
-
return Lakehouse.from_dict(item_dict, auth=self.auth)
|
304
344
|
|
305
|
-
def get_warehouse(self, warehouse_id = None, warehouse_name = None):
|
306
|
-
"""Get a warehouse from a workspace"""
|
307
|
-
if warehouse_id is None and warehouse_name is not None:
|
308
|
-
return self.get_item_by_name(warehouse_name, "Warehouse")
|
309
|
-
elif warehouse_id is None:
|
310
|
-
raise Exception("warehouse_id or the warehouse_name is required")
|
311
|
-
|
312
|
-
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/warehouses/{warehouse_id}"
|
313
|
-
|
314
|
-
item_dict = self.get_item_internal(url)
|
315
|
-
return Warehouse.from_dict(item_dict, auth=self.auth)
|
316
|
-
|
317
|
-
def get_spark_job_definition(self, spark_job_definition_id = None, spark_job_definition_name = None):
|
318
|
-
"""Get a spark job definition from a workspace"""
|
319
|
-
if spark_job_definition_id is None and spark_job_definition_name is not None:
|
320
|
-
return self.get_item_by_name(spark_job_definition_name, "SparkJobDefinition")
|
321
|
-
elif spark_job_definition_id is None:
|
322
|
-
raise Exception("spark_job_definition_id or the spark_job_definition_name is required")
|
323
|
-
|
324
|
-
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/sparkjobdefinitions/{spark_job_definition_id}"
|
325
|
-
|
326
|
-
item_dict = self.get_item_internal(url)
|
327
|
-
sjd_obj = SparkJobDefinition.from_dict(item_dict, auth=self.auth)
|
328
|
-
sjd_obj.get_definition()
|
329
|
-
return sjd_obj
|
330
|
-
|
331
345
|
def get_item(self, item_id = None, item_name = None, item_type = None):
|
332
346
|
# GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}
|
333
347
|
"""Get an item from a workspace"""
|
334
348
|
if item_type:
|
349
|
+
if item_type.lower() == "datapipeline":
|
350
|
+
return self.get_data_pipeline(item_id, item_name)
|
351
|
+
if item_type.lower() == "eventstream":
|
352
|
+
return self.get_eventstream(item_id, item_name)
|
353
|
+
if item_type.lower() == "kqldatabase":
|
354
|
+
return self.get_kql_database(item_id, item_name)
|
355
|
+
if item_type.lower() == "kqlqueryset":
|
356
|
+
return self.get_kql_queryset(item_id, item_name)
|
335
357
|
if item_type.lower() == "lakehouse":
|
336
358
|
return self.get_lakehouse(item_id, item_name)
|
337
|
-
if item_type.lower() == "
|
338
|
-
return self.
|
359
|
+
if item_type.lower() == "mlmodel":
|
360
|
+
return self.get_ml_model(item_id, item_name)
|
361
|
+
if item_type.lower() == "mlexperiment":
|
362
|
+
return self.get_ml_experiment(item_id, item_name)
|
363
|
+
if item_type.lower() == "notebook":
|
364
|
+
return self.get_notebook(item_id, item_name)
|
365
|
+
if item_type.lower() == "report":
|
366
|
+
return self.get_report(item_id, item_name)
|
367
|
+
if item_type.lower() == "semanticmodel":
|
368
|
+
return self.get_semantic_model(item_id, item_name)
|
339
369
|
if item_type.lower() == "sparkjobdefinition":
|
340
370
|
return self.get_spark_job_definition(item_id, item_name)
|
371
|
+
if item_type.lower() == "warehouse":
|
372
|
+
return self.get_warehouse(item_id, item_name)
|
341
373
|
|
342
374
|
if item_id is None and item_name is not None and item_type is not None:
|
343
375
|
return self.get_item_by_name(item_name, item_type)
|
@@ -347,19 +379,8 @@ class Workspace:
|
|
347
379
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/items/{item_id}"
|
348
380
|
|
349
381
|
item_dict = self.get_item_internal(url)
|
350
|
-
if item_dict["type"] == "Lakehouse":
|
351
|
-
return self.get_lakehouse(item_dict["id"])
|
352
|
-
if item_dict["type"] == "Warehouse":
|
353
|
-
return self.get_warehouse(item_dict["id"])
|
354
|
-
if item_dict["type"] == "SparkJobDefinition":
|
355
|
-
return self.get_spark_job_definition(item_dict["id"])
|
356
|
-
|
357
|
-
|
358
|
-
item_obj = Item.from_dict(item_dict, auth=self.auth)
|
359
|
-
if item_obj.type in ["Notebook", "Report", "SemanticModel"]:
|
360
|
-
item_obj.get_definition()
|
361
|
-
return item_obj
|
362
382
|
|
383
|
+
return self.get_item_specific(item_dict)
|
363
384
|
|
364
385
|
def delete_item(self, item_id):
|
365
386
|
"""Delete an item from a workspace"""
|
@@ -370,22 +391,18 @@ class Workspace:
|
|
370
391
|
|
371
392
|
new_item_list = []
|
372
393
|
for item in item_list:
|
373
|
-
|
374
|
-
|
375
|
-
elif item["type"] == "Warehouse":
|
376
|
-
item = self.get_warehouse(item["id"])
|
377
|
-
elif item["type"] == "SparkJobDefinition":
|
378
|
-
item = self.get_spark_job_definition(item["id"])
|
379
|
-
else:
|
380
|
-
item = Item.from_dict(item, auth=self.auth)
|
381
|
-
if item.type in ["Notebook", "Report", "SemanticModel"]:
|
382
|
-
item.get_definition()
|
383
|
-
new_item_list.append(item)
|
394
|
+
item_ = self.get_item_specific(item)
|
395
|
+
new_item_list.append(item_)
|
384
396
|
return new_item_list
|
385
397
|
|
386
|
-
def list_items(self, with_properties = False, continuationToken = None):
|
398
|
+
def list_items(self, with_properties = False, continuationToken = None, type = None):
|
387
399
|
"""List items in a workspace"""
|
400
|
+
|
388
401
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/items"
|
402
|
+
|
403
|
+
if type:
|
404
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/{type}"
|
405
|
+
|
389
406
|
|
390
407
|
if continuationToken:
|
391
408
|
url = f"{url}?continuationToken={continuationToken}"
|
@@ -618,3 +635,441 @@ class Workspace:
|
|
618
635
|
return self.get_item(item_id).load_table(table_name, path_type, relative_path,
|
619
636
|
file_extension, format_options,
|
620
637
|
mode, recursive, wait_for_completion)
|
638
|
+
|
639
|
+
def list_dashboards(self):
|
640
|
+
"""List dashboards in a workspace"""
|
641
|
+
return self.list_items(type="dashboards")
|
642
|
+
|
643
|
+
def list_datamarts(self):
|
644
|
+
"""List datamarts in a workspace"""
|
645
|
+
return self.list_items(type="datamarts")
|
646
|
+
|
647
|
+
def list_paginated_reports(self):
|
648
|
+
"""List paginated reports in a workspace"""
|
649
|
+
return self.list_items(type="paginatedReports")
|
650
|
+
|
651
|
+
def list_sql_endpoints(self):
|
652
|
+
"""List sql endpoints in a workspace"""
|
653
|
+
return self.list_items(type="sqlEndpoints")
|
654
|
+
|
655
|
+
def list_mirrored_warehouses(self):
|
656
|
+
"""List mirrored warehouses in a workspace"""
|
657
|
+
return self.list_items(type="mirroredWarehouses")
|
658
|
+
|
659
|
+
def list_data_pipelines(self, with_properties = False):
|
660
|
+
"""List data pipelines in a workspace"""
|
661
|
+
return self.list_items(with_properties = with_properties, type="dataPipelines")
|
662
|
+
|
663
|
+
def get_data_pipeline(self, data_pipeline_id = None, data_pipeline_name = None):
|
664
|
+
"""Get a data pipeline from a workspace"""
|
665
|
+
if data_pipeline_id is None and data_pipeline_name is not None:
|
666
|
+
return self.get_item_by_name(data_pipeline_name, "DataPipeline")
|
667
|
+
elif data_pipeline_id is None:
|
668
|
+
raise Exception("data_pipeline_id or the data_pipeline_name is required")
|
669
|
+
|
670
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/dataPipelines/{data_pipeline_id}"
|
671
|
+
|
672
|
+
item_dict = self.get_item_internal(url)
|
673
|
+
dp = DataPipeline.from_dict(item_dict, auth=self.auth)
|
674
|
+
dp.get_definition()
|
675
|
+
return dp
|
676
|
+
|
677
|
+
def delete_data_pipeline(self, data_pipeline_id):
|
678
|
+
"""Delete a data pipeline from a workspace"""
|
679
|
+
return self.get_item(item_id=data_pipeline_id).delete(type="dataPipelines")
|
680
|
+
|
681
|
+
def update_data_pipeline(self, data_pipeline_id, display_name = None, description = None):
|
682
|
+
"""Update a data pipeline in a workspace"""
|
683
|
+
return self.get_item(item_id=data_pipeline_id).update(display_name=display_name, description=description, type="dataPipelines")
|
684
|
+
|
685
|
+
def list_eventstreams(self):
|
686
|
+
"""List eventstreams in a workspace"""
|
687
|
+
return self.list_items(type="eventstreams")
|
688
|
+
|
689
|
+
def create_eventstream(self, display_name, description = None):
|
690
|
+
"""Create an eventstream in a workspace"""
|
691
|
+
return self.create_item(display_name = display_name,
|
692
|
+
type = "eventstreams",
|
693
|
+
definition = None,
|
694
|
+
description = description)
|
695
|
+
|
696
|
+
def get_eventstream(self, eventstream_id = None, eventstream_name = None):
|
697
|
+
"""Get an eventstream from a workspace"""
|
698
|
+
if eventstream_id is None and eventstream_name is not None:
|
699
|
+
return self.get_item_by_name(eventstream_name, "Eventstream")
|
700
|
+
elif eventstream_id is None:
|
701
|
+
raise Exception("eventstream_id or the eventstream_name is required")
|
702
|
+
|
703
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/eventstreams/{eventstream_id}"
|
704
|
+
|
705
|
+
item_dict = self.get_item_internal(url)
|
706
|
+
return Eventstream.from_dict(item_dict, auth=self.auth)
|
707
|
+
|
708
|
+
def delete_eventstream(self, eventstream_id):
|
709
|
+
"""Delete an eventstream from a workspace"""
|
710
|
+
return self.get_item(item_id=eventstream_id).delete(type="eventstreams")
|
711
|
+
|
712
|
+
def update_eventstream(self, eventstream_id, display_name = None, description = None):
|
713
|
+
"""Update an eventstream in a workspace"""
|
714
|
+
return self.get_item(item_id=eventstream_id).update(display_name=display_name,
|
715
|
+
description=description,
|
716
|
+
type="eventstreams")
|
717
|
+
|
718
|
+
# kqlDatabases
|
719
|
+
|
720
|
+
def list_kql_databases(self):
|
721
|
+
"""List kql databases in a workspace"""
|
722
|
+
return self.list_items(type="kqlDatabases")
|
723
|
+
|
724
|
+
def get_kql_database(self, kql_database_id = None, kql_database_name = None):
|
725
|
+
"""Get a kql database from a workspace"""
|
726
|
+
|
727
|
+
if kql_database_id is None and kql_database_name is not None:
|
728
|
+
return self.get_item_by_name(kql_database_name, "KQLDatabase")
|
729
|
+
elif kql_database_id is None:
|
730
|
+
raise Exception("kql_database_id or the kql_database_name is required")
|
731
|
+
|
732
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/kqlDatabases/{kql_database_id}"
|
733
|
+
|
734
|
+
item_dict = self.get_item_internal(url)
|
735
|
+
return KQLDatabase.from_dict(item_dict, auth=self.auth)
|
736
|
+
|
737
|
+
def delete_kql_database(self, kql_database_id):
|
738
|
+
"""Delete a kql database from a workspace"""
|
739
|
+
return self.get_item(item_id=kql_database_id).delete(type="kqlDatabases")
|
740
|
+
|
741
|
+
def update_kql_database(self, kql_database_id, display_name = None, description = None):
|
742
|
+
"""Update a kql database in a workspace"""
|
743
|
+
return self.get_item(item_id=kql_database_id).update(display_name=display_name,
|
744
|
+
description=description,
|
745
|
+
type="kqlDatabases")
|
746
|
+
|
747
|
+
# kqlQuerysets
|
748
|
+
|
749
|
+
def list_kql_querysets(self):
|
750
|
+
"""List kql querysets in a workspace"""
|
751
|
+
return self.list_items(type="kqlQuerysets")
|
752
|
+
|
753
|
+
def get_kql_queryset(self, kql_queryset_id = None, kql_queryset_name = None):
|
754
|
+
"""Get a kql queryset from a workspace"""
|
755
|
+
|
756
|
+
if kql_queryset_id is None and kql_queryset_name is not None:
|
757
|
+
return self.get_item_by_name(kql_queryset_name, "KQLQueryset")
|
758
|
+
elif kql_queryset_id is None:
|
759
|
+
raise Exception("kql_queryset_id or the kql_queryset_name is required")
|
760
|
+
|
761
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/kqlQuerysets/{kql_queryset_id}"
|
762
|
+
|
763
|
+
item_dict = self.get_item_internal(url)
|
764
|
+
return KQLQueryset.from_dict(item_dict, auth=self.auth)
|
765
|
+
|
766
|
+
def delete_kql_queryset(self, kql_queryset_id):
|
767
|
+
"""Delete a kql queryset from a workspace"""
|
768
|
+
return self.get_item(item_id=kql_queryset_id).delete(type="kqlQuerysets")
|
769
|
+
|
770
|
+
def update_kql_queryset(self, kql_queryset_id, display_name = None, description = None):
|
771
|
+
"""Update a kql queryset in a workspace"""
|
772
|
+
return self.get_item(item_id=kql_queryset_id).update(display_name=display_name,
|
773
|
+
description=description,
|
774
|
+
type="kqlQuerysets")
|
775
|
+
|
776
|
+
|
777
|
+
# lakehouses
|
778
|
+
|
779
|
+
def list_lakehouses(self, with_properties = False):
|
780
|
+
"""List lakehouses in a workspace"""
|
781
|
+
return self.list_items(with_properties = with_properties, type="lakehouses")
|
782
|
+
|
783
|
+
def create_lakehouse(self, display_name, description = None):
|
784
|
+
"""Create a lakehouse in a workspace"""
|
785
|
+
return self.create_item(display_name = display_name,
|
786
|
+
type = "lakehouses",
|
787
|
+
definition = None,
|
788
|
+
description = description)
|
789
|
+
|
790
|
+
def delete_lakehouse(self, lakehouse_id):
|
791
|
+
"""Delete a lakehouse from a workspace"""
|
792
|
+
return self.get_item(item_id=lakehouse_id).delete(type="lakehouses")
|
793
|
+
|
794
|
+
def update_lakehouse(self, lakehouse_id, display_name = None, description = None):
|
795
|
+
"""Update a lakehouse in a workspace"""
|
796
|
+
return self.get_item(item_id=lakehouse_id).update(display_name=display_name,
|
797
|
+
description=description,
|
798
|
+
type="lakehouses")
|
799
|
+
|
800
|
+
def get_lakehouse(self, lakehouse_id = None, lakehouse_name = None):
|
801
|
+
"""Get a lakehouse from a workspace"""
|
802
|
+
|
803
|
+
if lakehouse_id is None and lakehouse_name is not None:
|
804
|
+
return self.get_item_by_name(lakehouse_name, "Lakehouse")
|
805
|
+
elif lakehouse_id is None:
|
806
|
+
raise Exception("lakehouse_id or the lakehouse_name is required")
|
807
|
+
|
808
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/lakehouses/{lakehouse_id}"
|
809
|
+
|
810
|
+
item_dict = self.get_item_internal(url)
|
811
|
+
return Lakehouse.from_dict(item_dict, auth=self.auth)
|
812
|
+
|
813
|
+
# mlExperiments
|
814
|
+
|
815
|
+
def list_ml_experiments(self):
|
816
|
+
"""List ml experiments in a workspace"""
|
817
|
+
return self.list_items(type="mlExperiments")
|
818
|
+
|
819
|
+
def create_ml_experiment(self, display_name, description = None):
|
820
|
+
"""Create an ml experiment in a workspace"""
|
821
|
+
return self.create_item(display_name = display_name,
|
822
|
+
type = "mlExperiments",
|
823
|
+
definition = None,
|
824
|
+
description = description)
|
825
|
+
|
826
|
+
def get_ml_experiment(self, ml_experiment_id = None, ml_experiment_name = None):
|
827
|
+
"""Get an ml experiment from a workspace"""
|
828
|
+
if ml_experiment_id is None and ml_experiment_name is not None:
|
829
|
+
return self.get_item_by_name(ml_experiment_name, "MLExperiment")
|
830
|
+
elif ml_experiment_id is None:
|
831
|
+
raise Exception("ml_experiment_id or the ml_experiment_name is required")
|
832
|
+
|
833
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/mlExperiments/{ml_experiment_id}"
|
834
|
+
|
835
|
+
item_dict = self.get_item_internal(url)
|
836
|
+
return MLExperiment.from_dict(item_dict, auth=self.auth)
|
837
|
+
|
838
|
+
def delete_ml_experiment(self, ml_experiment_id):
|
839
|
+
"""Delete an ml experiment from a workspace"""
|
840
|
+
return self.get_item(item_id=ml_experiment_id).delete(type="mlExperiments")
|
841
|
+
|
842
|
+
def update_ml_experiment(self, ml_experiment_id, display_name = None, description = None):
|
843
|
+
"""Update an ml experiment in a workspace"""
|
844
|
+
return self.get_item(item_id=ml_experiment_id).update(display_name=display_name,
|
845
|
+
description=description,
|
846
|
+
type="mlExperiments")
|
847
|
+
|
848
|
+
# mlModels
|
849
|
+
|
850
|
+
def list_ml_models(self):
|
851
|
+
"""List ml models in a workspace"""
|
852
|
+
return self.list_items(type="mlModels")
|
853
|
+
|
854
|
+
def create_ml_model(self, display_name, description = None):
|
855
|
+
"""Create an ml model in a workspace"""
|
856
|
+
return self.create_item(display_name = display_name,
|
857
|
+
type = "mlModels",
|
858
|
+
definition = None,
|
859
|
+
description = description)
|
860
|
+
|
861
|
+
def get_ml_model(self, ml_model_id = None, ml_model_name = None):
|
862
|
+
"""Get an ml model from a workspace"""
|
863
|
+
if ml_model_id is None and ml_model_name is not None:
|
864
|
+
return self.get_item_by_name(ml_model_name, "MLModel")
|
865
|
+
elif ml_model_id is None:
|
866
|
+
raise Exception("ml_model_id or the ml_model_name is required")
|
867
|
+
|
868
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/mlModels/{ml_model_id}"
|
869
|
+
|
870
|
+
item_dict = self.get_item_internal(url)
|
871
|
+
return MLModel.from_dict(item_dict, auth=self.auth)
|
872
|
+
|
873
|
+
def delete_ml_model(self, ml_model_id):
|
874
|
+
"""Delete an ml model from a workspace"""
|
875
|
+
return self.get_item(item_id=ml_model_id).delete(type="mlModels")
|
876
|
+
|
877
|
+
def update_ml_model(self, ml_model_id, display_name = None, description = None):
|
878
|
+
"""Update an ml model in a workspace"""
|
879
|
+
return self.get_item(item_id=ml_model_id).update(display_name=display_name,
|
880
|
+
description=description,
|
881
|
+
type="mlModels")
|
882
|
+
|
883
|
+
# notebooks
|
884
|
+
|
885
|
+
def list_notebooks(self, with_properties = False):
|
886
|
+
"""List notebooks in a workspace"""
|
887
|
+
return self.list_items(type="notebooks", with_properties = with_properties)
|
888
|
+
|
889
|
+
def create_notebook(self, display_name, definition = None, description = None):
|
890
|
+
"""Create a notebook in a workspace"""
|
891
|
+
return self.create_item(display_name = display_name,
|
892
|
+
type = "notebooks",
|
893
|
+
definition = definition,
|
894
|
+
description = description)
|
895
|
+
|
896
|
+
def get_notebook(self, notebook_id = None, notebook_name = None):
|
897
|
+
"""Get a notebook from a workspace"""
|
898
|
+
if notebook_id is None and notebook_name is not None:
|
899
|
+
return self.get_item_by_name(notebook_name, "Notebook")
|
900
|
+
elif notebook_id is None:
|
901
|
+
raise Exception("notebook_id or the notebook_name is required")
|
902
|
+
|
903
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/notebooks/{notebook_id}"
|
904
|
+
|
905
|
+
item_dict = self.get_item_internal(url)
|
906
|
+
noteb = Notebook.from_dict(item_dict, auth=self.auth)
|
907
|
+
noteb.get_definition()
|
908
|
+
return noteb
|
909
|
+
|
910
|
+
def delete_notebook(self, notebook_id):
|
911
|
+
"""Delete a notebook from a workspace"""
|
912
|
+
return self.get_item(item_id=notebook_id).delete(type="notebooks")
|
913
|
+
|
914
|
+
def update_notebook(self, notebook_id, display_name = None, description = None):
|
915
|
+
"""Update a notebook in a workspace"""
|
916
|
+
return self.get_item(item_id=notebook_id).update(display_name=display_name,
|
917
|
+
description=description,
|
918
|
+
type="notebooks")
|
919
|
+
|
920
|
+
def update_notebook_definition(self, notebook_id, definition):
|
921
|
+
"""Update the definition of a notebook in a workspace"""
|
922
|
+
return self.get_notebook(notebook_id=notebook_id).update_definition(definition=definition)
|
923
|
+
|
924
|
+
# reports
|
925
|
+
|
926
|
+
def list_reports(self, with_properties = False):
|
927
|
+
"""List reports in a workspace"""
|
928
|
+
return self.list_items(type="reports", with_properties = with_properties)
|
929
|
+
|
930
|
+
def create_report(self, display_name, definition = None, description = None):
|
931
|
+
"""Create a report in a workspace"""
|
932
|
+
return self.create_item(display_name = display_name,
|
933
|
+
type = "reports",
|
934
|
+
definition = definition,
|
935
|
+
description = description)
|
936
|
+
|
937
|
+
def get_report(self, report_id = None, report_name = None):
|
938
|
+
"""Get a report from a workspace"""
|
939
|
+
if report_id is None and report_name is not None:
|
940
|
+
return self.get_item_by_name(report_name, "Report")
|
941
|
+
elif report_id is None:
|
942
|
+
raise Exception("report_id or the report_name is required")
|
943
|
+
|
944
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/reports/{report_id}"
|
945
|
+
|
946
|
+
item_dict = self.get_item_internal(url)
|
947
|
+
rep = Report.from_dict(item_dict, auth=self.auth)
|
948
|
+
rep.get_definition()
|
949
|
+
return rep
|
950
|
+
|
951
|
+
def delete_report(self, report_id):
|
952
|
+
"""Delete a report from a workspace"""
|
953
|
+
return self.get_item(item_id=report_id).delete(type="reports")
|
954
|
+
|
955
|
+
def update_report_definition(self, report_id, definition):
|
956
|
+
"""Update the definition of a report in a workspace"""
|
957
|
+
return self.get_report(report_id=report_id).update_definition(definition=definition)
|
958
|
+
|
959
|
+
# semanticModels
|
960
|
+
|
961
|
+
def list_semantic_models(self, with_properties = False):
|
962
|
+
"""List semantic models in a workspace"""
|
963
|
+
return self.list_items(type="semanticModels", with_properties = with_properties)
|
964
|
+
|
965
|
+
def create_semantic_model(self, display_name, definition = None, description = None):
|
966
|
+
"""Create a semantic model in a workspace"""
|
967
|
+
return self.create_item(display_name = display_name,
|
968
|
+
type = "semanticModels",
|
969
|
+
definition = definition,
|
970
|
+
description = description)
|
971
|
+
|
972
|
+
def get_semantic_model(self, semantic_model_id = None, semantic_model_name = None):
|
973
|
+
"""Get a semantic model from a workspace"""
|
974
|
+
if semantic_model_id is None and semantic_model_name is not None:
|
975
|
+
return self.get_item_by_name(semantic_model_name, "SemanticModel")
|
976
|
+
elif semantic_model_id is None:
|
977
|
+
raise Exception("semantic_model_id or the semantic_model_name is required")
|
978
|
+
|
979
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/semanticModels/{semantic_model_id}"
|
980
|
+
|
981
|
+
item_dict = self.get_item_internal(url)
|
982
|
+
semmodel = SemanticModel.from_dict(item_dict, auth=self.auth)
|
983
|
+
semmodel.get_definition()
|
984
|
+
return semmodel
|
985
|
+
|
986
|
+
def delete_semantic_model(self, semantic_model_id):
|
987
|
+
"""Delete a semantic model from a workspace"""
|
988
|
+
return self.get_item(item_id=semantic_model_id).delete(type="semanticModels")
|
989
|
+
|
990
|
+
def update_semantic_model(self, semantic_model_id, display_name = None, description = None):
|
991
|
+
"""Update a semantic model in a workspace"""
|
992
|
+
return self.get_item(item_id=semantic_model_id).update(display_name=display_name,
|
993
|
+
description=description,
|
994
|
+
type="semanticModels")
|
995
|
+
|
996
|
+
def update_semantic_model_definition(self, semantic_model_id, definition):
|
997
|
+
"""Update the definition of a semantic model in a workspace"""
|
998
|
+
return self.get_semantic_model(semantic_model_id=semantic_model_id).update_definition(definition=definition)
|
999
|
+
|
1000
|
+
# sparkJobDefinitions
|
1001
|
+
|
1002
|
+
def list_spark_job_definitions(self, with_properties = False):
|
1003
|
+
"""List spark job definitions in a workspace"""
|
1004
|
+
return self.list_items(type="sparkJobDefinitions", with_properties = with_properties)
|
1005
|
+
|
1006
|
+
def create_spark_job_definition(self, display_name, definition = None, description = None):
|
1007
|
+
"""Create a spark job definition in a workspace"""
|
1008
|
+
return self.create_item(display_name = display_name,
|
1009
|
+
type = "sparkJobDefinitions",
|
1010
|
+
definition = definition,
|
1011
|
+
description = description)
|
1012
|
+
|
1013
|
+
def get_spark_job_definition(self, spark_job_definition_id = None, spark_job_definition_name = None):
|
1014
|
+
"""Get a spark job definition from a workspace"""
|
1015
|
+
if spark_job_definition_id is None and spark_job_definition_name is not None:
|
1016
|
+
return self.get_item_by_name(spark_job_definition_name, "SparkJobDefinition")
|
1017
|
+
elif spark_job_definition_id is None:
|
1018
|
+
raise Exception("spark_job_definition_id or the spark_job_definition_name is required")
|
1019
|
+
|
1020
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/sparkjobdefinitions/{spark_job_definition_id}"
|
1021
|
+
|
1022
|
+
item_dict = self.get_item_internal(url)
|
1023
|
+
sjd_obj = SparkJobDefinition.from_dict(item_dict, auth=self.auth)
|
1024
|
+
sjd_obj.get_definition()
|
1025
|
+
return sjd_obj
|
1026
|
+
|
1027
|
+
def delete_spark_job_definition(self, spark_job_definition_id):
|
1028
|
+
"""Delete a spark job definition from a workspace"""
|
1029
|
+
return self.get_item(item_id=spark_job_definition_id).delete(type="sparkJobDefinitions")
|
1030
|
+
|
1031
|
+
def update_spark_job_definition(self, spark_job_definition_id, display_name = None, description = None):
|
1032
|
+
"""Update a spark job definition in a workspace"""
|
1033
|
+
return self.get_spark_job_definition(spark_job_definition_id=spark_job_definition_id).update(display_name=display_name,
|
1034
|
+
description=description,
|
1035
|
+
type="sparkJobDefinitions")
|
1036
|
+
|
1037
|
+
def update_spark_job_definition_definition(self, spark_job_definition_id, definition):
|
1038
|
+
"""Update the definition of a spark job definition in a workspace"""
|
1039
|
+
return self.get_spark_job_definition(spark_job_definition_id=spark_job_definition_id).update_definition(definition=definition)
|
1040
|
+
|
1041
|
+
# warehouses
|
1042
|
+
|
1043
|
+
def list_warehouses(self, with_properties = False):
|
1044
|
+
"""List warehouses in a workspace"""
|
1045
|
+
return self.list_items(type="warehouses")
|
1046
|
+
|
1047
|
+
def create_warehouse(self, display_name, description = None):
|
1048
|
+
"""Create a warehouse in a workspace"""
|
1049
|
+
return self.create_item(display_name = display_name,
|
1050
|
+
type = "warehouses",description = description)
|
1051
|
+
|
1052
|
+
def get_warehouse(self, warehouse_id = None, warehouse_name = None):
|
1053
|
+
"""Get a warehouse from a workspace"""
|
1054
|
+
if warehouse_id is None and warehouse_name is not None:
|
1055
|
+
return self.get_item_by_name(warehouse_name, "Warehouse")
|
1056
|
+
elif warehouse_id is None:
|
1057
|
+
raise Exception("warehouse_id or the warehouse_name is required")
|
1058
|
+
|
1059
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/warehouses/{warehouse_id}"
|
1060
|
+
|
1061
|
+
item_dict = self.get_item_internal(url)
|
1062
|
+
return Warehouse.from_dict(item_dict, auth=self.auth)
|
1063
|
+
|
1064
|
+
def delete_warehouse(self, warehouse_id):
|
1065
|
+
"""Delete a warehouse from a workspace"""
|
1066
|
+
return self.get_item(item_id=warehouse_id).delete(type="warehouses")
|
1067
|
+
|
1068
|
+
def update_warehouse(self, warehouse_id, display_name = None, description = None):
|
1069
|
+
"""Update a warehouse in a workspace"""
|
1070
|
+
return self.get_item(item_id=warehouse_id).update(display_name=display_name,
|
1071
|
+
description=description,
|
1072
|
+
type="warehouses")
|
1073
|
+
|
1074
|
+
|
1075
|
+
|