msfabricpysdkcore 0.0.13__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.
Files changed (70) hide show
  1. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/PKG-INFO +9 -8
  2. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/README.md +8 -7
  3. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/admin_item.py +18 -44
  4. msfabricpysdkcore-0.1.1/msfabricpysdkcore/admin_workspace.py +99 -0
  5. msfabricpysdkcore-0.1.1/msfabricpysdkcore/adminapi.py +632 -0
  6. msfabricpysdkcore-0.1.1/msfabricpysdkcore/client.py +140 -0
  7. msfabricpysdkcore-0.1.1/msfabricpysdkcore/coreapi.py +2804 -0
  8. msfabricpysdkcore-0.1.1/msfabricpysdkcore/deployment_pipeline.py +128 -0
  9. msfabricpysdkcore-0.1.1/msfabricpysdkcore/domain.py +179 -0
  10. msfabricpysdkcore-0.1.1/msfabricpysdkcore/environment.py +51 -0
  11. msfabricpysdkcore-0.1.1/msfabricpysdkcore/item.py +136 -0
  12. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/job_instance.py +8 -22
  13. msfabricpysdkcore-0.1.1/msfabricpysdkcore/lakehouse.py +27 -0
  14. msfabricpysdkcore-0.1.1/msfabricpysdkcore/long_running_operation.py +49 -0
  15. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/onelakeshortcut.py +7 -21
  16. msfabricpysdkcore-0.1.1/msfabricpysdkcore/otheritems.py +195 -0
  17. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/spark_custom_pool.py +7 -47
  18. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_admin_apis.py +1 -1
  19. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_datapipelines.py +14 -17
  20. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
  21. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_domains.py +4 -3
  22. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_environments.py +51 -2
  23. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_evenhouses.py +48 -0
  24. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_evenstreams.py +1 -1
  25. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_items.py +80 -0
  26. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_kql_queryset.py +50 -0
  27. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_kqldatabases.py +1 -1
  28. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_lakehouse.py +86 -0
  29. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_ml_experiments.py +48 -0
  30. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_ml_models.py +48 -0
  31. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_notebooks.py +58 -0
  32. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_other_items.py +46 -0
  33. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_reports.py +53 -0
  34. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_semantic_model.py +51 -0
  35. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_spark.py +7 -5
  36. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
  37. msfabricpysdkcore-0.1.1/msfabricpysdkcore/tests/test_warehouses.py +51 -0
  38. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_workspaces_capacities.py +7 -4
  39. msfabricpysdkcore-0.1.1/msfabricpysdkcore/workspace.py +750 -0
  40. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/PKG-INFO +9 -8
  41. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/SOURCES.txt +11 -0
  42. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/pyproject.toml +1 -1
  43. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/setup.py +1 -1
  44. msfabricpysdkcore-0.0.13/msfabricpysdkcore/admin_workspace.py +0 -146
  45. msfabricpysdkcore-0.0.13/msfabricpysdkcore/adminapi.py +0 -709
  46. msfabricpysdkcore-0.0.13/msfabricpysdkcore/client.py +0 -26
  47. msfabricpysdkcore-0.0.13/msfabricpysdkcore/coreapi.py +0 -1059
  48. msfabricpysdkcore-0.0.13/msfabricpysdkcore/deployment_pipeline.py +0 -240
  49. msfabricpysdkcore-0.0.13/msfabricpysdkcore/domain.py +0 -378
  50. msfabricpysdkcore-0.0.13/msfabricpysdkcore/environment.py +0 -210
  51. msfabricpysdkcore-0.0.13/msfabricpysdkcore/item.py +0 -412
  52. msfabricpysdkcore-0.0.13/msfabricpysdkcore/lakehouse.py +0 -136
  53. msfabricpysdkcore-0.0.13/msfabricpysdkcore/long_running_operation.py +0 -79
  54. msfabricpysdkcore-0.0.13/msfabricpysdkcore/otheritems.py +0 -220
  55. msfabricpysdkcore-0.0.13/msfabricpysdkcore/workspace.py +0 -1516
  56. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/LICENSE +0 -0
  57. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/__init__.py +0 -0
  58. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/auth.py +0 -0
  59. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/capacity.py +0 -0
  60. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/__init__.py +0 -0
  61. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_external_data_shares.py +0 -0
  62. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_git.py +0 -0
  63. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +0 -0
  64. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_jobs.py +0 -0
  65. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +0 -0
  66. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore/tests/test_shortcuts.py +0 -0
  67. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
  68. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/requires.txt +0 -0
  69. {msfabricpysdkcore-0.0.13 → msfabricpysdkcore-0.1.1}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
  70. {msfabricpysdkcore-0.0.13 → 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.0.13
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 and Service Principal Authentication are supported, as well as Synapse Spark Authentication in Fabric Notebooks)
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
@@ -85,6 +85,7 @@ from msfabricpysdkcore import FabricClientCore
85
85
  # Create a client
