msfabricpysdkcore 0.0.11__tar.gz → 0.0.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/PKG-INFO +123 -8
  2. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/README.md +122 -7
  3. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/adminapi.py +49 -1
  4. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/coreapi.py +72 -7
  5. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/environment.py +11 -10
  6. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/item.py +147 -6
  7. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/long_running_operation.py +9 -4
  8. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/otheritems.py +29 -0
  9. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_admin_apis.py +20 -0
  10. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_deployment_pipeline.py +1 -2
  11. msfabricpysdkcore-0.0.13/msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
  12. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_git.py +2 -2
  13. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +14 -52
  14. msfabricpysdkcore-0.0.13/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +65 -0
  15. msfabricpysdkcore-0.0.13/msfabricpysdkcore/tests/test_sparkjobdefinition.py +55 -0
  16. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_workspaces_capacities.py +57 -47
  17. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/workspace.py +123 -8
  18. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore.egg-info/PKG-INFO +123 -8
  19. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore.egg-info/SOURCES.txt +3 -0
  20. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/pyproject.toml +1 -1
  21. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/setup.py +1 -1
  22. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/LICENSE +0 -0
  23. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/__init__.py +0 -0
  24. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/admin_item.py +0 -0
  25. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/admin_workspace.py +0 -0
  26. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/auth.py +0 -0
  27. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/capacity.py +0 -0
  28. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/client.py +0 -0
  29. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/deployment_pipeline.py +0 -0
  30. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/domain.py +0 -0
  31. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/job_instance.py +0 -0
  32. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/lakehouse.py +0 -0
  33. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/onelakeshortcut.py +0 -0
  34. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/spark_custom_pool.py +0 -0
  35. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/__init__.py +0 -0
  36. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_datapipelines.py +0 -0
  37. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_domains.py +0 -0
  38. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_environments.py +0 -0
  39. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_evenstreams.py +0 -0
  40. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_jobs.py +0 -0
  41. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_kqldatabases.py +0 -0
  42. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_shortcuts.py +0 -0
  43. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore/tests/test_spark.py +0 -0
  44. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
  45. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore.egg-info/requires.txt +0 -0
  46. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
  47. {msfabricpysdkcore-0.0.11 → msfabricpysdkcore-0.0.13}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msfabricpysdkcore
3
- Version: 0.0.11
3
+ Version: 0.0.13
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
@@ -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)
@@ -148,26 +151,40 @@ ws.add_role_assignment(principal = {"id" : "abadfbafb",
148
151
  role = 'Member')
149
152
 
150
153
 
151
- # Get workspace role assignments
152
- fc.get_workspace_role_assignments(workspace_id = ws.id)
154
+ # List workspace role assignments
155
+ fc.list_workspace_role_assignments(workspace_id = ws.id)
153
156
  # or
154
- ws.get_role_assignments()
157
+ ws.list_role_assignments()
155
158
 
156
159
 
160
+ # Get workspace role assignment
161
+ fc.get_workspace_role_assignment(workspace_id = ws.id,
162
+ workspace_role_assignment_id = "dagdasf")
163
+ # or
164
+ ws.get_role_assignment(workspace_role_assignment_id = "fsgdg")
165
+
157
166
  # Update workspace role assignment
158
167
  fc.update_workspace_role_assignment(workspace_id = ws.id,
159
168
  role = "Contributor",
160
- principal_id = "abadfbafb")
169
+ workspace_role_assignment_id = "abadfbafb")
161
170
  # or
162
171
  ws.update_role_assignment(role = "Contributor",
163
- principal_id = "abadfbafb")
172
+ workspace_role_assignment_id = "abadfbafb")
164
173
 
165
174
 
166
175
  # Delete workspace role assignment
167
176
  fc.delete_workspace_role_assignment(workspace_id = ws.id,
168
- principal_id = "abadfbafb")
177
+ workspace_role_assignment_id = "abadfbafb")
169
178
  # or
