msfabricpysdkcore 0.0.2__tar.gz → 0.0.4__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.
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/PKG-INFO +201 -19
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/README.md +201 -19
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/__init__.py +2 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/admin_item.py +106 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/admin_workspace.py +127 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/adminapi.py +535 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/capacity.py +56 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/client.py +22 -0
- msfabricpysdkcore-0.0.2/msfabricpysdkcore/client.py → msfabricpysdkcore-0.0.4/msfabricpysdkcore/coreapi.py +73 -32
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/domain.py +378 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore/item.py +19 -1
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore/job_instance.py +3 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/lakehouse.py +96 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore/onelakeshortcut.py +3 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/__init__.py +0 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_admin_apis.py +69 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_domains.py +125 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_git.py +62 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +69 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_jobs.py +39 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_shortcuts.py +53 -0
- msfabricpysdkcore-0.0.4/msfabricpysdkcore/tests/test_workspaces_capacities.py +146 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore/workspace.py +47 -7
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore.egg-info/PKG-INFO +201 -19
- msfabricpysdkcore-0.0.4/msfabricpysdkcore.egg-info/SOURCES.txt +32 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/pyproject.toml +1 -1
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/setup.py +1 -1
- msfabricpysdkcore-0.0.2/msfabricpysdkcore/__init__.py +0 -1
- msfabricpysdkcore-0.0.2/msfabricpysdkcore.egg-info/SOURCES.txt +0 -17
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore/auth.py +0 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore/long_running_operation.py +0 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore.egg-info/requires.txt +0 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
- {msfabricpysdkcore-0.0.2 → msfabricpysdkcore-0.0.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: msfabricpysdkcore
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.4
|
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
|
@@ -13,9 +13,9 @@ License-File: LICENSE
|
|
13
13
|
Requires-Dist: requests>=2.30.0
|
14
14
|
Requires-Dist: azure-identity>=1.15.0
|
15
15
|
|
16
|
-
#
|
16
|
+
# Python SDK for Microsoft Fabric
|
17
17
|
|
18
|
-
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs of Fabric*.
|
18
|
+
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs (v1) of Fabric*.
|
19
19
|
|
20
20
|

|
21
21
|
|
@@ -29,24 +29,35 @@ Additionally it brings some extra features like:
|
|
29
29
|
- Retry logic when hitting the API rate limits
|
30
30
|
- Referencing objects by name instead of ID
|
31
31
|
- More granular objects, e.g. a Workspace and Item object instead of referencing IDs all the time
|
32
|
-
- Do bulk operations
|
33
|
-
- Pagination support
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
-
|
39
|
-
- [
|
40
|
-
-
|
41
|
-
- [
|
42
|
-
- [
|
43
|
-
|
44
|
-
|
32
|
+
- Do bulk operations (see [Usage Patterns](usage_patterns.md))
|
33
|
+
- Pagination support
|
34
|
+
|
35
|
+
See the latest release notes [here](releasenotes/release_notes.md).
|
36
|
+
|
37
|
+
Currently it supports all Core APIs, Admin APIs and Lakehouse APIs, i.e.:
|
38
|
+
- Core APIs
|
39
|
+
- [Capacities](#working-with-capacities)
|
40
|
+
- [Git](#working-with-git)
|
41
|
+
- [Items](#working-with-items)
|
42
|
+
- [Job Scheduler](#working-with-job-scheduler)
|
43
|
+
- Long Running Operations
|
44
|
+
- [OneLakeShortcuts](#working-with-one-lake-shortcuts)
|
45
|
+
- [Workspaces](#working-with-workspaces)
|
46
|
+
- Lakehouse APIs
|
47
|
+
- [Tables](#tables)
|
48
|
+
- Admin APIs
|
49
|
+
- [Domains](#admin-api-for-domains)
|
50
|
+
- [Items](#admin-api-for-items)
|
51
|
+
- [Tenants](#admin-api-for-tenants)
|
52
|
+
- [Users](#admin-api-for-users)
|
53
|
+
- [Workspaces](#admin-api-for-workspaces)
|
54
|
+
|
55
|
+
It is planned to support also the APIs of the user experiences and new APIs which are not released yet.
|
56
|
+
Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
|
45
57
|
Eventually Power BI APIs like the Scanner API will be covered as well.
|
46
58
|
|
47
59
|
*Because this SDK uses the API in the background, all limitations and restrictions of the API apply to this SDK as well. This includes rate limits, permissions, etc.
|
48
60
|
|
49
|
-
**These features are not yet implemented but are planned for the near future.
|
50
61
|
|
51
62
|
|
52
63
|
|
@@ -160,11 +171,16 @@ ws.delete_role_assignment(principal_id = "abadfbafb")
|
|
160
171
|
|
161
172
|
```python
|
162
173
|
|
174
|
+
|
175
|
+
capacity_object = fc.get_capacity(capacity_id = "0129389012u8938491")
|
176
|
+
#or
|
177
|
+
capacity_object = fc.get_capacity(capacity_name = "sandboxcapacitygermanywc")
|
178
|
+
|
163
179
|
# Assign a capaycity to a workspace
|
164
180
|
fc.assign_to_capacity(workspace_id=workspace_id,
|
165
|
-
capacity_id=
|
181
|
+
capacity_id=capacity_object.id)
|
166
182
|
# or
|
167
|
-
ws.assign_to_capacity(capacity_id=
|
183
|
+
ws.assign_to_capacity(capacity_id=capacity_object.id)
|
168
184
|
|
169
185
|
# Unassign from capacity
|
170
186
|
fc.unassign_from_capacity(workspace_id=ws.id)
|
@@ -359,6 +375,172 @@ item.cancel_item_job_instance(job_instance_id="job_instance_id")
|
|
359
375
|
|
360
376
|
```
|
361
377
|
|
378
|
+
### Tables
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
```python
|
383
|
+
# List tables in a Lakehouse
|
384
|
+
|
385
|
+
from msfabricpysdkcore import FabricClientCore
|
386
|
+
|
387
|
+
fc = FabricClientCore()
|
388
|
+
ws = fc.get_workspace_by_name("testworkspace")
|
389
|
+
lakehouse = ws.get_item_by_name(item_name="lakehouse1", item_type="Lakehouse")
|
390
|
+
table_list = lakehouse.list_tables()
|
391
|
+
# or
|
392
|
+
table_list = ws.list_tables(item_id = "someitemid")
|
393
|
+
# or
|
394
|
+
table_list = fc.list_tables(workspace_id = "someworkspaceid", item_id = "someitemid")
|
395
|
+
|
396
|
+
|
397
|
+
# Load a file (like a csv) into a Lakehouse table
|
398
|
+
|
399
|
+
lakehouse.load_table(table_name="testtable", path_type= "File", relative_path="Files/folder1/titanic.csv")
|
400
|
+
# or
|
401
|
+
ws.load_table(item_id = "someitemid", table_name="testtable",
|
402
|
+
path_type= "File", relative_path="Files/folder1/titanic.csv")
|
403
|
+
# or
|
404
|
+
fc.load_table(workspace_id = "someworkspaceid", item_id = "someitemid", table_name="testtable",
|
405
|
+
path_type= "File", relative_path="Files/folder1/titanic.csv")
|
406
|
+
|
407
|
+
```
|
408
|
+
|
409
|
+
### Admin API for Workspaces
|
410
|
+
|
411
|
+
```python
|
412
|
+
from msfabricpysdkcore import FabricClientAdmin
|
413
|
+
|
414
|
+
fca = FabricClientAdmin()
|
415
|
+
|
416
|
+
|
417
|
+
# List workspaces
|
418
|
+
ws = fca.list_workspaces(name="testworkspace")[0]
|
419
|
+
|
420
|
+
# Get workspace
|
421
|
+
ws = fca.get_workspace(workspace_id="workspace_id")
|
422
|
+
|
423
|
+
# Get workspace access details
|
424
|
+
|
425
|
+
ws_access = fca.get_workspace_access_details("workspace_id")
|
426
|
+
# or
|
427
|
+
ws_access = ws.get_access_details()
|
428
|
+
```
|
429
|
+
|
430
|
+
### Admin API for Users
|
431
|
+
|
432
|
+
```python
|
433
|
+
from msfabricpysdkcore import FabricClientAdmin
|
434
|
+
|
435
|
+
fca = FabricClientAdmin()
|
436
|
+
|
437
|
+
# Get access entities
|
438
|
+
|
439
|
+
user_id = 'b4fuhaidc2'
|
440
|
+
access_entities = fca.get_access_entities(user_id, type="Notebook")
|
441
|
+
|
442
|
+
```
|
443
|
+
|
444
|
+
### Admin API for Tenants
|
445
|
+
|
446
|
+
```python
|
447
|
+
from msfabricpysdkcore import FabricClientAdmin
|
448
|
+
|
449
|
+
fca = FabricClientAdmin()
|
450
|
+
|
451
|
+
# Get tenant settings
|
452
|
+
|
453
|
+
tenant_settings = fca.get_tenant_settings()
|
454
|
+
|
455
|
+
# Get capacity tenant settings overrides
|
456
|
+
|
457
|
+
overrides = fca.get_capacities_tenant_settings_overrides()
|
458
|
+
|
459
|
+
```
|
460
|
+
|
461
|
+
### Admin API for Items
|
462
|
+
|
463
|
+
```python
|
464
|
+
from msfabricpysdkcore import FabricClientAdmin
|
465
|
+
|
466
|
+
fca = FabricClientAdmin()
|
467
|
+
|
468
|
+
# List items
|
469
|
+
|
470
|
+
item_list = fca.list_items(workspace_id="wsid")
|
471
|
+
|
472
|
+
# Get item
|
473
|
+
|
474
|
+
item = fca.get_item(workspace_id="wsid", item_id=item_list[0].id)
|
475
|
+
# or
|
476
|
+
item = ws.get_item(item_id=item_list[0].id)
|
477
|
+
|
478
|
+
# Get item access details
|
479
|
+
|
480
|
+
item_access = fca.get_item_access_details(workspace_id="wsid", item_id=item_list[0].id)
|
481
|
+
#or
|
482
|
+
item_access = ws.get_item_access_details(item_id=item_list[0].id)
|
483
|
+
# or
|
484
|
+
item_access = item.get_access_details()
|
485
|
+
|
486
|
+
```
|
487
|
+
|
488
|
+
### Admin API for Domains
|
489
|
+
|
490
|
+
```python
|
491
|
+
from msfabricpysdkcore import FabricClientAdmin
|
492
|
+
|
493
|
+
fca = FabricClientAdmin()
|
494
|
+
|
495
|
+
# Create domain
|
496
|
+
domain_name = "sdktestdomains"
|
497
|
+
domain = fca.create_domain(display_name=domain_name)
|
498
|
+
|
499
|
+
# Get domain by name
|
500
|
+
domain_clone = fca.get_domain_by_name(domain_name)
|
501
|
+
|
502
|
+
# Get domain by id
|
503
|
+
domain_clone = fca.get_domain_by_id(domain.id)
|
504
|
+
|
505
|
+
# List domains
|
506
|
+
domains = fca.list_domains()
|
507
|
+
|
508
|
+
# Update domain
|
509
|
+
domain_new_name = "sdktestdomains2"
|
510
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name)
|
511
|
+
|
512
|
+
# Assign domain workspaces by Ids
|
513
|
+
fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
514
|
+
|
515
|
+
# List domain workspaces
|
516
|
+
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
517
|
+
|
518
|
+
# Unassign domain workspaces by ids
|
519
|
+
status_code = fca.unassign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
520
|
+
|
521
|
+
# Assign domain workspaces by capacities
|
522
|
+
status_code = fca.assign_domain_workspaces_by_capacities(domain.id, ["cap_id1", "cap_id2"])
|
523
|
+
|
524
|
+
# Unassign all domain workspaces
|
525
|
+
status_code = fca.unassign_all_domain_workspaces(domain.id)
|
526
|
+
|
527
|
+
# Assign domain workspaces by principals
|
528
|
+
principal1 = {'id': '6edbsdfbfdgdf656', 'type': 'User'}
|
529
|
+
principal2 = {'id': '6eyxcbyyxc57', 'type': 'User'}
|
530
|
+
|
531
|
+
status_code = fca.assign_domains_workspaces_by_principals(domain.id, [principal1, principal2], wait_for_completion=True)
|
532
|
+
|
533
|
+
# Role assignments bulk assign
|
534
|
+
|
535
|
+
principals = [principal, principal_2]
|
536
|
+
status_code = fca.role_assignments_bulk_assign(domain.id, "Contributors", principals)
|
537
|
+
|
538
|
+
# Role assignments bulk unassign
|
539
|
+
status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [principal_2])
|
540
|
+
|
541
|
+
# Delete domain
|
542
|
+
status_code = fca.delete_domain(domain.id)
|
543
|
+
```
|
362
544
|
|
363
545
|
|
364
546
|
Note: This SDK is not an official SDK from Microsoft. It is a community project and not supported by Microsoft. Use it at your own risk.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Python SDK for Microsoft Fabric
|
2
2
|
|
3
|
-
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs of Fabric*.
|
3
|
+
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs (v1) of Fabric*.
|
4
4
|
|
5
5
|

|
6
6
|
|
@@ -14,24 +14,35 @@ Additionally it brings some extra features like:
|
|
14
14
|
- Retry logic when hitting the API rate limits
|
15
15
|
- Referencing objects by name instead of ID
|
16
16
|
- More granular objects, e.g. a Workspace and Item object instead of referencing IDs all the time
|
17
|
-
- Do bulk operations
|
18
|
-
- Pagination support
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
- [
|
25
|
-
-
|
26
|
-
- [
|
27
|
-
- [
|
28
|
-
|
29
|
-
|
17
|
+
- Do bulk operations (see [Usage Patterns](usage_patterns.md))
|
18
|
+
- Pagination support
|
19
|
+
|
20
|
+
See the latest release notes [here](releasenotes/release_notes.md).
|
21
|
+
|
22
|
+
Currently it supports all Core APIs, Admin APIs and Lakehouse APIs, i.e.:
|
23
|
+
- Core APIs
|
24
|
+
- [Capacities](#working-with-capacities)
|
25
|
+
- [Git](#working-with-git)
|
26
|
+
- [Items](#working-with-items)
|
27
|
+
- [Job Scheduler](#working-with-job-scheduler)
|
28
|
+
- Long Running Operations
|
29
|
+
- [OneLakeShortcuts](#working-with-one-lake-shortcuts)
|
30
|
+
- [Workspaces](#working-with-workspaces)
|
31
|
+
- Lakehouse APIs
|
32
|
+
- [Tables](#tables)
|
33
|
+
- Admin APIs
|
34
|
+
- [Domains](#admin-api-for-domains)
|
35
|
+
- [Items](#admin-api-for-items)
|
36
|
+
- [Tenants](#admin-api-for-tenants)
|
37
|
+
- [Users](#admin-api-for-users)
|
38
|
+
- [Workspaces](#admin-api-for-workspaces)
|
39
|
+
|
40
|
+
It is planned to support also the APIs of the user experiences and new APIs which are not released yet.
|
41
|
+
Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
|
30
42
|
Eventually Power BI APIs like the Scanner API will be covered as well.
|
31
43
|
|
32
44
|
*Because this SDK uses the API in the background, all limitations and restrictions of the API apply to this SDK as well. This includes rate limits, permissions, etc.
|
33
45
|
|
34
|
-
**These features are not yet implemented but are planned for the near future.
|
35
46
|
|
36
47
|
|
37
48
|
|
@@ -145,11 +156,16 @@ ws.delete_role_assignment(principal_id = "abadfbafb")
|
|
145
156
|
|
146
157
|
```python
|
147
158
|
|
159
|
+
|
160
|
+
capacity_object = fc.get_capacity(capacity_id = "0129389012u8938491")
|
161
|
+
#or
|
162
|
+
capacity_object = fc.get_capacity(capacity_name = "sandboxcapacitygermanywc")
|
163
|
+
|
148
164
|
# Assign a capaycity to a workspace
|
149
165
|
fc.assign_to_capacity(workspace_id=workspace_id,
|
150
|
-
capacity_id=
|
166
|
+
capacity_id=capacity_object.id)
|
151
167
|
# or
|
152
|
-
ws.assign_to_capacity(capacity_id=
|
168
|
+
ws.assign_to_capacity(capacity_id=capacity_object.id)
|
153
169
|
|
154
170
|
# Unassign from capacity
|
155
171
|
fc.unassign_from_capacity(workspace_id=ws.id)
|
@@ -344,7 +360,173 @@ item.cancel_item_job_instance(job_instance_id="job_instance_id")
|
|
344
360
|
|
345
361
|
```
|
346
362
|
|
363
|
+
### Tables
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
```python
|
368
|
+
# List tables in a Lakehouse
|
369
|
+
|
370
|
+
from msfabricpysdkcore import FabricClientCore
|
371
|
+
|
372
|
+
fc = FabricClientCore()
|
373
|
+
ws = fc.get_workspace_by_name("testworkspace")
|
374
|
+
lakehouse = ws.get_item_by_name(item_name="lakehouse1", item_type="Lakehouse")
|
375
|
+
table_list = lakehouse.list_tables()
|
376
|
+
# or
|
377
|
+
table_list = ws.list_tables(item_id = "someitemid")
|
378
|
+
# or
|
379
|
+
table_list = fc.list_tables(workspace_id = "someworkspaceid", item_id = "someitemid")
|
380
|
+
|
381
|
+
|
382
|
+
# Load a file (like a csv) into a Lakehouse table
|
383
|
+
|
384
|
+
lakehouse.load_table(table_name="testtable", path_type= "File", relative_path="Files/folder1/titanic.csv")
|
385
|
+
# or
|
386
|
+
ws.load_table(item_id = "someitemid", table_name="testtable",
|
387
|
+
path_type= "File", relative_path="Files/folder1/titanic.csv")
|
388
|
+
# or
|
389
|
+
fc.load_table(workspace_id = "someworkspaceid", item_id = "someitemid", table_name="testtable",
|
390
|
+
path_type= "File", relative_path="Files/folder1/titanic.csv")
|
391
|
+
|
392
|
+
```
|
393
|
+
|
394
|
+
### Admin API for Workspaces
|
395
|
+
|
396
|
+
```python
|
397
|
+
from msfabricpysdkcore import FabricClientAdmin
|
398
|
+
|
399
|
+
fca = FabricClientAdmin()
|
400
|
+
|
401
|
+
|
402
|
+
# List workspaces
|
403
|
+
ws = fca.list_workspaces(name="testworkspace")[0]
|
404
|
+
|
405
|
+
# Get workspace
|
406
|
+
ws = fca.get_workspace(workspace_id="workspace_id")
|
407
|
+
|
408
|
+
# Get workspace access details
|
409
|
+
|
410
|
+
ws_access = fca.get_workspace_access_details("workspace_id")
|
411
|
+
# or
|
412
|
+
ws_access = ws.get_access_details()
|
413
|
+
```
|
414
|
+
|
415
|
+
### Admin API for Users
|
416
|
+
|
417
|
+
```python
|
418
|
+
from msfabricpysdkcore import FabricClientAdmin
|
419
|
+
|
420
|
+
fca = FabricClientAdmin()
|
421
|
+
|
422
|
+
# Get access entities
|
423
|
+
|
424
|
+
user_id = 'b4fuhaidc2'
|
425
|
+
access_entities = fca.get_access_entities(user_id, type="Notebook")
|
426
|
+
|
427
|
+
```
|
428
|
+
|
429
|
+
### Admin API for Tenants
|
430
|
+
|
431
|
+
```python
|
432
|
+
from msfabricpysdkcore import FabricClientAdmin
|
433
|
+
|
434
|
+
fca = FabricClientAdmin()
|
435
|
+
|
436
|
+
# Get tenant settings
|
437
|
+
|
438
|
+
tenant_settings = fca.get_tenant_settings()
|
439
|
+
|
440
|
+
# Get capacity tenant settings overrides
|
441
|
+
|
442
|
+
overrides = fca.get_capacities_tenant_settings_overrides()
|
443
|
+
|
444
|
+
```
|
445
|
+
|
446
|
+
### Admin API for Items
|
447
|
+
|
448
|
+
```python
|
449
|
+
from msfabricpysdkcore import FabricClientAdmin
|
450
|
+
|
451
|
+
fca = FabricClientAdmin()
|
452
|
+
|
453
|
+
# List items
|
454
|
+
|
455
|
+
item_list = fca.list_items(workspace_id="wsid")
|
456
|
+
|
457
|
+
# Get item
|
458
|
+
|
459
|
+
item = fca.get_item(workspace_id="wsid", item_id=item_list[0].id)
|
460
|
+
# or
|
461
|
+
item = ws.get_item(item_id=item_list[0].id)
|
462
|
+
|
463
|
+
# Get item access details
|
464
|
+
|
465
|
+
item_access = fca.get_item_access_details(workspace_id="wsid", item_id=item_list[0].id)
|
466
|
+
#or
|
467
|
+
item_access = ws.get_item_access_details(item_id=item_list[0].id)
|
468
|
+
# or
|
469
|
+
item_access = item.get_access_details()
|
470
|
+
|
471
|
+
```
|
472
|
+
|
473
|
+
### Admin API for Domains
|
474
|
+
|
475
|
+
```python
|
476
|
+
from msfabricpysdkcore import FabricClientAdmin
|
477
|
+
|
478
|
+
fca = FabricClientAdmin()
|
479
|
+
|
480
|
+
# Create domain
|
481
|
+
domain_name = "sdktestdomains"
|
482
|
+
domain = fca.create_domain(display_name=domain_name)
|
483
|
+
|
484
|
+
# Get domain by name
|
485
|
+
domain_clone = fca.get_domain_by_name(domain_name)
|
486
|
+
|
487
|
+
# Get domain by id
|
488
|
+
domain_clone = fca.get_domain_by_id(domain.id)
|
489
|
+
|
490
|
+
# List domains
|
491
|
+
domains = fca.list_domains()
|
492
|
+
|
493
|
+
# Update domain
|
494
|
+
domain_new_name = "sdktestdomains2"
|
495
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name)
|
496
|
+
|
497
|
+
# Assign domain workspaces by Ids
|
498
|
+
fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
499
|
+
|
500
|
+
# List domain workspaces
|
501
|
+
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
502
|
+
|
503
|
+
# Unassign domain workspaces by ids
|
504
|
+
status_code = fca.unassign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
505
|
+
|
506
|
+
# Assign domain workspaces by capacities
|
507
|
+
status_code = fca.assign_domain_workspaces_by_capacities(domain.id, ["cap_id1", "cap_id2"])
|
508
|
+
|
509
|
+
# Unassign all domain workspaces
|
510
|
+
status_code = fca.unassign_all_domain_workspaces(domain.id)
|
511
|
+
|
512
|
+
# Assign domain workspaces by principals
|
513
|
+
principal1 = {'id': '6edbsdfbfdgdf656', 'type': 'User'}
|
514
|
+
principal2 = {'id': '6eyxcbyyxc57', 'type': 'User'}
|
515
|
+
|
516
|
+
status_code = fca.assign_domains_workspaces_by_principals(domain.id, [principal1, principal2], wait_for_completion=True)
|
517
|
+
|
518
|
+
# Role assignments bulk assign
|
519
|
+
|
520
|
+
principals = [principal, principal_2]
|
521
|
+
status_code = fca.role_assignments_bulk_assign(domain.id, "Contributors", principals)
|
522
|
+
|
523
|
+
# Role assignments bulk unassign
|
524
|
+
status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [principal_2])
|
525
|
+
|
526
|
+
# Delete domain
|
527
|
+
status_code = fca.delete_domain(domain.id)
|
528
|
+
```
|
347
529
|
|
348
530
|
|
349
531
|
Note: This SDK is not an official SDK from Microsoft. It is a community project and not supported by Microsoft. Use it at your own risk.
|
350
|
-
Also the API is still in preview and might change. This SDK is not yet feature complete and might not cover all APIs yet. Feel free to contribute to this project to make it better.
|
532
|
+
Also the API is still in preview and might change. This SDK is not yet feature complete and might not cover all APIs yet. Feel free to contribute to this project to make it better.
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import json
|
2
|
+
from time import sleep
|
3
|
+
|
4
|
+
import requests
|
5
|
+
|
6
|
+
|
7
|
+
class AdminItem:
|
8
|
+
"""Class to represent a item in Microsoft Fabric"""
|
9
|
+
|
10
|
+
def __init__(self, id, type, name, workspace_id, state, description, last_updated_date, capacity_id, creator_principal, auth) -> None:
|
11
|
+
"""Constructor for the Item class
|
12
|
+
|
13
|
+
Args:
|
14
|
+
id (str): The ID of the item
|
15
|
+
type (str): The type of the item
|
16
|
+
name (str): The name of the item
|
17
|
+
workspace_id (str): The ID of the workspace
|
18
|
+
state (str): The state of the item
|
19
|
+
description (str): The description of the item
|
20
|
+
last_updated_date (str): The last updated date of the item
|
21
|
+
capacity_id (str): The ID of the capacity
|
22
|
+
creator_principal (dict): The creator principal of the item
|
23
|
+
auth (Auth): The Auth object
|
24
|
+
Returns:
|
25
|
+
Item: The Item object
|
26
|
+
"""
|
27
|
+
self.id = id
|
28
|
+
self.type = type
|
29
|
+
self.name = name
|
30
|
+
self.workspace_id = workspace_id
|
31
|
+
self.state = state
|
32
|
+
self.description = description
|
33
|
+
self.last_updated_date = last_updated_date
|
34
|
+
self.capacity_id = capacity_id
|
35
|
+
self.creator_principal = creator_principal
|
36
|
+
self.auth = auth
|
37
|
+
|
38
|
+
|
39
|
+
def __str__(self) -> str:
|
40
|
+
"""Return a string representation of the workspace object
|
41
|
+
|
42
|
+
Returns:
|
43
|
+
str: The string representation of the workspace object
|
44
|
+
"""
|
45
|
+
dict_ = {
|
46
|
+
'id': self.id,
|
47
|
+
'type': self.type,
|
48
|
+
'name': self.name,
|
49
|
+
'workspace_id': self.workspace_id,
|
50
|
+
'state': self.state,
|
51
|
+
'description': self.description,
|
52
|
+
'last_updated_date': self.last_updated_date,
|
53
|
+
'capacity_id': self.capacity_id,
|
54
|
+
'creator_principal': self.creator_principal
|
55
|
+
}
|
56
|
+
return json.dumps(dict_, indent=2)
|
57
|
+
|
58
|
+
|
59
|
+
def __repr__(self) -> str:
|
60
|
+
return self.__str__()
|
61
|
+
|
62
|
+
def from_dict(item_dict, auth):
|
63
|
+
"""Create Item object from dictionary
|
64
|
+
|
65
|
+
Args:
|
66
|
+
item_dict (dict): The dictionary containing the item information
|
67
|
+
auth (Auth): The Auth object
|
68
|
+
Returns:
|
69
|
+
Item: The Item object"""
|
70
|
+
return AdminItem(
|
71
|
+
id = item_dict['id'],
|
72
|
+
type = item_dict['type'],
|
73
|
+
name = item_dict['name'],
|
74
|
+
workspace_id = item_dict['workspaceId'],
|
75
|
+
state = item_dict['state'],
|
76
|
+
description = item_dict.get('description', None),
|
77
|
+
last_updated_date = item_dict['lastUpdatedDate'],
|
78
|
+
capacity_id = item_dict['capacityId'],
|
79
|
+
creator_principal = item_dict['creatorPrincipal'],
|
80
|
+
auth = auth
|
81
|
+
)
|
82
|
+
|
83
|
+
def get_item_access_details(self, type=None):
|
84
|
+
"""Get the access details of the item
|
85
|
+
|
86
|
+
Returns:
|
87
|
+
dict: The access details of the item"""
|
88
|
+
|
89
|
+
url = f"https://api.fabric.microsoft.com/v1/admin/workspaces/{self.workspace_id}/items/{self.id}/users"
|
90
|
+
|
91
|
+
if type:
|
92
|
+
url += f"?type={self.type}"
|
93
|
+
|
94
|
+
for _ in range(10):
|
95
|
+
response = requests.get(url=url, headers=self.auth.get_headers())
|
96
|
+
if response.status_code == 429:
|
97
|
+
print("Too many requests, waiting 10 seconds")
|
98
|
+
sleep(10)
|
99
|
+
continue
|
100
|
+
if response.status_code not in (200, 429):
|
101
|
+
print(response.status_code)
|
102
|
+
print(response.text)
|
103
|
+
raise Exception(f"Error getting item: {response.text}")
|
104
|
+
break
|
105
|
+
|
106
|
+
return json.loads(response.text)
|