msfabricpysdkcore 0.0.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.1/LICENSE +21 -0
- msfabricpysdkcore-0.0.1/PKG-INFO +365 -0
- msfabricpysdkcore-0.0.1/README.md +350 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/__init__.py +1 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/auth.py +61 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/client.py +283 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/item.py +246 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/job_instance.py +66 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/long_running_operation.py +81 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/onelakeshortcut.py +55 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore/workspace.py +481 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore.egg-info/PKG-INFO +365 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore.egg-info/SOURCES.txt +17 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore.egg-info/dependency_links.txt +1 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore.egg-info/requires.txt +2 -0
- msfabricpysdkcore-0.0.1/msfabricpysdkcore.egg-info/top_level.txt +1 -0
- msfabricpysdkcore-0.0.1/pyproject.toml +22 -0
- msfabricpysdkcore-0.0.1/setup.cfg +4 -0
- msfabricpysdkcore-0.0.1/setup.py +11 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) Andreas J. Rederer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE
|
@@ -0,0 +1,365 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: msfabricpysdkcore
|
3
|
+
Version: 0.0.1
|
4
|
+
Summary: A Microsoft Fabric SDK for Python
|
5
|
+
Author: Andreas Rederer
|
6
|
+
Project-URL: Homepage, https://github.com/DaSenf1860/ms-fabric-sdk-core
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.11
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENSE
|
13
|
+
Requires-Dist: requests>=2.30.0
|
14
|
+
Requires-Dist: azure-identity>=1.15.0
|
15
|
+
|
16
|
+
# A Microsoft Fabric SDK for Python
|
17
|
+
|
18
|
+
This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs of Fabric*.
|
19
|
+
|
20
|
+