170
- ws.delete_role_assignment(principal_id = "abadfbafb")
179
+ ws.delete_role_assignment(workspace_role_assignment_id = "abadfbafb")
180
+
181
+
182
+ # Provision Identity
183
+ result = fc.provision_identity(workspace_id=ws.id)
184
+ print(result["applicationId"]))
185
+
186
+ # Deprovision Identity
187
+ fc.deprovision_identity(workspace_id=ws.id)
171
188
 
172
189
  ```
173
190
 
@@ -235,6 +252,43 @@ response = pipe.deploy(source_stage_id=dev_stage.id,target_stage_id=prod_stage.i
235
252
 
236
253
  ```
237
254
 
255
+ ### External Data Shares
256
+
257
+ ```python
258
+ from msfabricpysdkcore.coreapi import FabricClientCore
259
+
260
+ fc = FabricClientCore()
261
+
262
+ workspace_id = 'yxcvyxcvyxcv'
263
+ item_id = 'sdfsdfsdfsf'
264
+
265
+
266
+ # Create
267
+
268
+ recipient = {
269
+ "userPrincipalName": "lisa4@fabrikam.com"
270
+ }
271
+ paths=["Files/external"]
272
+
273
+ data_share = fc.create_external_data_share(workspace_id, item_id, paths, recipient)
274
+
275
+ # Get
276
+
277
+ data_share2 = fc.get_external_data_share(workspace_id, item_id, data_share['id'])
278
+
279
+ # List
280
+
281
+ data_share_list = fc.list_external_data_shares_in_item(workspace_id, item_id)
282
+
283
+ data_share_ids = [ds['id'] for ds in data_share_list]
284
+
285
+ # Revoke
286
+
287
+ response_code = fc.revoke_external_data_share(workspace_id, item_id, data_share['id'])
288
+
289
+ ```
290
+
291
+
238
292
  ### Working with items
239
293
 
240
294
  ```python
@@ -438,6 +492,44 @@ results = fc.get_operation_results(operation_id)
438
492
 
439
493
  ```
440
494
 
495
+ ### One Lake Data Access Security
496
+
497
+ ```python
498
+ from msfabricpysdkcore import FabricClientCore
499
+
500
+ fc = FabricClientCore()
501
+
502
+ workspace_id = "d8aafgasdsdbe5"
503
+ item_id = "503hsdfhs48364"
504
+
505
+ # List
506
+
507
+ resp = fc.list_data_access_roles(workspace_id=workspace_id, item_id=item_id)
508
+
509
+ roles = resp[0]
510
+ etag = resp[1]
511
+
512
+
513
+ # Create or Update
514
+
515
+ role1 = roles[1]
516
+
517
+ item_access = role1["members"]["fabricItemMembers"][0]['itemAccess']
518
+ +
519
+ if 'ReadAll' in item_access:
520
+ item_access = ['Read', 'Write', 'Execute']
521
+ else:
522
+ item_access.append('ReadAll')
523
+
524
+ role1["members"]["fabricItemMembers"][0]['itemAccess'] = item_access
525
+ roles[1] = role1
526
+
527
+ resp = fc.create_or_update_data_access_roles(workspace_id=workspace_id,
528
+ item_id=item_id,
529
+ data_access_roles=roles,
530
+ etag_match={"If-Match":etag})
531
+
532
+ ```
441
533
 
442
534
  ### Admin API for Workspaces
443
535
 
