msfabricpysdkcore 0.0.9__tar.gz → 0.0.11__tar.gz

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 (45) hide show
  1. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/PKG-INFO +82 -32
  2. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/README.md +81 -31
  3. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/admin_item.py +7 -0
  4. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/admin_workspace.py +20 -1
  5. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/adminapi.py +133 -7
  6. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/auth.py +9 -6
  7. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/client.py +5 -4
  8. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/coreapi.py +341 -17
  9. msfabricpysdkcore-0.0.11/msfabricpysdkcore/deployment_pipeline.py +240 -0
  10. msfabricpysdkcore-0.0.11/msfabricpysdkcore/environment.py +209 -0
  11. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/item.py +12 -11
  12. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/lakehouse.py +42 -1
  13. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/long_running_operation.py +2 -6
  14. msfabricpysdkcore-0.0.11/msfabricpysdkcore/otheritems.py +191 -0
  15. msfabricpysdkcore-0.0.11/msfabricpysdkcore/spark_custom_pool.py +118 -0
  16. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_admin_apis.py +20 -9
  17. msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_datapipelines.py +48 -0
  18. msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_deployment_pipeline.py +64 -0
  19. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_domains.py +3 -2
  20. msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_environments.py +65 -0
  21. msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_evenstreams.py +44 -0
  22. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_git.py +3 -1
  23. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +81 -109
  24. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_jobs.py +4 -0
  25. msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_kqldatabases.py +48 -0
  26. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_shortcuts.py +3 -1
  27. msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_spark.py +91 -0
  28. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_workspaces_capacities.py +6 -5
  29. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/workspace.py +358 -32
  30. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/PKG-INFO +82 -32
  31. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/SOURCES.txt +9 -0
  32. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/pyproject.toml +1 -1
  33. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/setup.py +1 -1
  34. msfabricpysdkcore-0.0.9/msfabricpysdkcore/otheritems.py +0 -72
  35. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/LICENSE +0 -0
  36. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/__init__.py +0 -0
  37. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/capacity.py +0 -0
  38. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/domain.py +0 -0
  39. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/job_instance.py +0 -0
  40. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/onelakeshortcut.py +0 -0
  41. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/__init__.py +0 -0
  42. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
  43. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/requires.txt +0 -0
  44. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
  45. {msfabricpysdkcore-0.0.9 → msfabricpysdkcore-0.0.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msfabricpysdkcore
3
- Version: 0.0.9
3
+ Version: 0.0.11
4
4
  Summary: A Python SDK for Microsoft Fabric
5
5
  Author: Andreas Rederer
6
6
  Project-URL: Homepage, https://github.com/DaSenf1860/ms-fabric-sdk-core
@@ -37,22 +37,24 @@ See the latest release notes [here](releasenotes/release_notes.md).
37
37
  Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other item specific CRUD APIs, i.e.:
38
38
  - Core APIs
39
39
  - [Capacities](#working-with-capacities)
40
+ - [Deployment Pipelines](#deployment-pipelines)
40
41
  - [Git](#working-with-git)
41
42
  - [Items](#working-with-items)
42
43
  - [Job Scheduler](#working-with-job-scheduler)
43
- - Long Running Operations
44
+ - [Long Running Operations](#long-running-operations)
44
45
  - [OneLakeShortcuts](#working-with-one-lake-shortcuts)
45
46
  - [Workspaces](#working-with-workspaces)
46
- - Lakehouse APIs
47
- - [Tables](#tables)
48
47
  - Admin APIs
49
48
  - [Domains](#admin-api-for-domains)
50
49
  - [Items](#admin-api-for-items)
50
+ - [Labels](#admin-api-for-labels)
51
51
  - [Tenants](#admin-api-for-tenants)
52
52
  - [Users](#admin-api-for-users)
53
53
  - [Workspaces](#admin-api-for-workspaces)
54
- - [Item Specific CRUD APIs](item_specific_apis.md), e.g.
54
+ - [Item Specific APIs](item_specific_apis.md), e.g.
55
55
  - List, create, update, delete warehouses, notebooks, semantic models, kql databases,.....
56
+ - Lakehouse operations (Load table, list tables, run table maintenance)
57
+ - Spark Pool operations
56
58
 
57
59
  It is planned to support also new APIs which are not released yet.
58
60
  Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
@@ -194,6 +196,45 @@ ws.unassign_from_capacity()
194
196
  fc.list_capacities()
195
197
  ```
196
198
 
199
+ ### Deployment Pipelines
200
+
201
+ ```python
202
+
203
+
204
+ # List deployment pipelines
205
+
206
+ depl_pipes = fc.list_deployment_pipelines()
207
+
208
+ pipe = [pipe for pipe in depl_pipes if pipe.display_name == 'sdkpipe'][0]
209
+ pipe_id = pipe.id
210
+
211
+ # Get a deployment pipeline
212
+ pipe = fc.get_deployment_pipeline(pipe_id)
213
+
214
+
215
+ # Get deployment pipeline stages
216
+ stages = fc.get_deployment_pipeline_stages(pipe_id)
217
+
218
+ names = [stage.display_name for stage in stages]
219
+
220
+ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0]
221
+ prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
222
+
223
+ # Get deployment pipeline stages items
224
+ items = fc.get_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
225
+
226
+
227
+ items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
228
+ item = items[0]
229
+ item = {"sourceItemId": item["itemId"],
230
+ "itemType": item["itemType"]}
231
+ items = [item]
232
+
233
+ # Deploy stage content
234
+ response = pipe.deploy(source_stage_id=dev_stage.id,target_stage_id=prod_stage.id, items=items)
235
+
236
+ ```
237
+
197
238
  ### Working with items
198
239
 
199
240
  ```python
@@ -380,37 +421,24 @@ item.cancel_item_job_instance(job_instance_id="job_instance_id")
380
421
 
381
422
  ```
382
423
 
383
- ### Tables
384
-
385
424
 
425
+ ### Long Running Operations
386
426
 
387
427
  ```python
388
- # List tables in a Lakehouse
389
428
 
390
- from msfabricpysdkcore import FabricClientCore
429
+ # Get the state of an operation
391
430
 
392
- fc = FabricClientCore()
393
- ws = fc.get_workspace_by_name("testworkspace")
394
- lakehouse = ws.get_item_by_name(item_name="lakehouse1", item_type="Lakehouse")
395
- table_list = lakehouse.list_tables()
396
- # or
397
- table_list = ws.list_tables(item_id = "someitemid")
398
- # or
399
- table_list = fc.list_tables(workspace_id = "someworkspaceid", item_id = "someitemid")
431
+ operation_id = "801783df0123gsdgsq80"
400
432
 
433
+ state = fc.get_operation_state(operation_id)
401
434
 
402
- # Load a file (like a csv) into a Lakehouse table
435
+ # Get the results of an operation
403
436
 
404
- lakehouse.load_table(table_name="testtable", path_type= "File", relative_path="Files/folder1/titanic.csv")
405
- # or
406
- ws.load_table(item_id = "someitemid", table_name="testtable",
407
- path_type= "File", relative_path="Files/folder1/titanic.csv")
408
- # or
409
- fc.load_table(workspace_id = "someworkspaceid", item_id = "someitemid", table_name="testtable",
410
- path_type= "File", relative_path="Files/folder1/titanic.csv")
437
+ results = fc.get_operation_results(operation_id)
411
438
 
412
439
  ```
413
440
 
441
+
414
442
  ### Admin API for Workspaces
415
443
 
416
444
  ```python
@@ -427,9 +455,9 @@ ws = fca.get_workspace(workspace_id="workspace_id")
427
455
 
428
456
  # Get workspace access details
429
457
 
430
- ws_access = fca.get_workspace_access_details("workspace_id")
458
+ ws_access = fca.list_workspace_access_details("workspace_id")
431
459
  # or
432
- ws_access = ws.get_access_details()
460
+ ws_access = ws.list_access_details()
433
461
  ```
434
462
 
435
463
  ### Admin API for Users
@@ -442,7 +470,7 @@ fca = FabricClientAdmin()
442
470
  # Get access entities
443
471
 
444
472
  user_id = 'b4fuhaidc2'
445
- access_entities = fca.get_access_entities(user_id, type="Notebook")
473
+ access_entities = fca.list_access_entities(user_id, type="Notebook")
446
474
 
447
475
  ```
448
476
 
@@ -455,11 +483,11 @@ fca = FabricClientAdmin()
455
483
 
456
484
  # Get tenant settings
457
485
 
458
- tenant_settings = fca.get_tenant_settings()
486
+ tenant_settings = fca.list_tenant_settings()
459
487
 
460
488
  # Get capacity tenant settings overrides
461
489
 
462
- overrides = fca.get_capacities_tenant_settings_overrides()
490
+ overrides = fca.list_capacities_tenant_settings_overrides()
463
491
 
464
492
  ```
465
493
 
@@ -482,14 +510,36 @@ item = ws.get_item(item_id=item_list[0].id)
482
510
 
483
511
  # Get item access details
484
512
 
485
- item_access = fca.get_item_access_details(workspace_id="wsid", item_id=item_list[0].id)
513
+ item_access = fca.list_item_access_details(workspace_id="wsid", item_id=item_list[0].id)
486
514
  #or
487
- item_access = ws.get_item_access_details(item_id=item_list[0].id)
515
+ item_access = ws.list_item_access_details(item_id=item_list[0].id)
488
516
  # or
489
517
  item_access = item.get_access_details()
490
518
 
491
519
  ```
492
520
 
521
+ ### Admin API for Labels
522
+
523
+ ```python
524
+
525
+ from msfabricpysdkcore import FabricClientAdmin
526
+
527
+ fca = FabricClientAdmin()
528
+
529
+ items = [{"id": "d417b843534cf0-23423523", "type": "Lakehouse"}]
530
+ label_id = "de8912714345d2" # to be found in Microsoft Purview Compliance Center
531
+
532
+ # Bulk set labels
533
+
534
+ resp = fca.bulk_set_labels(items=items, label_id=label_id)
535
+
536
+ # Bulk remove labels
537
+
538
+ resp = fca.bulk_remove_labels(items=items)
539
+
540
+ ```
541
+
542
+
493
543
  ### Admin API for Domains
494
544
 
495
545
  ```python
@@ -22,22 +22,24 @@ See the latest release notes [here](releasenotes/release_notes.md).
22
22
  Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other item specific CRUD APIs, i.e.:
23
23
  - Core APIs
24
24
  - [Capacities](#working-with-capacities)
25
+ - [Deployment Pipelines](#deployment-pipelines)
25
26
  - [Git](#working-with-git)
26
27
  - [Items](#working-with-items)
27
28
  - [Job Scheduler](#working-with-job-scheduler)
28
- - Long Running Operations
29
+ - [Long Running Operations](#long-running-operations)
29
30
  - [OneLakeShortcuts](#working-with-one-lake-shortcuts)
30
31
  - [Workspaces](#working-with-workspaces)
31
- - Lakehouse APIs
32
- - [Tables](#tables)
33
32
  - Admin APIs
34
33
  - [Domains](#admin-api-for-domains)
35
34
  - [Items](#admin-api-for-items)
35
+ - [Labels](#admin-api-for-labels)
36
36
  - [Tenants](#admin-api-for-tenants)
37
37
  - [Users](#admin-api-for-users)
38
38
  - [Workspaces](#admin-api-for-workspaces)
39
- - [Item Specific CRUD APIs](item_specific_apis.md), e.g.
39
+ - [Item Specific APIs](item_specific_apis.md), e.g.
40
40
  - List, create, update, delete warehouses, notebooks, semantic models, kql databases,.....
41
+ - Lakehouse operations (Load table, list tables, run table maintenance)
42
+ - Spark Pool operations
41
43
 
42
44
  It is planned to support also new APIs which are not released yet.
43
45
  Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
@@ -179,6 +181,45 @@ ws.unassign_from_capacity()
179
181
  fc.list_capacities()
180
182
  ```
181
183
 
184
+ ### Deployment Pipelines
185
+
186
+ ```python
187
+
188
+
189
+ # List deployment pipelines
190
+
191
+ depl_pipes = fc.list_deployment_pipelines()
192
+
193
+ pipe = [pipe for pipe in depl_pipes if pipe.display_name == 'sdkpipe'][0]
194
+ pipe_id = pipe.id
195
+
196
+ # Get a deployment pipeline
197
+ pipe = fc.get_deployment_pipeline(pipe_id)
198
+
199
+
200
+ # Get deployment pipeline stages
201
+ stages = fc.get_deployment_pipeline_stages(pipe_id)
202
+
203
+ names = [stage.display_name for stage in stages]
204
+
205
+ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0]
206
+ prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
207
+
208
+ # Get deployment pipeline stages items
209
+ items = fc.get_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
210
+
211
+
212
+ items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
213
+ item = items[0]
214
+ item = {"sourceItemId": item["itemId"],
215
+ "itemType": item["itemType"]}
216
+ items = [item]
217
+
218
+ # Deploy stage content
219
+ response = pipe.deploy(source_stage_id=dev_stage.id,target_stage_id=prod_stage.id, items=items)
220
+
221
+ ```
222
+
182
223
  ### Working with items
183
224
 
184
225
  ```python
@@ -365,37 +406,24 @@ item.cancel_item_job_instance(job_instance_id="job_instance_id")
365
406
 
366
407
  ```
367
408
 
368
- ### Tables
369
-
370
409
 
410
+ ### Long Running Operations
371
411
 
372
412
  ```python
373
- # List tables in a Lakehouse
374
413
 
375
- from msfabricpysdkcore import FabricClientCore
414
+ # Get the state of an operation
376
415
 
377
- fc = FabricClientCore()
378
- ws = fc.get_workspace_by_name("testworkspace")
379
- lakehouse = ws.get_item_by_name(item_name="lakehouse1", item_type="Lakehouse")
380
- table_list = lakehouse.list_tables()
381
- # or
382
- table_list = ws.list_tables(item_id = "someitemid")
383
- # or
384
- table_list = fc.list_tables(workspace_id = "someworkspaceid", item_id = "someitemid")
416
+ operation_id = "801783df0123gsdgsq80"
385
417
 
418
+ state = fc.get_operation_state(operation_id)
386
419
 
387
- # Load a file (like a csv) into a Lakehouse table
420
+ # Get the results of an operation
388
421
 
389
- lakehouse.load_table(table_name="testtable", path_type= "File", relative_path="Files/folder1/titanic.csv")
390
- # or
391
- ws.load_table(item_id = "someitemid", table_name="testtable",
392
- path_type= "File", relative_path="Files/folder1/titanic.csv")
393
- # or
394
- fc.load_table(workspace_id = "someworkspaceid", item_id = "someitemid", table_name="testtable",
395
- path_type= "File", relative_path="Files/folder1/titanic.csv")
422
+ results = fc.get_operation_results(operation_id)
396
423
 
397
424
  ```
398
425
 
426
+
399
427
  ### Admin API for Workspaces
400
428
 
401
429
  ```python
@@ -412,9 +440,9 @@ ws = fca.get_workspace(workspace_id="workspace_id")
412
440
 
413
441
  # Get workspace access details
414
442
 
415
- ws_access = fca.get_workspace_access_details("workspace_id")
443
+ ws_access = fca.list_workspace_access_details("workspace_id")
416
444
  # or
417
- ws_access = ws.get_access_details()
445
+ ws_access = ws.list_access_details()
418
446
  ```
419
447
 
420
448
  ### Admin API for Users
@@ -427,7 +455,7 @@ fca = FabricClientAdmin()
427
455
  # Get access entities
428
456
 
429
457
  user_id = 'b4fuhaidc2'
430
- access_entities = fca.get_access_entities(user_id, type="Notebook")
458
+ access_entities = fca.list_access_entities(user_id, type="Notebook")
431
459
 
432
460
  ```
433
461
 
@@ -440,11 +468,11 @@ fca = FabricClientAdmin()
440
468
 
441
469
  # Get tenant settings
442
470
 
443
- tenant_settings = fca.get_tenant_settings()
471
+ tenant_settings = fca.list_tenant_settings()
444
472
 
445
473
  # Get capacity tenant settings overrides
446
474
 
447
- overrides = fca.get_capacities_tenant_settings_overrides()
475
+ overrides = fca.list_capacities_tenant_settings_overrides()
448
476
 
449
477
  ```
450
478
 
@@ -467,14 +495,36 @@ item = ws.get_item(item_id=item_list[0].id)
467
495
 
468
496
  # Get item access details
469
497
 
470
- item_access = fca.get_item_access_details(workspace_id="wsid", item_id=item_list[0].id)
498
+ item_access = fca.list_item_access_details(workspace_id="wsid", item_id=item_list[0].id)
471
499
  #or
472
- item_access = ws.get_item_access_details(item_id=item_list[0].id)
500
+ item_access = ws.list_item_access_details(item_id=item_list[0].id)
473
501
  # or
474
502
  item_access = item.get_access_details()
475
503
 
476
504
  ```
477
505
 
506
+ ### Admin API for Labels
507
+
508
+ ```python
509
+
510
+ from msfabricpysdkcore import FabricClientAdmin
511
+
512
+ fca = FabricClientAdmin()
513
+
514
+ items = [{"id": "d417b843534cf0-23423523", "type": "Lakehouse"}]
515
+ label_id = "de8912714345d2" # to be found in Microsoft Purview Compliance Center
516
+
517
+ # Bulk set labels
518
+
519
+ resp = fca.bulk_set_labels(items=items, label_id=label_id)
520
+
521
+ # Bulk remove labels
522
+
523
+ resp = fca.bulk_remove_labels(items=items)
524
+
525
+ ```
526
+
527
+
478
528
  ### Admin API for Domains
479
529
 
480
530
  ```python
@@ -83,6 +83,13 @@ class AdminItem:
83
83
  def get_item_access_details(self, type=None):
84
84
  """Get the access details of the item
85
85
 
86
+ Returns:
87
+ dict: The access details of the item"""
88
+ return self.list_item_access_details(type)
89
+
90
+ def list_item_access_details(self, type=None):
91
+ """Get the access details of the item
92
+
86
93
  Returns:
87
94
  dict: The access details of the item"""
88
95
 
@@ -70,6 +70,14 @@ class AdminWorkspace:
70
70
  def get_workspace_access_details(self):
71
71
  """Get the access details of the workspace
72
72
 
73
+ Returns:
74
+ dict: The access details of the workspace
75
+ """
76
+ return self.list_workspace_access_details()
77
+
78
+ def list_workspace_access_details(self):
79
+ """Get the access details of the workspace
80
+
73
81
  Returns:
74
82
  dict: The access details of the workspace
75
83
  """
@@ -115,6 +123,17 @@ class AdminWorkspace:
115
123
  item_dict = json.loads(response.text)
116
124
  return AdminItem.from_dict(item_dict, self.auth)
117
125
 
126
+ def list_item_access_details(self, item_id, type=None):
127
+ """Get the access details of the item
128
+
129
+ Args:
130
+ item_id (str): The ID of the item
131
+ type (str): The type of the item
132
+ Returns:
133
+ dict: The access details of the item
134
+ """
135
+ return self.get_item(item_id, type).list_item_access_details()
136
+
118
137
  def get_item_access_details(self, item_id, type=None):
119
138
  """Get the access details of the item
120
139
 
@@ -124,4 +143,4 @@ class AdminWorkspace:
124
143
  Returns:
125
144
  dict: The access details of the item
126
145
  """
127
- return self.get_item(item_id, type).get_item_access_details()
146
+ return self.list_item_access_details(item_id, type)
@@ -284,13 +284,24 @@ class FabricClientAdmin(FabricClient):
284
284
  def get_workspace_access_details(self, workspace_id):
285
285
  """Get the access details of the workspace
286
286
 
287
+ Args:
288
+ workspace_id (str): The ID of the workspace
289
+ Returns:
290
+ dict: The access details of the workspace
291
+ """
292
+ print("DEPRECATED: Use list_workspace_access_details instead")
293
+ return self.list_workspace_access_details(workspace_id)
294
+
295
+ def list_workspace_access_details(self, workspace_id):
296
+ """Get the access details of the workspace
297
+
287
298
  Args:
288
299
  workspace_id (str): The ID of the workspace
289
300
  Returns:
290
301
  dict: The access details of the workspace
291
302
  """
292
303
  ws = self.get_workspace(workspace_id)
293
- return ws.get_workspace_access_details()
304
+ return ws.list_workspace_access_details()
294
305
 
295
306
  def list_workspaces(self, capacity_id = None, name=None, state=None, type=None, continuationToken = None):
296
307
  """List all workspaces
@@ -426,6 +437,15 @@ class FabricClientAdmin(FabricClient):
426
437
  def get_tenant_settings(self):
427
438
  """Get the tenant settings
428
439
 
440
+ Returns:
441
+ dict: The tenant settings
442
+ """
443
+ print("DEPRECATED: Use list_tenant_settings instead")
444
+ return self.list_tenant_settings()
445
+
446
+ def list_tenant_settings(self):
447
+ """Get the tenant settings
448
+
429
449
  Returns:
430
450
  dict: The tenant settings
431
451
  """
@@ -445,7 +465,7 @@ class FabricClientAdmin(FabricClient):
445
465
  return json.loads(response.text)
446
466
 
447
467
 
448
- def get_capacities_tenant_settings_overrides(self, continuationToken = None):
468
+ def list_capacities_tenant_settings_overrides(self, continuationToken = None):
449
469
  """Returns list of tenant setting overrides that override at the capacities
450
470
 
451
471
  Returns:
@@ -471,12 +491,35 @@ class FabricClientAdmin(FabricClient):
471
491
  overrides = resp_dict["Overrides"]
472
492
 
473
493
  if "continuationToken" in resp_dict and resp_dict["continuationToken"] is not None:
474
- overrides_next = self.get_capacities_tenant_settings_overrides(continuationToken=resp_dict["continuationToken"])
494
+ overrides_next = self.list_capacities_tenant_settings_overrides(continuationToken=resp_dict["continuationToken"])
475
495
  overrides.extend(overrides_next)
476
496
 
477
497
  return overrides
498
+
499
+ def get_capacities_tenant_settings_overrides(self):
500
+ """Returns list of tenant setting overrides that override at the capacities
501
+
502
+ Returns:
503
+ list: The capacities tenant settings overrides
504
+ """
505
+ print("DEPRECATED: Use list_capacities_tenant_settings_overrides instead")
506
+ return self.list_capacities_tenant_settings_overrides()
478
507
 
479
- def get_access_entities(self, user_id, type = None, continuationToken = None):
508
+
509
+ def get_access_entities(self, user_id, type = None):
510
+ """Get the access entities for a user
511
+
512
+ Args:
513
+ user_id (str): The ID of the user
514
+ type (str): The type of the access entity
515
+ continuationToken (str): The continuation token
516
+ Returns:
517
+ list: The list of access entities
518
+ """
519
+ print("DEPRECATED: Use list_access_entities instead")
520
+ return self.list_access_entities(user_id, type)
521
+
522
+ def list_access_entities(self, user_id, type = None, continuationToken = None):
480
523
  """Get the access entities for a user
481
524
 
482
525
  Args:
@@ -515,12 +558,12 @@ class FabricClientAdmin(FabricClient):
515
558
  access_entities = resp_dict["accessEntities"]
516
559
 
517
560
  if "continuationToken" in resp_dict and resp_dict["continuationToken"] is not None:
518
- access_entities_next = self.get_access_entities(user_id, type, continuationToken=resp_dict["continuationToken"])
561
+ access_entities_next = self.list_access_entities(user_id, type, continuationToken=resp_dict["continuationToken"])
519
562
  resp_dict["accessEntities"].extend(access_entities_next)
520
563
 
521
564
  return access_entities
522
565
 
523
- def get_item_access_details(self, workspace_id, item_id, type=None):
566
+ def list_item_access_details(self, workspace_id, item_id, type=None):
524
567
  """Get the access details of the item
525
568
 
526
569
  Args:
@@ -532,4 +575,87 @@ class FabricClientAdmin(FabricClient):
532
575
  """
533
576
  ws = self.get_workspace(workspace_id)
534
577
  item = ws.get_item(item_id, type)
535
- return item.get_item_access_details(type)
578
+ return item.list_item_access_details(type)
579
+
580
+ def get_item_access_details(self, workspace_id, item_id, type=None):
581
+ """Get the access details of the item
582
+
583
+ Args:
584
+ workspace_id (str): The ID of the workspace
585
+ item_id (str): The ID of the item
586
+ type (str): The type of the item
587
+ Returns:
588
+ dict: The access details of the item
589
+ """
590
+ print("DEPRECATED: Use list_item_access_details instead")
591
+ return self.list_item_access_details(workspace_id, item_id, type)
592
+
593
+ def bulk_set_labels(self, items, label_id, assignment_method = None, delegated_principal = None):
594
+ """Set labels in bulk"""
595
+ # POST https://api.fabric.microsoft.com/v1/admin/items/bulkSetLabels
596
+
597
+ url = "https://api.fabric.microsoft.com/v1/admin/items/bulkSetLabels"
598
+
599
+ if len(items) > 2000:
600
+ self.bulk_set_labels(items[2000:], label_id, assignment_method, delegated_principal)
601
+ items = items[:2000]
602
+
603
+ body = {
604
+ "items": items,
605
+ "labelId": label_id
606
+ }
607
+ if assignment_method:
608
+ body["assignmentMethod"] = assignment_method
609
+
610
+ if delegated_principal:
611
+ body["delegatedPrincipal"] = delegated_principal
612
+
613
+ for _ in range(10):
614
+ response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
615
+ if response.status_code == 429:
616
+ print("Too many requests, waiting 10 seconds")
617
+ sleep(10)
618
+ continue
619
+ if response.status_code not in (200, 429):
620
+ print(response.status_code)
621
+ print(response.text)
622
+ raise Exception(f"Error setting labels: {response.text}")
623
+ break
624
+
625
+ response = json.loads(response.text)
626
+ return response
627
+
628
+
629
+ def bulk_remove_labels(self, items):
630
+ """Remove labels in bulk
631
+ Args:
632
+ items (list): The list of item IDs
633
+
634
+ Returns:
635
+ dict: The response from the API"""
636
+ # POST https://api.fabric.microsoft.com/v1/admin/items/bulkRemoveLabels
637
+
638
+ url = "https://api.fabric.microsoft.com/v1/admin/items/bulkRemoveLabels"
639
+
640
+ if len(items) > 2000:
641
+ self.bulk_remove_labels(items[2000:])
642
+ items = items[:2000]
643
+
644
+ body = {
645
+ "items": items
646
+ }
647
+
648
+ for _ in range(10):
649
+ response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
650
+ if response.status_code == 429:
651
+ print("Too many requests, waiting 10 seconds")
652
+ sleep(10)
653
+ continue
654
+ if response.status_code not in (200, 429):
655
+ print(response.status_code)
656
+ print(response.text)
657
+ raise Exception(f"Error removing labels: {response.text}")
658
+ break
659
+
660
+ response = json.loads(response.text)
661
+ return response
@@ -26,8 +26,9 @@ class FabricAuth():
26
26
  class FabricAuthClient(FabricAuth):
27
27
  """FabricAuthClient class to interact with Entra ID"""
28
28
 
29
- def __init__(self):
30
- print("Using Azure CLI for authentication")
29
+ def __init__(self, silent = False):
30
+ if not silent:
31
+ print("Using Azure CLI for authentication")
31
32
  self.auth = AzureCliCredential()
32
33
 
33
34
  def get_token(self):
@@ -38,8 +39,9 @@ class FabricAuthClient(FabricAuth):
38
39
  class FabricServicePrincipal(FabricAuth):
39
40
  """FabricServicePrincipal class to interact with Entra ID"""
40
41
 
41
- def __init__(self, tenant_id, client_id, client_secret):
42
- print("Using Service Principal for authentication")
42
+ def __init__(self, tenant_id, client_id, client_secret, silent = False):
43
+ if not silent:
44
+ print("Using Service Principal for authentication")
43
45
 
44
46
  self.tenant_id = tenant_id
45
47
  self.client_id = client_id
@@ -65,9 +67,10 @@ class FabricServicePrincipal(FabricAuth):
65
67
  class FabricSparkUtilsAuthentication(FabricAuth):
66
68
  """FabricSparkUtilsAuthentication class to interact with Entra ID"""
67
69
 
68
- def __init__(self):
70
+ def __init__(self, silent = False):
69
71
  mssparkutils.credentials.getToken("pbi")
70
- print("Using Synapse Spark Utils for authentication")
72
+ if not silent:
73
+ print("Using Synapse Spark Utils for authentication")
71
74
 
72
75
  def get_token(self):
73
76
  """Get token from Azure AD"""