msfabricpysdkcore 0.0.12__py3-none-any.whl → 0.1.1__py3-none-any.whl

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 (45) hide show
  1. msfabricpysdkcore/admin_item.py +18 -44
  2. msfabricpysdkcore/admin_workspace.py +13 -60
  3. msfabricpysdkcore/adminapi.py +400 -429
  4. msfabricpysdkcore/client.py +115 -1
  5. msfabricpysdkcore/coreapi.py +2553 -763
  6. msfabricpysdkcore/deployment_pipeline.py +34 -146
  7. msfabricpysdkcore/domain.py +20 -219
  8. msfabricpysdkcore/environment.py +13 -171
  9. msfabricpysdkcore/item.py +63 -198
  10. msfabricpysdkcore/job_instance.py +8 -22
  11. msfabricpysdkcore/lakehouse.py +9 -118
  12. msfabricpysdkcore/long_running_operation.py +7 -37
  13. msfabricpysdkcore/onelakeshortcut.py +7 -21
  14. msfabricpysdkcore/otheritems.py +66 -91
  15. msfabricpysdkcore/spark_custom_pool.py +7 -47
  16. msfabricpysdkcore/tests/test_admin_apis.py +21 -1
  17. msfabricpysdkcore/tests/test_datapipelines.py +14 -17
  18. msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
  19. msfabricpysdkcore/tests/test_domains.py +4 -3
  20. msfabricpysdkcore/tests/test_environments.py +51 -2
  21. msfabricpysdkcore/tests/test_evenhouses.py +48 -0
  22. msfabricpysdkcore/tests/test_evenstreams.py +1 -1
  23. msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
  24. msfabricpysdkcore/tests/test_items.py +80 -0
  25. msfabricpysdkcore/tests/test_kql_queryset.py +50 -0
  26. msfabricpysdkcore/tests/test_kqldatabases.py +1 -1
  27. msfabricpysdkcore/tests/test_lakehouse.py +86 -0
  28. msfabricpysdkcore/tests/test_ml_experiments.py +48 -0
  29. msfabricpysdkcore/tests/test_ml_models.py +48 -0
  30. msfabricpysdkcore/tests/test_notebooks.py +58 -0
  31. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +65 -0
  32. msfabricpysdkcore/tests/test_other_items.py +46 -0
  33. msfabricpysdkcore/tests/test_reports.py +53 -0
  34. msfabricpysdkcore/tests/test_semantic_model.py +51 -0
  35. msfabricpysdkcore/tests/test_spark.py +7 -5
  36. msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
  37. msfabricpysdkcore/tests/test_warehouses.py +51 -0
  38. msfabricpysdkcore/tests/test_workspaces_capacities.py +7 -4
  39. msfabricpysdkcore/workspace.py +397 -1121
  40. {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/METADATA +110 -8
  41. msfabricpysdkcore-0.1.1.dist-info/RECORD +52 -0
  42. {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/WHEEL +1 -1
  43. msfabricpysdkcore-0.0.12.dist-info/RECORD +0 -39
  44. {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/LICENSE +0 -0
  45. {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/top_level.txt +0 -0
@@ -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)
@@ -1,15 +1,14 @@
1
1
  import json
2
2
  from time import sleep
3
3
 
4
- import requests
5
-
6
4
  from msfabricpysdkcore.admin_item import AdminItem
5
+ from msfabricpysdkcore.adminapi import FabricClientAdmin
7
6
 
8
7
 
9
8
  class AdminWorkspace:
10
9
  """Class to represent a workspace in Microsoft Fabric"""
11
10
 
12
- def __init__(self, id, type, name, state, capacity_id, auth) -> None:
11
+ def __init__(self, id, type, name, state, capacity_id, admin_client:FabricClientAdmin) -> None:
13
12
  """Constructor for the Workspace class
14
13
 
15
14
  Args:
@@ -18,7 +17,7 @@ class AdminWorkspace:
18
17
  name (str): The name of the workspace
19
18
  state (str): The state of the workspace
20
19
  capacity_id (str): The ID of the capacity
21
- auth (Auth): The Auth object
20
+ admin_client (FabricClientAdmin): The FabricClientAdmin object
22
21
  Returns:
23
22
  Workspace: The Workspace object
24
23
  """
@@ -27,7 +26,7 @@ class AdminWorkspace:
27
26
  self.name = name
28
27
  self.state = state
29
28
  self.capacity_id = capacity_id
30
- self.auth = auth
29
+ self.admin_client = admin_client
31
30
 
32
31
 
33
32
  def __str__(self) -> str:
@@ -49,12 +48,12 @@ class AdminWorkspace:
49
48
  def __repr__(self) -> str:
50
49
  return self.__str__()
51
50
 
52
- def from_dict(item_dict, auth):
51
+ def from_dict(item_dict, admin_client):
53
52
  """Create Workspace object from dictionary
54
53
 
55
54
  Args:
56
55
  item_dict (dict): The dictionary representing the workspace
57
- auth (Auth): The Auth object
56
+ admin_client (FabricClientAdmin): The FabricClientAdmin object
58
57
  Returns:
59
58
  Workspace: The Workspace object
60
59
  """
@@ -64,39 +63,19 @@ class AdminWorkspace:
64
63
  name=item_dict['name'],
65
64
  state=item_dict['state'],
66
65
  capacity_id=item_dict['capacityId'],
67
- auth=auth
66
+ admin_client=admin_client
68
67
  )
69
-
70
- def get_workspace_access_details(self):
71
- """Get the access details of the workspace
72
-
73
- Returns:
74
- dict: The access details of the workspace
75
- """
76
- return self.list_workspace_access_details()
77
-
68
+
78
69
  def list_workspace_access_details(self):
79
70
  """Get the access details of the workspace
80
71
 
81
72
  Returns:
82
73
  dict: The access details of the workspace
83
74
  """
84
- url = f"https://api.fabric.microsoft.com/v1/admin/workspaces/{self.id}/users"
85
-
86
- for _ in range(10):
87
- response = requests.get(url=url, headers=self.auth.get_headers())
88
- if response.status_code == 429:
89
- print("Too many requests, waiting 10 seconds")
90
- sleep(10)
91
- continue
92
- if response.status_code not in (200, 429):
93
- print(response.status_code)
94
- print(response.text)
95
- raise Exception(f"Error getting workspace: {response.text}")
96
- break
75
+ return self.admin_client.list_workspace_access_details(self.id)
76
+
77
+ # Items
97
78
 
98
- return json.loads(response.text)
99
-
100
79
  def get_item(self, item_id, type = None):
101
80
  """Get an item from the workspace
102
81
 
@@ -106,22 +85,7 @@ class AdminWorkspace:
106
85
  Returns:
107
86
  AdminItem: The item object
108
87
  """
109
- url = f"https://api.fabric.microsoft.com/v1/admin/workspaces/{self.id}/items/{item_id}"
110
- if type:
111
- url += f"?type={type}"
112
- for _ in range(10):
113
- response = requests.get(url=url, headers=self.auth.get_headers())
114
- if response.status_code == 429:
115
- print("Too many requests, waiting 10 seconds")
116
- sleep(10)
117
- continue
118
- if response.status_code not in (200, 429):
119
- print(response.status_code)
120
- print(response.text)
121
- raise Exception(f"Error getting item: {response.text}")
122
- break
123
- item_dict = json.loads(response.text)
124
- return AdminItem.from_dict(item_dict, self.auth)
88
+ return self.admin_client.get_item(self.id, item_id, type)
125
89
 
126
90
  def list_item_access_details(self, item_id, type=None):
127
91
  """Get the access details of the item
@@ -132,15 +96,4 @@ class AdminWorkspace:
132
96
  Returns:
133
97
  dict: The access details of the item
134
98
  """
135
- return self.get_item(item_id, type).list_item_access_details()
136
-
137
- def get_item_access_details(self, item_id, type=None):
138
- """Get the access details of the item
139
-
140
- Args:
141
- item_id (str): The ID of the item
142
- type (str): The type of the item
143
- Returns:
144
- dict: The access details of the item
145
- """
146
- return self.list_item_access_details(item_id, type)
99
+ return self.admin_client.list_item_access_details(self.id, item_id, type)