@@ -597,6 +689,29 @@ status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [pri
597
689
  status_code = fca.delete_domain(domain.id)
598
690
  ```
599
691
 
692
+ ### Admin API for External Data Shares
693
+
694
+ ```python
695
+ from msfabricpysdkcore import FabricClientAdmin
696
+
697
+ fca = FabricClientAdmin()
698
+
699
+ # List external data shares
700
+
701
+ data_shares = fca.list_external_data_shares()
702
+ ws = fca.list_workspaces(name="testworkspace")[0]
703
+
704
+ data_shares = [d for d in data_shares if d['workspaceId'] == ws.id]
705
+
706
+ # Revoke external data share
707
+
708
+ fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
709
+ item_id = data_shares[0]['itemId'],
710
+ workspace_id = data_shares[0]['workspaceId'])
711
+
712
+
713
+ ```
714
+
600
715
 
601
716
  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.
602
717
  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.
@@ -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)
@@ -133,26 +136,40 @@ ws.add_role_assignment(principal = {"id" : "abadfbafb",
133
136
  role = 'Member')
134
137
 
135
138
 
136
- # Get workspace role assignments
137
- fc.get_workspace_role_assignments(workspace_id = ws.id)
139
+ # List workspace role assignments
140
+ fc.list_workspace_role_assignments(workspace_id = ws.id)
138
141
  # or
139
- ws.get_role_assignments()
142
+ ws.list_role_assignments()
140
143
 
141
144
 
145
+ # Get workspace role assignment
146
+ fc.get_workspace_role_assignment(workspace_id = ws.id,
147
+ workspace_role_assignment_id = "dagdasf")
148
+ # or
149
+ ws.get_role_assignment(workspace_role_assignment_id = "fsgdg")
150
+
142
151
  # Update workspace role assignment
143
152
  fc.update_workspace_role_assignment(workspace_id = ws.id,
144
153
  role = "Contributor",
145
- principal_id = "abadfbafb")
154
+ workspace_role_assignment_id = "abadfbafb")
146
155
  # or
147
156
  ws.update_role_assignment(role = "Contributor",
148
- principal_id = "abadfbafb")
157
+ workspace_role_assignment_id = "abadfbafb")
149
158
 
150
159
 
151
160
  # Delete workspace role assignment
152
161
  fc.delete_workspace_role_assignment(workspace_id = ws.id,
153
- principal_id = "abadfbafb")
162
+ workspace_role_assignment_id = "abadfbafb")
154
163
  # or
155
- ws.delete_role_assignment(principal_id = "abadfbafb")
164
+ ws.delete_role_assignment(workspace_role_assignment_id = "abadfbafb")
165
+
166
+
167
+ # Provision Identity
168
+ result = fc.provision_identity(workspace_id=ws.id)
169
+ print(result["applicationId"]))
170
+
171
+ # Deprovision Identity
172
+ fc.deprovision_identity(workspace_id=ws.id)
156
173
 
157
174
  ```
158
175
 
