msfabricpysdkcore 0.0.13__tar.gz → 0.1.2__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.13 → msfabricpysdkcore-0.1.2}/PKG-INFO +72 -10
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/README.md +71 -9
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/__init__.py +3 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/admin_item.py +19 -45
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/admin_workspace.py +99 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/adminapi.py +634 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/auth.py +10 -6
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/client.py +143 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/coreapi.py +2807 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/deployment_pipeline.py +128 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/domain.py +179 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/environment.py +51 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/fabric_azure_capacity.py +77 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/fabric_azure_client.py +228 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/item.py +136 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/job_instance.py +8 -22
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/lakehouse.py +27 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/long_running_operation.py +49 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/onelakeshortcut.py +7 -21
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/otheritems.py +195 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/spark_custom_pool.py +7 -47
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_admin_apis.py +9 -10
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_datapipelines.py +15 -18
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_domains.py +6 -5
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_environments.py +54 -5
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_evenhouses.py +47 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_evenstreams.py +44 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_external_data_shares.py +3 -3
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_fabric_azure_client.py +78 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_git.py +8 -9
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_items.py +81 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_jobs.py +2 -2
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_kql_queryset.py +49 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_kqldatabases.py +3 -3
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_lakehouse.py +84 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_ml_experiments.py +47 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_ml_models.py +47 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_notebooks.py +57 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +2 -4
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_other_items.py +45 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_reports.py +52 -0
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_semantic_model.py +50 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_shortcuts.py +4 -4
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_spark.py +9 -9
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_sparkjobdefinition.py +2 -2
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/tests/test_warehouses.py +50 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_workspaces_capacities.py +16 -13
- msfabricpysdkcore-0.1.2/msfabricpysdkcore/workspace.py +750 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore.egg-info/PKG-INFO +72 -10
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore.egg-info/SOURCES.txt +14 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/pyproject.toml +1 -1
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/setup.py +1 -1
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/__init__.py +0 -2
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/admin_workspace.py +0 -146
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/adminapi.py +0 -709
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/client.py +0 -26
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/coreapi.py +0 -1059
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/deployment_pipeline.py +0 -240
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/domain.py +0 -378
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/environment.py +0 -210
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/item.py +0 -412
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/lakehouse.py +0 -136
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/long_running_operation.py +0 -79
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/otheritems.py +0 -220
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/tests/test_evenstreams.py +0 -44
- msfabricpysdkcore-0.0.13/msfabricpysdkcore/workspace.py +0 -1516
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/capacity.py +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/__init__.py +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore.egg-info/requires.txt +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
- {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.2}/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.2
|
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
|
@@ -15,16 +15,17 @@ 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 (v1) of Fabric*.
|
18
|
+
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs (v1) of Fabric*. It supports all Fabric REST APIs as well as Azure Resource Management APIs for Fabric (as of July 23, 2024).
|
19
19
|
|
20
20
|

