msfabricpysdkcore 0.0.12__tar.gz → 0.1.1__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.12 → msfabricpysdkcore-0.1.1}/PKG-INFO +110 -8
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/README.md +109 -7
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/admin_item.py +18 -44
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/admin_workspace.py +99 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/adminapi.py +632 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/client.py +140 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/coreapi.py +2804 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/deployment_pipeline.py +128 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/domain.py +179 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/environment.py +51 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/item.py +136 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/job_instance.py +8 -22
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/lakehouse.py +27 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/long_running_operation.py +49 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/onelakeshortcut.py +7 -21
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/otheritems.py +195 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/spark_custom_pool.py +7 -47
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_admin_apis.py +21 -1
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_datapipelines.py +14 -17
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_domains.py +4 -3
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_environments.py +51 -2
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_evenhouses.py +48 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_evenstreams.py +1 -1
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_items.py +80 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_kql_queryset.py +50 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_kqldatabases.py +1 -1
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_lakehouse.py +86 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_ml_experiments.py +48 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_ml_models.py +48 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_notebooks.py +58 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +65 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_other_items.py +46 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_reports.py +53 -0
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_semantic_model.py +51 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_spark.py +7 -5
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_warehouses.py +51 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_workspaces_capacities.py +7 -4
- msfabricpysdkcore-0.1.1/msfabricpysdkcore/workspace.py +750 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/PKG-INFO +110 -8
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/SOURCES.txt +13 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/pyproject.toml +1 -1
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/setup.py +1 -1
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/admin_workspace.py +0 -146
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/adminapi.py +0 -661
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/client.py +0 -26
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/coreapi.py +0 -1014
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/deployment_pipeline.py +0 -240
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/domain.py +0 -378
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/environment.py +0 -209
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/item.py +0 -271
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/lakehouse.py +0 -136
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/long_running_operation.py +0 -79
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/otheritems.py +0 -220
- msfabricpysdkcore-0.0.12/msfabricpysdkcore/workspace.py +0 -1474
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/__init__.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/auth.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/capacity.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/__init__.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_git.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_jobs.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_shortcuts.py +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/requires.txt +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
- {msfabricpysdkcore-0.0.12 → msfabricpysdkcore-0.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: msfabricpysdkcore
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1.1
|
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
|
@@ -24,7 +24,7 @@ They are designed to automate your Fabric processes.
|
|
24
24
|
|
25
25
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
26
26
|
Additionally it brings some extra features like:
|
27
|
-
- Authentication is handled for you (currently Azure CLI Authentication
|
27
|
+
- Authentication is handled for you (currently Azure CLI Authentication, Authentication from a Microsoft Fabric notebook and Service Principal Authentication are supported)
|
28
28
|
- Waiting for completion of long running operations
|
29
29
|
- Retry logic when hitting the API rate limits
|
30
30
|
- Referencing objects by name instead of ID
|
@@ -38,14 +38,17 @@ Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other it
|
|
38
38
|
- Core APIs
|
39
39
|
- [Capacities](#working-with-capacities)
|
40
40
|
- [Deployment Pipelines](#deployment-pipelines)
|
41
|
+
- [External Data Shares](#external-data-shares)
|
41
42
|
- [Git](#working-with-git)
|
42
43
|
- [Items](#working-with-items)
|
43
44
|
- [Job Scheduler](#working-with-job-scheduler)
|
44
45
|
- [Long Running Operations](#long-running-operations)
|
46
|
+
- [OneLakeDataAccessSecurity](#one-lake-data-access-security)
|
45
47
|
- [OneLakeShortcuts](#working-with-one-lake-shortcuts)
|
46
48
|
- [Workspaces](#working-with-workspaces)
|
47
49
|
- Admin APIs
|
48
50
|
- [Domains](#admin-api-for-domains)
|
51
|
+
- [External Data Shares](#admin-api-for-external-data-shares)
|
49
52
|
- [Items](#admin-api-for-items)
|
50
53
|
- [Labels](#admin-api-for-labels)
|
51
54
|
- [Tenants](#admin-api-for-tenants)
|
@@ -82,6 +85,7 @@ from msfabricpysdkcore import FabricClientCore
|
|
82
85
|
# Create a client
|
83
86
|
|
84
87
|
# Either login with the Azure CLI first and initiate the client directly
|
88
|
+
# This also works directly in a Microsoft Fabric notebook
|
85
89
|
fc = FabricClientCore()
|
86
90
|
|
87
91
|
# Or use a service principal (note that not all APIs are supported with service principal)
|
@@ -227,7 +231,7 @@ pipe = fc.get_deployment_pipeline(pipe_id)
|
|
227
231
|
|
228
232
|
|
229
233
|
# Get deployment pipeline stages
|
230
|
-
stages = fc.
|
234
|
+
stages = fc.list_deployment_pipeline_stages(pipe_id)
|
231
235
|
|
232
236
|
names = [stage.display_name for stage in stages]
|
233
237
|
|
@@ -235,7 +239,7 @@ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0
|
|
235
239
|
prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
|
236
240
|
|
237
241
|
# Get deployment pipeline stages items
|
238
|
-
items = fc.
|
242
|
+
items = fc.list_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
|
239
243
|
|
240
244
|
|
241
245
|
items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
|
@@ -249,6 +253,43 @@ response = pipe.deploy(source_stage_id=dev_stage.id,target_stage_id=prod_stage.i
|
|
249
253
|
|
250
254
|
```
|
251
255
|
|
256
|
+
### External Data Shares
|
257
|
+
|
258
|
+
```python
|
259
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
260
|
+
|
261
|
+
fc = FabricClientCore()
|
262
|
+
|
263
|
+
workspace_id = 'yxcvyxcvyxcv'
|
264
|
+
item_id = 'sdfsdfsdfsf'
|
265
|
+
|
266
|
+
|
267
|
+
# Create
|
268
|
+
|
269
|
+
recipient = {
|
270
|
+
"userPrincipalName": "lisa4@fabrikam.com"
|
271
|
+
}
|
272
|
+
paths=["Files/external"]
|
273
|
+
|
274
|
+
data_share = fc.create_external_data_share(workspace_id, item_id, paths, recipient)
|
275
|
+
|
276
|
+
# Get
|
277
|
+
|
278
|
+
data_share2 = fc.get_external_data_share(workspace_id, item_id, data_share['id'])
|
279
|
+
|
280
|
+
# List
|
281
|
+
|
282
|
+
data_share_list = fc.list_external_data_shares_in_item(workspace_id, item_id)
|
283
|
+
|
284
|
+
data_share_ids = [ds['id'] for ds in data_share_list]
|
285
|
+
|
286
|
+
# Revoke
|
287
|
+
|
288
|
+
response_code = fc.revoke_external_data_share(workspace_id, item_id, data_share['id'])
|
289
|
+
|
290
|
+
```
|
291
|
+
|
292
|
+
|
252
293
|
### Working with items
|
253
294
|
|
254
295
|
```python
|
@@ -272,11 +313,11 @@ item_list = ws.list_items()
|
|
272
313
|
|
273
314
|
|
274
315
|
# Update an item
|
275
|
-
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None)
|
316
|
+
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None, return_item=True)
|
276
317
|
# or
|
277
|
-
ws.update_item(item_id="item_id", display_name="new_item_name", description = None)
|
318
|
+
ws.update_item(item_id="item_id", display_name="new_item_name", description = None, return_item=True)
|
278
319
|
# or
|
279
|
-
item.update(display_name="new_item_name", description = None)
|
320
|
+
item.update(display_name="new_item_name", description = None, return_item=True)
|
280
321
|
|
281
322
|
|
282
323
|
# Delete an item
|
@@ -452,6 +493,44 @@ results = fc.get_operation_results(operation_id)
|
|
452
493
|
|
453
494
|
```
|
454
495
|
|
496
|
+
### One Lake Data Access Security
|
497
|
+
|
498
|
+
```python
|
499
|
+
from msfabricpysdkcore import FabricClientCore
|
500
|
+
|
501
|
+
fc = FabricClientCore()
|
502
|
+
|
503
|
+
workspace_id = "d8aafgasdsdbe5"
|
504
|
+
item_id = "503hsdfhs48364"
|
505
|
+
|
506
|
+
# List
|
507
|
+
|
508
|
+
resp = fc.list_data_access_roles(workspace_id=workspace_id, item_id=item_id)
|
509
|
+
|
510
|
+
roles = resp[0]
|
511
|
+
etag = resp[1]
|
512
|
+
|
513
|
+
|
514
|
+
# Create or Update
|
515
|
+
|
516
|
+
role1 = roles[1]
|
517
|
+
|
518
|
+
item_access = role1["members"]["fabricItemMembers"][0]['itemAccess']
|
519
|
+
+
|
520
|
+
if 'ReadAll' in item_access:
|
521
|
+
item_access = ['Read', 'Write', 'Execute']
|
522
|
+
else:
|
523
|
+
item_access.append('ReadAll')
|
524
|
+
|
525
|
+
role1["members"]["fabricItemMembers"][0]['itemAccess'] = item_access
|
526
|
+
roles[1] = role1
|
527
|
+
|
528
|
+
resp = fc.create_or_update_data_access_roles(workspace_id=workspace_id,
|
529
|
+
item_id=item_id,
|
530
|
+
data_access_roles=roles,
|
531
|
+
etag_match={"If-Match":etag})
|
532
|
+
|
533
|
+
```
|
455
534
|
|
456
535
|
### Admin API for Workspaces
|
457
536
|
|
@@ -576,7 +655,7 @@ domains = fca.list_domains()
|
|
576
655
|
|
577
656
|
# Update domain
|
578
657
|
domain_new_name = "sdktestdomains2"
|
579
|
-
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name)
|
658
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name, return_item=True)
|
580
659
|
|
581
660
|
# Assign domain workspaces by Ids
|
582
661
|
fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
@@ -611,6 +690,29 @@ status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [pri
|
|
611
690
|
status_code = fca.delete_domain(domain.id)
|
612
691
|
```
|
613
692
|
|
693
|
+
### Admin API for External Data Shares
|
694
|
+
|
695
|
+
```python
|
696
|
+
from msfabricpysdkcore import FabricClientAdmin
|
697
|
+
|
698
|
+
fca = FabricClientAdmin()
|
699
|
+
|
700
|
+
# List external data shares
|
701
|
+
|
702
|
+
data_shares = fca.list_external_data_shares()
|
703
|
+
ws = fca.list_workspaces(name="testworkspace")[0]
|
704
|
+
|
705
|
+
data_shares = [d for d in data_shares if d['workspaceId'] == ws.id]
|
706
|
+
|
707
|
+
# Revoke external data share
|
708
|
+
|
709
|
+
fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
710
|
+
item_id = data_shares[0]['itemId'],
|
711
|
+
workspace_id = data_shares[0]['workspaceId'])
|
712
|
+
|
713
|
+
|
714
|
+
```
|
715
|
+
|
614
716
|
|
615
717
|
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.
|
616
718
|
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.
|
@@ -9,7 +9,7 @@ They are designed to automate your Fabric processes.
|
|
9
9
|
|
10
10
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
11
11
|
Additionally it brings some extra features like:
|
12
|
-
- Authentication is handled for you (currently Azure CLI Authentication
|
12
|
+
- Authentication is handled for you (currently Azure CLI Authentication, Authentication from a Microsoft Fabric notebook and Service Principal Authentication are supported)
|
13
13
|
- Waiting for completion of long running operations
|
14
14
|
- Retry logic when hitting the API rate limits
|
15
15
|
- Referencing objects by name instead of ID
|
@@ -23,14 +23,17 @@ Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other it
|
|
23
23
|
- Core APIs
|
24
24
|
- [Capacities](#working-with-capacities)
|
25
25
|
- [Deployment Pipelines](#deployment-pipelines)
|
26
|
+
- [External Data Shares](#external-data-shares)
|
26
27
|
- [Git](#working-with-git)
|
27
28
|
- [Items](#working-with-items)
|
28
29
|
- [Job Scheduler](#working-with-job-scheduler)
|
29
30
|
- [Long Running Operations](#long-running-operations)
|
31
|
+
- [OneLakeDataAccessSecurity](#one-lake-data-access-security)
|
30
32
|
- [OneLakeShortcuts](#working-with-one-lake-shortcuts)
|
31
33
|
- [Workspaces](#working-with-workspaces)
|
32
34
|
- Admin APIs
|
33
35
|
- [Domains](#admin-api-for-domains)
|
36
|
+
- [External Data Shares](#admin-api-for-external-data-shares)
|
34
37
|
- [Items](#admin-api-for-items)
|
35
38
|
- [Labels](#admin-api-for-labels)
|
36
39
|
- [Tenants](#admin-api-for-tenants)
|
@@ -67,6 +70,7 @@ from msfabricpysdkcore import FabricClientCore
|
|
67
70
|
# Create a client
|
68
71
|
|
69
72
|
# Either login with the Azure CLI first and initiate the client directly
|
73
|
+
# This also works directly in a Microsoft Fabric notebook
|
70
74
|
fc = FabricClientCore()
|
71
75
|
|
72
76
|
# Or use a service principal (note that not all APIs are supported with service principal)
|
@@ -212,7 +216,7 @@ pipe = fc.get_deployment_pipeline(pipe_id)
|
|
212
216
|
|
213
217
|
|
214
218
|
# Get deployment pipeline stages
|
215
|
-
stages = fc.
|
219
|
+
stages = fc.list_deployment_pipeline_stages(pipe_id)
|
216
220
|
|
217
221
|
names = [stage.display_name for stage in stages]
|
218
222
|
|
@@ -220,7 +224,7 @@ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0
|
|
220
224
|
prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
|
221
225
|
|
222
226
|
# Get deployment pipeline stages items
|
223
|
-
items = fc.
|
227
|
+
items = fc.list_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
|
224
228
|
|
225
229
|
|
226
230
|
items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
|
@@ -234,6 +238,43 @@ response = pipe.deploy(source_stage_id=dev_stage.id,target_stage_id=prod_stage.i
|
|
234
238
|
|
235
239
|
```
|
236
240
|
|
241
|
+
### External Data Shares
|
242
|
+
|
243
|
+
```python
|
244
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
245
|
+
|
246
|
+
fc = FabricClientCore()
|
247
|
+
|
248
|
+
workspace_id = 'yxcvyxcvyxcv'
|
249
|
+
item_id = 'sdfsdfsdfsf'
|
250
|
+
|
251
|
+
|
252
|
+
# Create
|
253
|
+
|
254
|
+
recipient = {
|
255
|
+
"userPrincipalName": "lisa4@fabrikam.com"
|
256
|
+
}
|
257
|
+
paths=["Files/external"]
|
258
|
+
|
259
|
+
data_share = fc.create_external_data_share(workspace_id, item_id, paths, recipient)
|
260
|
+
|
261
|
+
# Get
|
262
|
+
|
263
|
+
data_share2 = fc.get_external_data_share(workspace_id, item_id, data_share['id'])
|
264
|
+
|
265
|
+
# List
|
266
|
+
|
267
|
+
data_share_list = fc.list_external_data_shares_in_item(workspace_id, item_id)
|
268
|
+
|
269
|
+
data_share_ids = [ds['id'] for ds in data_share_list]
|
270
|
+
|
271
|
+
# Revoke
|
272
|
+
|
273
|
+
response_code = fc.revoke_external_data_share(workspace_id, item_id, data_share['id'])
|
274
|
+
|
275
|
+
```
|
276
|
+
|
277
|
+
|
237
278
|
### Working with items
|
238
279
|
|
239
280
|
```python
|
@@ -257,11 +298,11 @@ item_list = ws.list_items()
|
|
257
298
|
|
258
299
|
|
259
300
|
# Update an item
|
260
|
-
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None)
|
301
|
+
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None, return_item=True)
|
261
302
|
# or
|
262
|
-
ws.update_item(item_id="item_id", display_name="new_item_name", description = None)
|
303
|
+
ws.update_item(item_id="item_id", display_name="new_item_name", description = None, return_item=True)
|
263
304
|
# or
|
264
|
-
item.update(display_name="new_item_name", description = None)
|
305
|
+
item.update(display_name="new_item_name", description = None, return_item=True)
|
265
306
|
|
266
307
|
|
267
308
|
# Delete an item
|
@@ -437,6 +478,44 @@ results = fc.get_operation_results(operation_id)
|
|
437
478
|
|
438
479
|
```
|
439
480
|
|
481
|
+
### One Lake Data Access Security
|
482
|
+
|
483
|
+
```python
|
484
|
+
from msfabricpysdkcore import FabricClientCore
|
485
|
+
|
486
|
+
fc = FabricClientCore()
|
487
|
+
|
488
|
+
workspace_id = "d8aafgasdsdbe5"
|
489
|
+
item_id = "503hsdfhs48364"
|
490
|
+
|
491
|
+
# List
|
492
|
+
|
493
|
+
resp = fc.list_data_access_roles(workspace_id=workspace_id, item_id=item_id)
|
494
|
+
|
495
|
+
roles = resp[0]
|
496
|
+
etag = resp[1]
|
497
|
+
|
498
|
+
|
499
|
+
# Create or Update
|
500
|
+
|
501
|
+
role1 = roles[1]
|
502
|
+
|
503
|
+
item_access = role1["members"]["fabricItemMembers"][0]['itemAccess']
|
504
|
+
+
|
505
|
+
if 'ReadAll' in item_access:
|
506
|
+
item_access = ['Read', 'Write', 'Execute']
|
507
|
+
else:
|
508
|
+
item_access.append('ReadAll')
|
509
|
+
|
510
|
+
role1["members"]["fabricItemMembers"][0]['itemAccess'] = item_access
|
511
|
+
roles[1] = role1
|
512
|
+
|
513
|
+
resp = fc.create_or_update_data_access_roles(workspace_id=workspace_id,
|
514
|
+
item_id=item_id,
|
515
|
+
data_access_roles=roles,
|
516
|
+
etag_match={"If-Match":etag})
|
517
|
+
|
518
|
+
```
|
440
519
|
|
441
520
|
### Admin API for Workspaces
|
442
521
|
|
@@ -561,7 +640,7 @@ domains = fca.list_domains()
|
|
561
640
|
|
562
641
|
# Update domain
|
563
642
|
domain_new_name = "sdktestdomains2"
|
564
|
-
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name)
|
643
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name, return_item=True)
|
565
644
|
|
566
645
|
# Assign domain workspaces by Ids
|
567
646
|
fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
@@ -596,6 +675,29 @@ status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [pri
|
|
596
675
|
status_code = fca.delete_domain(domain.id)
|
597
676
|
```
|
598
677
|
|
678
|
+
### Admin API for External Data Shares
|
679
|
+
|
680
|
+
```python
|
681
|
+
from msfabricpysdkcore import FabricClientAdmin
|
682
|
+
|
683
|
+
fca = FabricClientAdmin()
|
684
|
+
|
685
|
+
# List external data shares
|
686
|
+
|
687
|
+
data_shares = fca.list_external_data_shares()
|
688
|
+
ws = fca.list_workspaces(name="testworkspace")[0]
|
689
|
+
|
690
|
+
data_shares = [d for d in data_shares if d['workspaceId'] == ws.id]
|
691
|
+
|
692
|
+
# Revoke external data share
|
693
|
+
|
694
|
+
fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
695
|
+
item_id = data_shares[0]['itemId'],
|
696
|
+
workspace_id = data_shares[0]['workspaceId'])
|
697
|
+
|
698
|
+
|
699
|
+
```
|
700
|
+
|
599
701
|
|
600
702
|
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.
|
601
703
|
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.
|
@@ -1,29 +1,26 @@
|
|
1
1
|
import json
|
2
|
-
from
|
3
|
-
|
4
|
-
import requests
|
2
|
+
from msfabricpysdkcore.adminapi import FabricClientAdmin
|
5
3
|
|
6
4
|
|
7
5
|
class AdminItem:
|
8
6
|
"""Class to represent a item in Microsoft Fabric"""
|
9
7
|
|
10
|
-
def __init__(self, id, type, name, workspace_id, state, description, last_updated_date, capacity_id, creator_principal,
|
8
|
+
def __init__(self, id, type, name, workspace_id, state, description, last_updated_date, capacity_id, creator_principal, admin_client: FabricClientAdmin) -> None:
|
11
9
|
"""Constructor for the Item class
|
12
10
|
|
13
11
|
Args:
|
14
12
|
id (str): The ID of the item
|
15
13
|
type (str): The type of the item
|
16
14
|
name (str): The name of the item
|
17
|
-
workspace_id (str): The ID of the workspace
|
15
|
+
workspace_id (str): The ID of the workspace to which the item belongs
|
18
16
|
state (str): The state of the item
|
19
17
|
description (str): The description of the item
|
20
|
-
last_updated_date (str): The
|
21
|
-
capacity_id (str): The
|
22
|
-
creator_principal (
|
23
|
-
|
24
|
-
Returns:
|
25
|
-
Item: The Item object
|
18
|
+
last_updated_date (str): The date when the item was last updated
|
19
|
+
capacity_id (str): The
|
20
|
+
creator_principal (str): The principal who created the item
|
21
|
+
admin_client (FabricClientAdmin): The FabricClientAdmin object
|
26
22
|
"""
|
23
|
+
|
27
24
|
self.id = id
|
28
25
|
self.type = type
|
29
26
|
self.name = name
|
@@ -33,7 +30,7 @@ class AdminItem:
|
|
33
30
|
self.last_updated_date = last_updated_date
|
34
31
|
self.capacity_id = capacity_id
|
35
32
|
self.creator_principal = creator_principal
|
36
|
-
self.
|
33
|
+
self.admin_client = admin_client
|
37
34
|
|
38
35
|
|
39
36
|
def __str__(self) -> str:
|
@@ -59,55 +56,32 @@ class AdminItem:
|
|
59
56
|
def __repr__(self) -> str:
|
60
57
|
return self.__str__()
|
61
58
|
|
62
|
-
def from_dict(item_dict,
|
59
|
+
def from_dict(item_dict, admin_client):
|
63
60
|
"""Create Item object from dictionary
|
64
61
|
|
65
62
|
Args:
|
66
|
-
item_dict (dict): The dictionary containing the item
|
67
|
-
|
63
|
+
item_dict (dict): The dictionary containing the item details
|
64
|
+
admin_client (FabricClientAdmin): The FabricClientAdmin object
|
68
65
|
Returns:
|
69
|
-
|
66
|
+
AdminItem: The AdminItem object
|
67
|
+
"""
|
70
68
|
return AdminItem(
|
71
69
|
id = item_dict['id'],
|
72
70
|
type = item_dict['type'],
|
73
|
-
name = item_dict
|
71
|
+
name = item_dict.get('name', None),
|
74
72
|
workspace_id = item_dict['workspaceId'],
|
75
73
|
state = item_dict['state'],
|
76
74
|
description = item_dict.get('description', None),
|
77
75
|
last_updated_date = item_dict['lastUpdatedDate'],
|
78
76
|
capacity_id = item_dict['capacityId'],
|
79
77
|
creator_principal = item_dict['creatorPrincipal'],
|
80
|
-
|
78
|
+
admin_client = admin_client
|
81
79
|
)
|
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
|
-
return self.list_item_access_details(type)
|
89
|
-
|
80
|
+
|
90
81
|
def list_item_access_details(self, type=None):
|
91
82
|
"""Get the access details of the item
|
92
83
|
|
93
84
|
Returns:
|
94
85
|
dict: The access details of the item"""
|
95
86
|
|
96
|
-
|
97
|
-
|
98
|
-
if type:
|
99
|
-
url += f"?type={self.type}"
|
100
|
-
|
101
|
-
for _ in range(10):
|
102
|
-
response = requests.get(url=url, headers=self.auth.get_headers())
|
103
|
-
if response.status_code == 429:
|
104
|
-
print("Too many requests, waiting 10 seconds")
|
105
|
-
sleep(10)
|
106
|
-
continue
|
107
|
-
if response.status_code not in (200, 429):
|
108
|
-
print(response.status_code)
|
109
|
-
print(response.text)
|
110
|
-
raise Exception(f"Error getting item: {response.text}")
|
111
|
-
break
|
112
|
-
|
113
|
-
return json.loads(response.text)
|
87
|
+
return self.admin_client.list_item_access_details(self.workspace_id, self.id, type)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import json
|
2
|
+
from time import sleep
|
3
|
+
|
4
|
+
from msfabricpysdkcore.admin_item import AdminItem
|
5
|
+
from msfabricpysdkcore.adminapi import FabricClientAdmin
|
6
|
+
|
7
|
+
|
8
|
+
class AdminWorkspace:
|
9
|
+
"""Class to represent a workspace in Microsoft Fabric"""
|
10
|
+
|
11
|
+
def __init__(self, id, type, name, state, capacity_id, admin_client:FabricClientAdmin) -> None:
|
12
|
+
"""Constructor for the Workspace class
|
13
|
+
|
14
|
+
Args:
|
15
|
+
id (str): The ID of the workspace
|
16
|
+
type (str): The type of the workspace
|
17
|
+
name (str): The name of the workspace
|
18
|
+
state (str): The state of the workspace
|
19
|
+
capacity_id (str): The ID of the capacity
|
20
|
+
admin_client (FabricClientAdmin): The FabricClientAdmin object
|
21
|
+
Returns:
|
22
|
+
Workspace: The Workspace object
|
23
|
+
"""
|
24
|
+
self.id = id
|
25
|
+
self.type = type
|
26
|
+
self.name = name
|
27
|
+
self.state = state
|
28
|
+
self.capacity_id = capacity_id
|
29
|
+
self.admin_client = admin_client
|
30
|
+
|
31
|
+
|
32
|
+
def __str__(self) -> str:
|
33
|
+
"""Return a string representation of the workspace object
|
34
|
+
|
35
|
+
Returns:
|
36
|
+
str: The string representation of the workspace object
|
37
|
+
"""
|
38
|
+
dict_ = {
|
39
|
+
'id': self.id,
|
40
|
+
'type': self.type,
|
41
|
+
'name': self.name,
|
42
|
+
'state': self.state,
|
43
|
+
'capacity_id': self.capacity_id
|
44
|
+
}
|
45
|
+
return json.dumps(dict_, indent=2)
|
46
|
+
|
47
|
+
|
48
|
+
def __repr__(self) -> str:
|
49
|
+
return self.__str__()
|
50
|
+
|
51
|
+
def from_dict(item_dict, admin_client):
|
52
|
+
"""Create Workspace object from dictionary
|
53
|
+
|
54
|
+
Args:
|
55
|
+
item_dict (dict): The dictionary representing the workspace
|
56
|
+
admin_client (FabricClientAdmin): The FabricClientAdmin object
|
57
|
+
Returns:
|
58
|
+
Workspace: The Workspace object
|
59
|
+
"""
|
60
|
+
return AdminWorkspace(
|
61
|
+
id=item_dict['id'],
|
62
|
+
type=item_dict['type'],
|
63
|
+
name=item_dict['name'],
|
64
|
+
state=item_dict['state'],
|
65
|
+
capacity_id=item_dict['capacityId'],
|
66
|
+
admin_client=admin_client
|
67
|
+
)
|
68
|
+
|
69
|
+
def list_workspace_access_details(self):
|
70
|
+
"""Get the access details of the workspace
|
71
|
+
|
72
|
+
Returns:
|
73
|
+
dict: The access details of the workspace
|
74
|
+
"""
|
75
|
+
return self.admin_client.list_workspace_access_details(self.id)
|
76
|
+
|
77
|
+
# Items
|
78
|
+
|
79
|
+
def get_item(self, item_id, type = None):
|
80
|
+
"""Get an item from the workspace
|
81
|
+
|
82
|
+
Args:
|
83
|
+
item_id (str): The ID of the item
|
84
|
+
type (str): The type of the item
|
85
|
+
Returns:
|
86
|
+
AdminItem: The item object
|
87
|
+
"""
|
88
|
+
return self.admin_client.get_item(self.id, item_id, type)
|
89
|
+
|
90
|
+
def list_item_access_details(self, item_id, type=None):
|
91
|
+
"""Get the access details of the item
|
92
|
+
|
93
|
+
Args:
|
94
|
+
item_id (str): The ID of the item
|
95
|
+
type (str): The type of the item
|
96
|
+
Returns:
|
97
|
+
dict: The access details of the item
|
98
|
+
"""
|
99
|
+
return self.admin_client.list_item_access_details(self.id, item_id, type)
|