|
21
|
+
|
22
|
+
The Microsoft Fabric REST APIs are documented [here](https://docs.microsoft.com/en-us/rest/api/fabric/).
|
23
|
+
They are designed to automate your Fabric processes.
|
24
|
+
|
25
|
+
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
26
|
+
Additionally it brings some extra features like:
|
27
|
+
- Authentication is handled for you (currently Azure CLI Authentification and Service Principal Authentification are supported)
|
28
|
+
- Waiting for completion of long running operations
|
29
|
+
- Retry logic when hitting the API rate limits
|
30
|
+
- Referencing objects by name instead of ID
|
31
|
+
- More granular objects, e.g. a Workpace and Item object instead of referencing IDs all the time
|
32
|
+
- Do bulk operations**
|
33
|
+
- Pagination support**
|
34
|
+
|
35
|
+
Currently it supports all Core APIs, i.e.:
|
36
|
+
- [Capacities](#working-with-capacities)
|
37
|
+
- [Git](#working-with-git)
|
38
|
+
- [Items](#working-with-items)
|
39
|
+
- [Job Scheduler](#working-with-job-scheduler)
|
40
|
+
- Long Running Operations
|
41
|
+
- [OneLakeShortcuts](#working-with-one-lake-shortcuts)
|
42
|
+
- [Workspaces](#working-with-workspaces)
|
43
|
+
|
44
|
+
It is planned to support also the Admin and Lakehouse APIs and new APIs which are not released yet.
|
45
|
+
Eventually Power BI APIs like the Scanner API will be covered as well.
|
46
|
+
|
47
|
+
*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
|
+
|
49
|
+
**These features are not yet implemented but are planned for the near future.
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
## Installation
|
54
|
+
|
55
|
+
```bash
|
56
|
+
pip install msfabricpysdkcore
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
## Usage
|
61
|
+
|
62
|
+
|
63
|
+
### Client initialization and authentication
|
64
|
+
```python
|
65
|
+
from msfabricpysdkcore import FabricClientCore
|
66
|
+
|
67
|
+
# Create a client
|
68
|
+
|
69
|
+
# Either login with the Azure CLI first and initiate the client directly
|
70
|
+
fc = FabricClientCore()
|
71
|
+
|
72
|
+
# Or use a service principal (note that not all APIs are supported with service principal)
|
73
|
+
# You can also use environment variables to set the service principal id and secret. The environment variables are:
|
74
|
+
# FABRIC_CLIENT_ID
|
75
|
+
# FABRIC_CLIENT_SECRET
|
76
|
+
# FABRIC_TENANT_ID
|
77
|
+
|
78
|
+
fc = FabricClientCore(tenant_id = "tenant_id",
|
79
|
+
client_id = "your_service_principal_id",
|
80
|
+
client_secret = "your_service_principal_secret")
|
81
|
+
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
### Working with workspaces
|
86
|
+
|
87
|
+
```python
|
88
|
+
# Create a workspace
|
89
|
+
ws_created = fc.create_workspace(display_name="testworkspace",
|
90
|
+
description="test workspace",
|
91
|
+
exists_ok=False)
|
92
|
+
|
93
|
+
|
94
|
+
# Get a workspace by id
|
95
|
+
workspace_id = ws_created.id
|
96
|
+
ws = fc.get_workspace_by_id(id = workspace_id)
|
97
|
+
|
98
|
+
|
99
|
+
# Get a workspace by name
|
100
|
+
workspace_name = ws_created.display_name
|
101
|
+
ws = fc.get_workspace_by_name(name = workspace_name)
|
102
|
+
|
103
|
+
|
104
|
+
# List workspaces
|
105
|
+
result = fc.list_workspaces()
|
106
|
+
for ws in result:
|
107
|
+
print(ws)
|
108
|
+
|
109
|
+
|
110
|
+
# Update workspace
|
111
|
+
fc.update_workspace(workspace_id=ws.id,
|
112
|
+
display_name="newname8912389u1293",
|
113
|
+
description="new description")
|
114
|
+
# or
|
115
|
+
ws.update(display_name="newname8912389u1293",
|
116
|
+
description="new description")
|
117
|
+
|
118
|
+
|
119
|
+
# Delete workspace
|
120
|
+
fc.delete_workspace(workspace_id="workspace_id")
|
121
|
+
# or
|
122
|
+
ws.delete()
|
123
|
+
|
124
|
+
|
125
|
+
# Add workspace role assignment
|
126
|
+
fc.add_workspace_role_assignment(workspace_id = ws.id,
|
127
|
+
principal = {"id" : "abadfbafb",
|
128
|
+
"type" : "ServicePrincipal"},
|
129
|
+
role = 'Member')
|
130
|
+
# or
|
131
|
+
ws.add_role_assignment(principal = {"id" : "abadfbafb",
|
132
|
+
"type" : "ServicePrincipal"},
|
133
|
+
role = 'Member')
|
134
|
+
|
135
|
+
|
136
|
+
# Get workspace role assignments
|
137
|
+
fc.get_workspace_role_assignments(workspace_id = ws.id)
|
138
|
+
# or
|
139
|
+
ws.get_role_assignments()
|
140
|
+
|
141
|
+
|
142
|
+
# Update workspace role assignment
|
143
|
+
fc.update_workspace_role_assignment(workspace_id = ws.id,
|
144
|
+
role = "Contributor",
|
145
|
+
principal_id = "abadfbafb")
|
146
|
+
# or
|
147
|
+
ws.update_role_assignment(role = "Contributor",
|
148
|
+
principal_id = "abadfbafb")
|
149
|
+
|
150
|
+
|
151
|
+
# Delete workspace role assignment
|
152
|
+
fc.delete_workspace_role_assignment(workspace_id = ws.id,
|
153
|
+
principal_id = "abadfbafb")
|
154
|
+
# or
|
155
|
+
ws.delete_role_assignment(principal_id = "abadfbafb")
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
### Working with capacities
|
160
|
+
|
161
|
+
```python
|
162
|
+
|
163
|
+
# Assign a capaycity to a workspace
|
164
|
+
fc.assign_to_capacity(workspace_id=workspace_id,
|
165
|
+
capacity_id="capacityid123123")
|
166
|
+
# or
|
167
|
+
ws.assign_to_capacity(capacity_id="capacityid123123")
|
168
|
+
|
169
|
+
# Unassign from capacity
|
170
|
+
fc.unassign_from_capacity(workspace_id=ws.id)
|
171
|
+
# or
|
172
|
+
ws.unassign_from_capacity()
|
173
|
+
|
174
|
+
|
175
|
+
# List capacities
|
176
|
+
fc.list_capacities()
|
177
|
+
```
|
178
|
+
|
179
|
+
### Working with items
|
180
|
+
|
181
|
+
```python
|
182
|
+
|
183
|
+
# Create an item
|
184
|
+
fc.create_item(display_name="item_name", type="Lakehouse", workspace_id="workspace_id", definition = None, description = None)
|
185
|
+
# or
|
186
|
+
ws.create_item(display_name="item_name", type="Lakehouse", definition = None, description = None)
|
187
|
+
|
188
|
+
|
189
|
+
# Get an item
|
190
|
+
item = fc.get_item(workspace_id="workspace_id", item_id="item_id")
|
191
|
+
# or
|
192
|
+
item = ws.get_item(item_id="item_id")
|
193
|
+
|
194
|
+
|
195
|
+
# List items
|
196
|
+
item_list = fc.list_items(workspace_id="workspace_id")
|
197
|
+
# or
|
198
|
+
item_list = ws.list_items()
|
199
|
+
|
200
|
+
|
201
|
+
# Update an item
|
202
|
+
fc.update_item(workspace_id="workspace_id", item_id="item_id" display_name="new_item_name", description = None)
|
203
|
+
# or
|
204
|
+
ws.update_item(item_id="item_id", display_name="new_item_name", description = None)
|
205
|
+
# or
|
206
|
+
item.update(display_name="new_item_name", description = None)
|
207
|
+
|
208
|
+
|
209
|
+
# Delete an item
|
210
|
+
fc.delete_item(workspace_id="workspace_id", item_id="item_id")
|
211
|
+
# or
|
212
|
+
ws.delete_item(item_id="item_id")
|
213
|
+
# or
|
214
|
+
item.delete()
|
215
|
+
|
216
|
+
```
|
217
|
+
|
218
|
+
### Working with Git
|
219
|
+
|
220
|
+
```python
|
221
|
+
|
222
|
+
# Connect to a git repository
|
223
|
+
|
224
|
+
git_provider_details = {'organizationName': 'dasenf1860',
|
225
|
+
'projectName': 'fabrictest',
|
226
|
+
'gitProviderType': 'AzureDevOps',
|
227
|
+
'repositoryName': 'fabrictest',
|
228
|
+
'branchName': 'main',
|
229
|
+
'directoryName': '/folder1'}
|
230
|
+
|
231
|
+
fc.git_connect(workspace_id="workspaceid", git_provider_details=git_provider_details)
|
232
|
+
# or
|
233
|
+
ws.git_connect(git_provider_details=git_provider_details)
|
234
|
+
|
235
|
+
|
236
|
+
# Initialize a git connection
|
237
|
+
|
238
|
+
initialization_strategy = "PreferWorkspace"
|
239
|
+
|
240
|
+
fc.git_initialize_connection(workspace_id="workspaceid", initialization_strategy=initialization_strategy)
|
241
|
+
# or
|
242
|
+
ws.git_initialize_connection(initialization_strategy=initialization_strategy)
|
243
|
+
|
244
|
+
|
245
|
+
# Get git connection details
|
246
|
+
fc.git_get_connection(workspace_id="workspaceid")
|
247
|
+
# or
|
248
|
+
ws.git_get_connection()
|
249
|
+
|
250
|
+
|
251
|
+
# Get git status
|
252
|
+
fc.git_get_status(workspace_id="workspaceid")
|
253
|
+
# or
|
254
|
+
ws.git_get_status()
|
255
|
+
|
256
|
+
|
257
|
+
# Update from git
|
258
|
+
fc.update_from_git(workspace_id="workspaceid", remote_commit_hash="commit_hash",
|
259
|
+
conflict_resolution = None, options = None, workspace_head = None)
|
260
|
+
# or
|
261
|
+
ws.update_from_git(remote_commit_hash="commit_hash", conflict_resolution = None, options = None, workspace_head = None)
|
262
|
+
|
263
|
+
|
264
|
+
# Commit to git
|
265
|
+
fc.commit_to_git(workspace_id="workspaceid", mode = "All", comment="commit message", items=None, workspace_head=None)
|
266
|
+
# or
|
267
|
+
ws.commit_to_git(mode = "All", comment="commit message", items=None, workspace_head=None)
|
268
|
+
|
269
|
+
|
270
|
+
# Disconnect from git
|
271
|
+
fc.git_disconnect(workspace_id="workspaceid")
|
272
|
+
# or
|
273
|
+
ws.git_disconnect()
|
274
|
+
|
275
|
+
```
|
276
|
+
|
277
|
+
### Working with one lake shortcuts
|
278
|
+
|
279
|
+
```python
|
280
|
+
|
281
|
+
# Create a shortcut
|
282
|
+
fc.create_shortcut(workspace_id="workspace_id",
|
283
|
+
item_id="item_id",
|
284
|
+
path="path",
|
285
|
+
name="name",
|
286
|
+
target={"oneLake": {"itemId": "item_id_target",
|
287
|
+
"path": "path_target",
|
288
|
+
"workspaceId": "workspace_id_target"}})
|
289
|
+
# or
|
290
|
+
ws.create_shortcut(item_id="item_id",
|
291
|
+
path="path",
|
292
|
+
name="name",
|
293
|
+
target={"oneLake": {"itemId": "item_id_target",
|
294
|
+
"path": "path_target",
|
295
|
+
"workspaceId": "workspace_id_target"}})
|
296
|
+
# or
|
297
|
+
item.create_shortcut(path="path",
|
298
|
+
name="name",
|
299
|
+
target={"oneLake": {"itemId": "item_id_target",
|
300
|
+
"path": "path_target",
|
301
|
+
"workspaceId": "workspace_id_target"}})
|
302
|
+
|
303
|
+
|
304
|
+
# Get a shortcut
|
305
|
+
shortcut = fc.get_shortcut(workspace_id="workspace_id",
|
306
|
+
item_id="item_id",
|
307
|
+
path="path",
|
308
|
+
name="name")
|
309
|
+
# or
|
310
|
+
shortcut = ws.get_shortcut(item_id="item_id",
|
311
|
+
path="path",
|
312
|
+
name="name")
|
313
|
+
# or
|
314
|
+
shortcut = item.get_shortcut(path="path",
|
315
|
+
name="name")
|
316
|
+
|
317
|
+
|
318
|
+
# Delete a shortcut
|
319
|
+
fc.delete_shortcut(workspace_id="workspace_id",
|
320
|
+
item_id="item_id",
|
321
|
+
path="path",
|
322
|
+
name="name")
|
323
|
+
# or
|
324
|
+
ws.delete_shortcut(item_id="item_id",
|
325
|
+
path="path",
|
326
|
+
name="name")
|
327
|
+
# or
|
328
|
+
item.delete_shortcut(path="path",
|
329
|
+
name="name")
|
330
|
+
|
331
|
+
```
|
332
|
+
|
333
|
+
|
334
|
+
### Working with job scheduler
|
335
|
+
|
336
|
+
```python
|
337
|
+
|
338
|
+
# Run a on demand item job
|
339
|
+
fc.run_on_demand_item_job(workspace_id="workspace_id", item_id="item_id", job_type="RunNotebook", execution_data = None)
|
340
|
+
# or
|
341
|
+
ws.run_on_demand_item_job(item_id="item_id", job_type="RunNotebook", execution_data = None)
|
342
|
+
# or
|
343
|
+
item.run_on_demand_item_job(job_type="RunNotebook", execution_data = None)
|
344
|
+
|
345
|
+
|
346
|
+
# Get an item job instance
|
347
|
+
fc.get_item_job_instance(workspace_id="workspace_id", item_id="item_id", job_instance_id="job_instance_id")
|
348
|
+
# or
|
349
|
+
ws.get_item_job_instance(item_id="item_id", job_instance_id="job_instance_id")
|
350
|
+
# or
|
351
|
+
item.get_item_job_instance(job_instance_id="job_instance_id")
|
352
|
+
|
353
|
+
# Cancel an item job instance
|
354
|
+
fc.cancel_item_job_instance(workspace_id="workspace_id", item_id="item_id", job_instance_id="job_instance_id")
|
355
|
+
# or
|
356
|
+
ws.cancel_item_job_instance(item_id="item_id", job_instance_id="job_instance_id")
|
357
|
+
# or
|
358
|
+
item.cancel_item_job_instance(job_instance_id="job_instance_id")
|
359
|
+
|
360
|
+
```
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
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.
|
365
|
+
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.
|