86
86
 
87
87
  # Either login with the Azure CLI first and initiate the client directly
88
+ # This also works directly in a Microsoft Fabric notebook
88
89
  fc = FabricClientCore()
89
90
 
90
91
  # Or use a service principal (note that not all APIs are supported with service principal)
@@ -230,7 +231,7 @@ pipe = fc.get_deployment_pipeline(pipe_id)
230
231
 
231
232
 
232
233
  # Get deployment pipeline stages
233
- stages = fc.get_deployment_pipeline_stages(pipe_id)
234
+ stages = fc.list_deployment_pipeline_stages(pipe_id)
234
235
 
235
236
  names = [stage.display_name for stage in stages]
236
237
 
@@ -238,7 +239,7 @@ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0
238
239
  prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
239
240
 
240
241
  # Get deployment pipeline stages items
241
- items = fc.get_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
242
+ items = fc.list_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
242
243
 
243
244
 
244
245
  items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
@@ -312,11 +313,11 @@ item_list = ws.list_items()
312
313
 
313
314
 
314
315
  # Update an item
315
- 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)
316
317
  # or
317
- 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)
318
319
  # or
319
- item.update(display_name="new_item_name", description = None)
320
+ item.update(display_name="new_item_name", description = None, return_item=True)
320
321
 
321
322
 
322
323
  # Delete an item
@@ -654,7 +655,7 @@ domains = fca.list_domains()
654
655
 
655
656
  # Update domain
656
657
  domain_new_name = "sdktestdomains2"
657
- 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)
658
659
 
659
660
  # Assign domain workspaces by Ids
660
661
  fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
@@ -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 and Service Principal Authentication are supported, as well as Synapse Spark Authentication in Fabric Notebooks)
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
@@ -70,6 +70,7 @@ from msfabricpysdkcore import FabricClientCore
70
70
  # Create a client
71
71
 
72
72
  # Either login with the Azure CLI first and initiate the client directly
73
+ # This also works directly in a Microsoft Fabric notebook
73
74
  fc = FabricClientCore()
74
75
 
75
76
  # Or use a service principal (note that not all APIs are supported with service principal)
@@ -215,7 +216,7 @@ pipe = fc.get_deployment_pipeline(pipe_id)
215
216
 
216
217
 
217
218
  # Get deployment pipeline stages
218
- stages = fc.get_deployment_pipeline_stages(pipe_id)
219
+ stages = fc.list_deployment_pipeline_stages(pipe_id)
219
220
 
220
221
  names = [stage.display_name for stage in stages]
221
222
 
@@ -223,7 +224,7 @@ dev_stage = [stage for stage in stages if stage.display_name == "Development"][0
223
224
  prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
224
225
 
225
226
  # Get deployment pipeline stages items
226
- items = fc.get_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
227
+ items = fc.list_deployment_pipeline_stages_items(pipeline_id=pipe_id, stage_id=dev_stage.id)
227
228
 
228
229
 
229
230
  items = [item for item in dev_stage.get_items() if item["itemDisplayName"] == 'cicdlakehouse']
@@ -297,11 +298,11 @@ item_list = ws.list_items()
297
298
 
298
299
 
299
300
  # Update an item
300
- 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)
301
302
  # or
302
- 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)
303
304
  # or
304
- item.update(display_name="new_item_name", description = None)
305
+ item.update(display_name="new_item_name", description = None, return_item=True)
305
306
 
306
307
 
307
308
  # Delete an item
@@ -639,7 +640,7 @@ domains = fca.list_domains()
639
640
 
640
641
  # Update domain
641
642
  domain_new_name = "sdktestdomains2"
642
- 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)
643
644
 
644
645
  # Assign domain workspaces by Ids
645
646
  fca.assign_domain_workspaces_by_ids(domain.id, ["workspace_id_1", "workspace_id_2"])
@@ -1,29 +1,26 @@
1
1
  import json
2
- from time import sleep
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, auth) -> None:
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 last updated date of the item
21
- capacity_id (str): The ID of the capacity
22
- creator_principal (dict): The creator principal of the item
23
- auth (Auth): The Auth object
24
- Returns:
25
- Item: The Item object
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.auth = auth
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, auth):
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 information
67
- auth (Auth): The Auth object
63
+ item_dict (dict): The dictionary containing the item details
64
+ admin_client (FabricClientAdmin): The FabricClientAdmin object
68
65
  Returns:
69
- Item: The Item object"""
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['name'],
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
- auth = auth
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
- url = f"https://api.fabric.microsoft.com/v1/admin/workspaces/{self.workspace_id}/items/{self.id}/users"
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)