|
21
21
|
|
22
22
|
The Microsoft Fabric REST APIs are documented [here](https://docs.microsoft.com/en-us/rest/api/fabric/).
|
23
|
+
The Azure Resoure Management APIs for Fabric are documented [here](https://learn.microsoft.com/en-us/rest/api/microsoftfabric/fabric-capacities?view=rest-microsoftfabric-2023-11-01).
|
23
24
|
They are designed to automate your Fabric processes.
|
24
25
|
|
25
26
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
26
27
|
Additionally it brings some extra features like:
|
27
|
-
- Authentication is handled for you (currently Azure CLI Authentication
|
28
|
+
- Authentication is handled for you (currently Azure CLI Authentication, Authentication from a Microsoft Fabric notebook and Service Principal Authentication are supported)
|
28
29
|
- Waiting for completion of long running operations
|
29
30
|
- Retry logic when hitting the API rate limits
|
30
31
|
- Referencing objects by name instead of ID
|
@@ -34,7 +35,7 @@ Additionally it brings some extra features like:
|
|
34
35
|
|
35
36
|
See the latest release notes [here](releasenotes/release_notes.md).
|
36
37
|
|
37
|
-
Currently it supports all Core APIs, Admin APIs,
|
38
|
+
Currently it supports all Core APIs, Admin APIs, all item specific CRUD APIs and Azure Resource Management APIs for Fabric capacities, i.e.:
|
38
39
|
- Core APIs
|
39
40
|
- [Capacities](#working-with-capacities)
|
40
41
|
- [Deployment Pipelines](#deployment-pipelines)
|
@@ -58,6 +59,7 @@ Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other it
|
|
58
59
|
- List, create, update, delete warehouses, notebooks, semantic models, kql databases,.....
|
59
60
|
- Lakehouse operations (Load table, list tables, run table maintenance)
|
60
61
|
- Spark Pool operations
|
62
|
+
- [Azure Resource Management APIs for Fabric capacities](#azure-resource-management-apis-for-fabric-capacities)
|
61
63
|
|
62
64
|
It is planned to support also new APIs which are not released yet.
|
63
65
|
Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
|
@@ -85,6 +87,7 @@ from msfabricpysdkcore import FabricClientCore
|
|
85
87
|
# Create a client
|
86
88
|
|
87
89
|
# Either login with the Azure CLI first and initiate the client directly
|
90
|
+
# This also works directly in a Microsoft Fabric notebook
|
88
91
|
fc = FabricClientCore()
|
89
92
|
|
90
93
|
# Or use a service principal (note that not all APIs are supported with service principal)
|
@@ -99,7 +102,12 @@ fc = FabricClientCore(tenant_id = "tenant_id",
|
|
99
102
|
|
100
103
|
|
101
104
|
```
|
105
|
+
### Getting a token
|
106
|
+
```python
|
107
|
+
# Getting a token
|
102
108
|
|
109
|
+
token = fc.get_token()
|
110
|
+
```
|
103
111
|
### Working with workspaces
|
104
112
|
|
105
113
|
```python
|
@@ -230,7 +238,7 @@ pipe = fc.get_deployment_pipeline(pipe_id)
|
|
230
238
|
|
231
239
|
|
232
240
|
# Get deployment pipeline stages
|
233
|
-
stages = fc.
|
241
|
+
stages = fc.list_deployment_pipeline_stages(pipe_id)
|
234
242
|
|
235
243
|
names = [stage.display_name for stage in stages]
|
236
244
|
|
@@ -238,7 +246,7 @@ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0
|
|
238
246
|
prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
|
239
247
|
|
240
248
|
# Get deployment pipeline stages items
|
241
|
-
items = fc.
|
249
|
+
items = fc.list_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
|
242
250
|
|
243
251
|
|
244
252
|
items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
|
@@ -312,11 +320,11 @@ item_list = ws.list_items()
|
|
312
320
|
|
313
321
|
|
314
322
|
# Update an item
|
315
|
-
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None)
|
323
|
+
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None, return_item=True)
|
316
324
|
# or
|
317
|
-
ws.update_item(item_id="item_id", display_name="new_item_name", description = None)
|
325
|
+
ws.update_item(item_id="item_id", display_name="new_item_name", description = None, return_item=True)
|
318
326
|
# or
|
319
|
-
item.update(display_name="new_item_name", description = None)
|
327
|
+
item.update(display_name="new_item_name", description = None, return_item=True)
|
320
328
|
|
321
329
|
|
322
330
|
# Delete an item
|
@@ -654,7 +662,7 @@ domains = fca.list_domains()
|
|
654
662
|
|
655
663
|
# Update domain
|
656
664
|
domain_new_name = "sdktestdomains2"
|
657
|
-
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name)
|
665
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name, return_item=True)
|
658
666
|
|
659
667
|
# Assign domain workspaces by Ids
|
660
668
|
fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
@@ -715,3 +723,57 @@ fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
|
715
723
|
|
716
724
|
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.
|
717
725
|
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.
|
726
|
+
|
727
|
+
|
728
|
+
### Azure Resource Management APIs for Fabric capacities
|
729
|
+
|
730
|
+
```python
|
731
|
+
from msfabricpysdkcore import FabricAzureClient
|
732
|
+
|
733
|
+
fac = FabricAzureClient()
|
734
|
+
|
735
|
+
subscription_id = "fsdgdfgds"
|
736
|
+
resource_group_name = "fabricdemo"
|
737
|
+
capacity_name = "rgsdfgsdfgsd"
|
738
|
+
capacity_name_new = "dsfgsdfgsdfg" + datetime.now().strftime("%Y%m%d%H%M%S")
|
739
|
+
|
740
|
+
# Check name availability
|
741
|
+
|
742
|
+
resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_new)
|
743
|
+
|
744
|
+
# Create or update capacity
|
745
|
+
resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
|
746
|
+
location="westeurope",
|
747
|
+
properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
|
748
|
+
sku = "F2")
|
749
|
+
|
750
|
+
# Get capacity
|
751
|
+
resp = fac.get_capacity(subscription_id, resource_group_name, capacity_name_new)
|
752
|
+
sku = resp.sku['name']
|
753
|
+
|
754
|
+
# Delete capacity
|
755
|
+
resp = fac.delete_capacity(subscription_id, resource_group_name, capacity_name_new)
|
756
|
+
|
757
|
+
# List capacities by resource group
|
758
|
+
resp = fac.list_by_resource_group(subscription_id, resource_group_name)
|
759
|
+
cap_names = [cap["name"] for cap in resp]
|
760
|
+
|
761
|
+
# List capacities by subscription
|
762
|
+
resp = fac.list_by_subscription(subscription_id)
|
763
|
+
cap_names = [cap["name"] for cap in resp]
|
764
|
+
|
765
|
+
# List SKUs
|
766
|
+
resp = fac.list_skus(subscription_id)
|
767
|
+
|
768
|
+
# List SKUs for capacity
|
769
|
+
resp = fac.list_skus_for_capacity(subscription_id, resource_group_name, capacity_name)
|
770
|
+
|
771
|
+
# Resume capacity
|
772
|
+
resp = fac.resume_capacity(subscription_id, resource_group_name, capacity_name)
|
773
|
+
|
774
|
+
# Suspend capacity
|
775
|
+
resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
|
776
|
+
|
777
|
+
# Update capacity
|
778
|
+
resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
|
779
|
+
```
|
@@ -1,15 +1,16 @@
|
|
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 (v1) of Fabric*.
|
3
|
+
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs (v1) of Fabric*. It supports all Fabric REST APIs as well as Azure Resource Management APIs for Fabric (as of July 23, 2024).
|
4
4
|
|
5
5
|

|
6
6
|
|
7
7
|
The Microsoft Fabric REST APIs are documented [here](https://docs.microsoft.com/en-us/rest/api/fabric/).
|
8
|
+
The Azure Resoure Management APIs for Fabric are documented [here](https://learn.microsoft.com/en-us/rest/api/microsoftfabric/fabric-capacities?view=rest-microsoftfabric-2023-11-01).
|
8
9
|
They are designed to automate your Fabric processes.
|
9
10
|
|
10
11
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
11
12
|
Additionally it brings some extra features like:
|
12
|
-
- Authentication is handled for you (currently Azure CLI Authentication
|
13
|
+
- Authentication is handled for you (currently Azure CLI Authentication, Authentication from a Microsoft Fabric notebook and Service Principal Authentication are supported)
|
13
14
|
- Waiting for completion of long running operations
|
14
15
|
- Retry logic when hitting the API rate limits
|
15
16
|
- Referencing objects by name instead of ID
|
@@ -19,7 +20,7 @@ Additionally it brings some extra features like:
|
|
19
20
|
|
20
21
|
See the latest release notes [here](releasenotes/release_notes.md).
|
21
22
|
|
22
|
-
Currently it supports all Core APIs, Admin APIs,
|
23
|
+
Currently it supports all Core APIs, Admin APIs, all item specific CRUD APIs and Azure Resource Management APIs for Fabric capacities, i.e.:
|
23
24
|
- Core APIs
|
24
25
|
- [Capacities](#working-with-capacities)
|
25
26
|
- [Deployment Pipelines](#deployment-pipelines)
|
@@ -43,6 +44,7 @@ Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other it
|
|
43
44
|
- List, create, update, delete warehouses, notebooks, semantic models, kql databases,.....
|
44
45
|
- Lakehouse operations (Load table, list tables, run table maintenance)
|
45
46
|
- Spark Pool operations
|
47
|
+
- [Azure Resource Management APIs for Fabric capacities](#azure-resource-management-apis-for-fabric-capacities)
|
46
48
|
|
47
49
|
It is planned to support also new APIs which are not released yet.
|
48
50
|
Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
|
@@ -70,6 +72,7 @@ from msfabricpysdkcore import FabricClientCore
|
|
70
72
|
# Create a client
|
71
73
|
|
72
74
|
# Either login with the Azure CLI first and initiate the client directly
|
75
|
+
# This also works directly in a Microsoft Fabric notebook
|
73
76
|
fc = FabricClientCore()
|
74
77
|
|
75
78
|
# Or use a service principal (note that not all APIs are supported with service principal)
|
@@ -84,7 +87,12 @@ fc = FabricClientCore(tenant_id = "tenant_id",
|
|
84
87
|
|
85
88
|
|
86
89
|
```
|
90
|
+
### Getting a token
|
91
|
+
```python
|
92
|
+
# Getting a token
|
87
93
|
|
94
|
+
token = fc.get_token()
|
95
|
+
```
|
88
96
|
### Working with workspaces
|
89
97
|
|
90
98
|
```python
|
@@ -215,7 +223,7 @@ pipe = fc.get_deployment_pipeline(pipe_id)
|
|
215
223
|
|
216
224
|
|
217
225
|
# Get deployment pipeline stages
|
218
|
-
stages = fc.
|
226
|
+
stages = fc.list_deployment_pipeline_stages(pipe_id)
|
219
227
|
|
220
228
|
names = [stage.display_name for stage in stages]
|
221
229
|
|
@@ -223,7 +231,7 @@ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0
|
|
223
231
|
prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
|
224
232
|
|
225
233
|
# Get deployment pipeline stages items
|
226
|
-
items = fc.
|
234
|
+
items = fc.list_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
|
227
235
|
|
228
236
|
|
229
237
|
items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
|
@@ -297,11 +305,11 @@ item_list = ws.list_items()
|
|
297
305
|
|
298
306
|
|
299
307
|
# Update an item
|
300
|
-
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None)
|
308
|
+
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None, return_item=True)
|
301
309
|
# or
|
302
|
-
ws.update_item(item_id="item_id", display_name="new_item_name", description = None)
|
310
|
+
ws.update_item(item_id="item_id", display_name="new_item_name", description = None, return_item=True)
|
303
311
|
# or
|
304
|
-
item.update(display_name="new_item_name", description = None)
|
312
|
+
item.update(display_name="new_item_name", description = None, return_item=True)
|
305
313
|
|
306
314
|
|
307
315
|
# Delete an item
|
@@ -639,7 +647,7 @@ domains = fca.list_domains()
|
|
639
647
|
|
640
648
|
# Update domain
|
641
649
|
domain_new_name = "sdktestdomains2"
|
642
|
-
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name)
|
650
|
+
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name, return_item=True)
|
643
651
|
|
644
652
|
# Assign domain workspaces by Ids
|
645
653
|
fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
|
@@ -700,3 +708,57 @@ fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
|
700
708
|
|
701
709
|
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.
|
702
710
|
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.
|
711
|
+
|
712
|
+
|
713
|
+
### Azure Resource Management APIs for Fabric capacities
|
714
|
+
|
715
|
+
```python
|
716
|
+
from msfabricpysdkcore import FabricAzureClient
|
717
|
+
|
718
|
+
fac = FabricAzureClient()
|
719
|
+
|
720
|
+
subscription_id = "fsdgdfgds"
|
721
|
+
resource_group_name = "fabricdemo"
|
722
|
+
capacity_name = "rgsdfgsdfgsd"
|
723
|
+
capacity_name_new = "dsfgsdfgsdfg" + datetime.now().strftime("%Y%m%d%H%M%S")
|
724
|
+
|
725
|
+
# Check name availability
|
726
|
+
|
727
|
+
resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_new)
|
728
|
+
|
729
|
+
# Create or update capacity
|
730
|
+
resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
|
731
|
+
location="westeurope",
|
732
|
+
properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
|
733
|
+
sku = "F2")
|
734
|
+
|
735
|
+
# Get capacity
|
736
|
+
resp = fac.get_capacity(subscription_id, resource_group_name, capacity_name_new)
|
737
|
+
sku = resp.sku['name']
|
738
|
+
|
739
|
+
# Delete capacity
|
740
|
+
resp = fac.delete_capacity(subscription_id, resource_group_name, capacity_name_new)
|
741
|
+
|
742
|
+
# List capacities by resource group
|
743
|
+
resp = fac.list_by_resource_group(subscription_id, resource_group_name)
|
744
|
+
cap_names = [cap["name"] for cap in resp]
|
745
|
+
|
746
|
+
# List capacities by subscription
|
747
|
+
resp = fac.list_by_subscription(subscription_id)
|
748
|
+
cap_names = [cap["name"] for cap in resp]
|
749
|
+
|
750
|
+
# List SKUs
|
751
|
+
resp = fac.list_skus(subscription_id)
|
752
|
+
|
753
|
+
# List SKUs for capacity
|
754
|
+
resp = fac.list_skus_for_capacity(subscription_id, resource_group_name, capacity_name)
|
755
|
+
|
756
|
+
# Resume capacity
|
757
|
+
resp = fac.resume_capacity(subscription_id, resource_group_name, capacity_name)
|
758
|
+
|
759
|
+
# Suspend capacity
|
760
|
+
resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
|
761
|
+
|
762
|
+
# Update capacity
|
763
|
+
resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
|
764
|
+
```
|
@@ -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
|
-
creator_principal = item_dict
|
80
|
-
|
77
|
+
creator_principal = item_dict.get('creatorPrincipal', None),
|
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)
|