@@ -220,6 +237,43 @@ response = pipe.deploy(source_stage_id=dev_stage.id,target_stage_id=prod_stage.i
220
237
 
221
238
  ```
222
239
 
240
+ ### External Data Shares
241
+
242
+ ```python
243
+ from msfabricpysdkcore.coreapi import FabricClientCore
244
+
245
+ fc = FabricClientCore()
246
+
247
+ workspace_id = 'yxcvyxcvyxcv'
248
+ item_id = 'sdfsdfsdfsf'
249
+
250
+
251
+ # Create
252
+
253
+ recipient = {
254
+ "userPrincipalName": "lisa4@fabrikam.com"
255
+ }
256
+ paths=["Files/external"]
257
+
258
+ data_share = fc.create_external_data_share(workspace_id, item_id, paths, recipient)
259
+
260
+ # Get
261
+
262
+ data_share2 = fc.get_external_data_share(workspace_id, item_id, data_share['id'])
263
+
264
+ # List
265
+
266
+ data_share_list = fc.list_external_data_shares_in_item(workspace_id, item_id)
267
+
268
+ data_share_ids = [ds['id'] for ds in data_share_list]
269
+
270
+ # Revoke
271
+
272
+ response_code = fc.revoke_external_data_share(workspace_id, item_id, data_share['id'])
273
+
274
+ ```
275
+
276
+
223
277
  ### Working with items
224
278
 
225
279
  ```python
@@ -423,6 +477,44 @@ results = fc.get_operation_results(operation_id)
423
477
 
424
478
  ```
425
479
 
480
+ ### One Lake Data Access Security
481
+
482
+ ```python
483
+ from msfabricpysdkcore import FabricClientCore
484
+
485
+ fc = FabricClientCore()
486
+
487
+ workspace_id = "d8aafgasdsdbe5"
488
+ item_id = "503hsdfhs48364"
489
+
490
+ # List
491
+
492
+ resp = fc.list_data_access_roles(workspace_id=workspace_id, item_id=item_id)
493
+
494
+ roles = resp[0]
495
+ etag = resp[1]
496
+
497
+
498
+ # Create or Update
499
+
500
+ role1 = roles[1]
501
+
502
+ item_access = role1["members"]["fabricItemMembers"][0]['itemAccess']
503
+ +
504
+ if 'ReadAll' in item_access:
505
+ item_access = ['Read', 'Write', 'Execute']
506
+ else:
507
+ item_access.append('ReadAll')
508
+
509
+ role1["members"]["fabricItemMembers"][0]['itemAccess'] = item_access
510
+ roles[1] = role1
511
+
512
+ resp = fc.create_or_update_data_access_roles(workspace_id=workspace_id,
513
+ item_id=item_id,
514
+ data_access_roles=roles,
515
+ etag_match={"If-Match":etag})
516
+
517
+ ```
426
518
 
427
519
  ### Admin API for Workspaces
428
520
 
@@ -582,6 +674,29 @@ status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [pri
582
674
  status_code = fca.delete_domain(domain.id)
583
675
  ```
584
676
 
677
+ ### Admin API for External Data Shares
678
+
679
+ ```python
680
+ from msfabricpysdkcore import FabricClientAdmin
681
+
682
+ fca = FabricClientAdmin()
683
+
684
+ # List external data shares
685
+
686
+ data_shares = fca.list_external_data_shares()
687
+ ws = fca.list_workspaces(name="testworkspace")[0]
688
+
689
+ data_shares = [d for d in data_shares if d['workspaceId'] == ws.id]
690
+
691
+ # Revoke external data share
692
+
693
+ fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
694
+ item_id = data_shares[0]['itemId'],
695
+ workspace_id = data_shares[0]['workspaceId'])
696
+
697
+
698
+ ```
699
+
585
700
 
586
701
  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.
587
702
  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.
@@ -658,4 +658,52 @@ class FabricClientAdmin(FabricClient):
658
658
  break
659
659
 
660
660
  response = json.loads(response.text)
661
- return response
661
+ return response
662
+
663
+ def list_external_data_shares(self, continuationToken = None):
664
+ # GET https://api.fabric.microsoft.com/v1/admin/items/externalDataShares
665
+ """List external data shares
666
+
667
+ Returns:
668
+ list: The list of external data shares
669
+ """
670
+ url = "https://api.fabric.microsoft.com/v1/admin/items/externalDataShares"
671
+
672
+ if continuationToken:
673
+ url = f"{url}?continuationToken={continuationToken}"
674
+
675
+ for _ in range(10):
676
+ response = requests.get(url=url, headers=self.auth.get_headers())
677
+ if response.status_code == 429:
678
+ print("Too many requests, waiting 10 seconds")
679
+ sleep(10)
680
+ continue
681
+ if response.status_code not in (200, 429):
682
+ raise Exception(f"Error listing external data shares: {response.status_code}, {response.text}")
683
+ break
684
+
685
+ response = json.loads(response.text)
686
+ list_data_shares = response["value"]
687
+
688
+ if "continuationToken" in response and response["continuationToken"] is not None:
689
+ list_data_shares_next = self.list_external_data_shares(continuationToken=response["continuationToken"])
690
+ list_data_shares.extend(list_data_shares_next)
691
+ return list_data_shares
692
+
693
+ def revoke_external_data_share(self, external_data_share_id, item_id, workspace_id):
694
+ # POST https://api.fabric.microsoft.com/v1/admin/workspaces/{workspaceId}/items/{itemId}/externalDataShares/{externalDataShareId}/revoke
695
+ """Revoke an external data share"""
696
+ url = f"https://api.fabric.microsoft.com/v1/admin/workspaces/{workspace_id}/items/{item_id}/externalDataShares/{external_data_share_id}/revoke"
697
+
698
+ for _ in range(10):
699
+ response = requests.post(url=url, headers=self.auth.get_headers())
700
+ if response.status_code == 429:
701
+ print("Too many requests, waiting 10 seconds")
702
+ sleep(10)
703
+ continue
704
+ if response.status_code not in (200, 429):
705
+ raise Exception(f"Error revoking external data share: {response.status_code}, {response.text}")
706
+ break
707
+
708
+ return response.status_code
709
+
@@ -81,10 +81,10 @@ class FabricClientCore(FabricClient):
81
81
  return self.get_workspace_by_name(name)
82
82
  raise ValueError("Either id or name must be provided")
83
83
 
84
- def get_workspace_role_assignments(self, workspace_id):
84
+ def list_workspace_role_assignments(self, workspace_id):
85
85
  """Get role assignments for a workspace"""
86
86
  ws = self.get_workspace_by_id(workspace_id)
87
- return ws.get_role_assignments()
87
+ return ws.list_role_assignments()
88
88
 
89
89
  def create_workspace(self, display_name, capacity_id = None, description = None, exists_ok = True):
90
90
  """Create a workspace"""
@@ -129,20 +129,25 @@ class FabricClientCore(FabricClient):
129
129
  ws = self.get_workspace_by_id(workspace_id)
130
130
  return ws.add_role_assignment(role, principal)
131
131
 
132
- def delete_workspace_role_assignment(self, workspace_id, principal_id):
132
+ def delete_workspace_role_assignment(self, workspace_id, workspace_role_assignment_id):
133
133
  """Delete a role assignment from a workspace"""
134
134
  ws = self.get_workspace_by_id(workspace_id)
135
- return ws.delete_role_assignment(principal_id)
135
+ return ws.delete_role_assignment(workspace_role_assignment_id)
136
136
 
137
137
  def update_workspace(self, workspace_id, display_name = None, description = None):
138
138
  """Update a workspace"""
139
139
  ws = self.get_workspace_by_id(workspace_id)
140
140
  return ws.update(display_name, description)
141
+
142
+ def get_workspace_role_assignment(self, workspace_id, workspace_role_assignment_id):
143
+ """Get a role assignment for a workspace"""
144
+ ws = self.get_workspace_by_id(workspace_id)
145
+ return ws.get_role_assignment(workspace_role_assignment_id)
141
146
 
142
- def update_workspace_role_assignment(self, workspace_id, role, principal_id):
147
+ def update_workspace_role_assignment(self, workspace_id, role, workspace_role_assignment_id):
143
148
  """Update a role assignment for a workspace"""
144
149
  ws = self.get_workspace_by_id(workspace_id)
145
- return ws.update_role_assignment(role, principal_id)
150
+ return ws.update_role_assignment(role, workspace_role_assignment_id)
146
151
 
147
152
  def assign_to_capacity(self, workspace_id, capacity_id):
148
153
  """Assign a workspace to a capacity"""
@@ -153,6 +158,16 @@ class FabricClientCore(FabricClient):
153
158
  """Unassign a workspace from a capacity"""
154
159
  ws = self.get_workspace_by_id(workspace_id)
155
160
  return ws.unassign_from_capacity()
161
+
162
+ def provision_identity(self, workspace_id):
163
+ """Provision an identity for a workspace"""
164
+ ws = self.get_workspace_by_id(workspace_id)
165
+ return ws.provision_identity()
166
+
167
+ def deprovision_identity(self, workspace_id):
168
+ """Deprovision an identity for a workspace"""
169
+ ws = self.get_workspace_by_id(workspace_id)
170
+ return ws.deprovision_identity()
156
171
 
157
172
  def list_capacities(self, continuationToken = None):
158
173
  """List all capacities in the tenant"""
@@ -809,6 +824,11 @@ class FabricClientCore(FabricClient):
809
824
  ws = self.get_workspace_by_id(workspace_id)
810
825
  return ws.update_spark_job_definition_definition(spark_job_definition_id, definition)
811
826
 
827
+ def run_on_demand_spark_job_definition(self, workspace_id, spark_job_definition_id, job_type = "sparkjob"):
828
+ """Run an on demand spark job definition"""
829
+ ws = self.get_workspace_by_id(workspace_id)
830
+ return ws.run_on_demand_spark_job_definition(spark_job_definition_id, job_type)
831
+
812
832
  # warehouses
813
833
 
814
834
  def list_warehouses(self, workspace_id, with_properties = False):
@@ -991,4 +1011,49 @@ class FabricClientCore(FabricClient):
991
1011
  return ws.update_spark_settings(automatic_log=automatic_log,
992
1012
  environment=environment,
993
1013
  high_concurrency=high_concurrency,
994
- pool=pool)
1014
+ pool=pool)
1015
+
1016
+
1017
+ # External Data Shares
1018
+
1019
+ # create
1020
+
1021
+ def create_external_data_share(self, workspace_id, item_id, paths, recipient):
1022
+ ws = self.get_workspace_by_id(workspace_id)
1023
+ return ws.create_external_data_share(item_id=item_id, paths = paths, recipient = recipient)
1024
+
1025
+ # get
1026
+
1027
+ def get_external_data_share(self, workspace_id, item_id, external_data_share_id):
1028
+ ws = self.get_workspace_by_id(workspace_id)
1029
+ return ws.get_external_data_share(item_id=item_id, external_data_share_id=external_data_share_id)
1030
+
1031
+ # list
1032
+
1033
+ def list_external_data_shares_in_item(self, workspace_id, item_id):
1034
+ ws = self.get_workspace_by_id(workspace_id)
1035
+ return ws.list_external_data_shares_in_item(item_id=item_id)
1036
+
1037
+ # revoke
1038
+
1039
+ def revoke_external_data_share(self, workspace_id, item_id, external_data_share_id):
1040
+ ws = self.get_workspace_by_id(workspace_id)
1041
+ return ws.revoke_external_data_share(item_id=item_id, external_data_share_id=external_data_share_id)
1042
+
1043
+
1044
+ # One Lake Data Access Security
1045
+
1046
+ # create and update
1047
+
1048
+ def create_or_update_data_access_roles(self, workspace_id, item_id, data_access_roles, dryrun = False, etag_match = None):
1049
+ ws = self.get_workspace_by_id(workspace_id)
1050
+ item = ws.get_item(item_id=item_id).create_or_update_data_access_roles(data_access_roles = data_access_roles,
1051
+ dryrun = dryrun, etag_match = etag_match)
1052
+ return item
1053
+
1054
+ # list
1055
+
1056
+ def list_data_access_roles(self, workspace_id, item_id):
1057
+ ws = self.get_workspace_by_id(workspace_id)
1058
+ item = ws.get_item(item_id=item_id)
1059
+ return item.list_data_access_roles()
@@ -135,16 +135,17 @@ class Environment(Item):
135
135
  # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries
136
136
  raise NotImplementedError("Not implemented yet")
137
137
  # url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries"
138
-
139
- # for _ in range(10):
140
- # response = requests.post(url=url, files={'file': file_path}, headers=self.auth.get_headers())
141
- # if response.status_code == 429:
142
- # print("Too many requests, waiting 10 seconds")
143
- # sleep(10)
144
- # continue
145
- # if response.status_code not in (200, 429):
146
- # raise Exception(f"Error uploading staging libraries: {response.status_code}, {response.text}")
147
- # break
138
+ # with open(file_path, 'rb') as f:
139
+ # files = {"upload_file.whl": f}
140
+ # for _ in range(10):
141
+ # response = requests.post(url=url, files=files, headers=self.auth.get_headers())
142
+ # if response.status_code == 429:
143
+ # print("Too many requests, waiting 10 seconds")
144
+ # sleep(10)
145
+ # continue
146
+ # if response.status_code not in (200, 429):
147
+ # raise Exception(f"Error uploading staging libraries: {response.status_code}, {response.text}")
148
+ # break
148
149
 
149
150
  # return json.loads(response.text)
150
151