msfabricpysdkcore 0.0.10__py3-none-any.whl → 0.0.12__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.
- msfabricpysdkcore/auth.py +9 -6
- msfabricpysdkcore/client.py +5 -4
- msfabricpysdkcore/coreapi.py +76 -16
- msfabricpysdkcore/environment.py +51 -64
- msfabricpysdkcore/item.py +1 -4
- msfabricpysdkcore/long_running_operation.py +9 -4
- msfabricpysdkcore/otheritems.py +61 -0
- msfabricpysdkcore/tests/test_datapipelines.py +48 -0
- msfabricpysdkcore/tests/test_deployment_pipeline.py +1 -2
- msfabricpysdkcore/tests/test_environments.py +48 -31
- msfabricpysdkcore/tests/test_evenstreams.py +44 -0
- msfabricpysdkcore/tests/test_git.py +2 -2
- msfabricpysdkcore/tests/test_items_incl_lakehouse.py +35 -161
- msfabricpysdkcore/tests/test_kqldatabases.py +48 -0
- msfabricpysdkcore/tests/test_sparkjobdefinition.py +55 -0
- msfabricpysdkcore/tests/test_workspaces_capacities.py +60 -50
- msfabricpysdkcore/workspace.py +163 -39
- {msfabricpysdkcore-0.0.10.dist-info → msfabricpysdkcore-0.0.12.dist-info}/METADATA +22 -8
- msfabricpysdkcore-0.0.12.dist-info/RECORD +39 -0
- {msfabricpysdkcore-0.0.10.dist-info → msfabricpysdkcore-0.0.12.dist-info}/WHEEL +1 -1
- msfabricpysdkcore-0.0.10.dist-info/RECORD +0 -35
- {msfabricpysdkcore-0.0.10.dist-info → msfabricpysdkcore-0.0.12.dist-info}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.10.dist-info → msfabricpysdkcore-0.0.12.dist-info}/top_level.txt +0 -0
@@ -10,118 +10,128 @@ class TestFabricClientCore(unittest.TestCase):
|
|
10
10
|
def __init__(self, *args, **kwargs):
|
11
11
|
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
12
12
|
self.fc = FabricClientCore()
|
13
|
-
|
14
|
-
self.display_name = "testws" + datetime_str
|
15
|
-
self.workspace_id = None
|
13
|
+
|
16
14
|
|
17
15
|
def test_end_to_end_workspace(self):
|
18
|
-
|
19
|
-
|
16
|
+
fc = self.fc
|
17
|
+
datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
18
|
+
display_name = "testws" + datetime_str
|
19
|
+
ws_created = fc.create_workspace(display_name=display_name,
|
20
20
|
description="test workspace",
|
21
21
|
exists_ok=False)
|
22
22
|
# Add assertions here to verify the result
|
23
|
-
self.assertEqual(ws_created.display_name,
|
24
|
-
|
25
|
-
ws =
|
26
|
-
self.assertEqual(ws.display_name,
|
23
|
+
self.assertEqual(ws_created.display_name, display_name)
|
24
|
+
workspace_id = ws_created.id
|
25
|
+
ws = fc.get_workspace_by_id(id = workspace_id)
|
26
|
+
self.assertEqual(ws.display_name, display_name)
|
27
27
|
self.assertEqual(ws.description, "test workspace")
|
28
28
|
|
29
29
|
# def test_assign_to_capacity(self):
|
30
30
|
|
31
|
-
result_status_code =
|
31
|
+
result_status_code = fc.assign_to_capacity(workspace_id=ws.id,
|
32
32
|
capacity_id="41cb829c-c231-4e9f-b4fc-f9042a6f9840")
|
33
33
|
self.assertEqual(result_status_code, 202)
|
34
34
|
|
35
35
|
|
36
36
|
# def test_list_workspaces(self):
|
37
37
|
|
38
|
-
result =
|
38
|
+
result = fc.list_workspaces()
|
39
39
|
display_names = [ws.display_name for ws in result]
|
40
|
-
self.assertIn(
|
40
|
+
self.assertIn(display_name, display_names)
|
41
41
|
|
42
42
|
for ws in result:
|
43
|
-
if ws.display_name ==
|
43
|
+
if ws.display_name == display_name:
|
44
44
|
self.assertEqual(ws.capacity_id, "41cb829c-c231-4e9f-b4fc-f9042a6f9840")
|
45
45
|
|
46
46
|
|
47
47
|
# def test_get_workspace_by_name(self):
|
48
48
|
|
49
|
-
workspace_name =
|
50
|
-
ws =
|
51
|
-
self.assertEqual(ws.display_name,
|
49
|
+
workspace_name = display_name
|
50
|
+
ws = fc.get_workspace_by_name(name = workspace_name)
|
51
|
+
self.assertEqual(ws.display_name, display_name)
|
52
52
|
|
53
53
|
# def test_get_workspace_by_id(self):
|
54
|
-
ws =
|
55
|
-
self.assertEqual(
|
54
|
+
ws = fc.get_workspace_by_id(id = workspace_id)
|
55
|
+
self.assertEqual(display_name, ws.display_name)
|
56
56
|
|
57
57
|
|
58
58
|
# def test_get_workspace(self):
|
59
|
-
result =
|
60
|
-
self.assertEqual(result.display_name,
|
59
|
+
result = fc.get_workspace_by_id(id = workspace_id)
|
60
|
+
self.assertEqual(result.display_name, display_name)
|
61
61
|
|
62
62
|
# def test_add_role_assignment(self):
|
63
|
-
result_status =
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
result_status = fc.add_workspace_role_assignment(workspace_id = ws.id,
|
64
|
+
principal = {"id" : "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69",
|
65
|
+
"type" : "ServicePrincipal"},
|
66
|
+
role = 'Member')
|
67
67
|
|
68
|
-
self.assertEqual(result_status,
|
68
|
+
self.assertEqual(result_status, 201)
|
69
69
|
|
70
70
|
# def test_get_workspace_role_assignments(self):
|
71
|
-
result =
|
72
|
-
self.assertTrue(
|
73
|
-
|
74
|
-
for user in result["value"]:
|
71
|
+
result = fc.list_workspace_role_assignments(workspace_id = ws.id)
|
72
|
+
self.assertTrue(len(result) == 2)
|
73
|
+
for user in result:
|
75
74
|
if user["principal"]["displayName"] == "fabrictestuser":
|
76
|
-
self.
|
75
|
+
self.assertEqual(user["role"], "Member")
|
76
|
+
|
77
|
+
# Get get_workspace_role_assignment
|
78
|
+
|
79
|
+
result = fc.get_workspace_role_assignment(workspace_id = ws.id,
|
80
|
+
workspace_role_assignment_id = "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69")
|
81
|
+
|
82
|
+
self.assertEqual(result["role"], "Member")
|
77
83
|
|
78
84
|
# def test_update_workspace_role_assignment(self):
|
79
85
|
|
80
|
-
result_status_code =
|
86
|
+
result_status_code = fc.update_workspace_role_assignment(workspace_id = ws.id,
|
81
87
|
role = "Contributor",
|
82
|
-
|
88
|
+
workspace_role_assignment_id= "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69")
|
83
89
|
|
84
90
|
self.assertEqual(result_status_code, 200)
|
85
91
|
|
86
|
-
result =
|
87
|
-
self.assertTrue(
|
88
|
-
|
89
|
-
for user in result["value"]:
|
92
|
+
result = fc.list_workspace_role_assignments(workspace_id = ws.id)
|
93
|
+
self.assertTrue(len(result) == 2)
|
94
|
+
for user in result:
|
90
95
|
if user["principal"]["displayName"] == "fabrictestuser":
|
91
96
|
self.assertTrue(user["role"] == "Contributor")
|
92
97
|
|
93
98
|
# def test_delete_role_assignment(self):
|
94
|
-
result_status_code =
|
95
|
-
|
99
|
+
result_status_code = fc.delete_workspace_role_assignment(workspace_id = ws.id,
|
100
|
+
workspace_role_assignment_id = "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69")
|
96
101
|
self.assertEqual(result_status_code, 200)
|
97
102
|
|
98
103
|
# def test_get_workspace_role_assignments(self):
|
99
|
-
result =
|
100
|
-
self.assertTrue(
|
101
|
-
|
102
|
-
user = result["value"][0]
|
104
|
+
result = fc.list_workspace_role_assignments(workspace_id = ws.id)
|
105
|
+
self.assertTrue(len(result) == 1)
|
106
|
+
user = result[0]
|
103
107
|
# self.assertTrue(user["principal"]["displayName"] == "fabricapi")
|
104
108
|
self.assertTrue(user["role"] == "Admin")
|
105
109
|
|
106
110
|
# def test_update_workspace(self):
|
107
|
-
ws_updated =
|
108
|
-
display_name="
|
111
|
+
ws_updated = fc.update_workspace(workspace_id=ws.id,
|
112
|
+
display_name="newn912389u8293",
|
109
113
|
description="new description")
|
110
|
-
self.assertEqual(ws_updated.display_name, "
|
114
|
+
self.assertEqual(ws_updated.display_name, "newn912389u8293")
|
111
115
|
self.assertEqual(ws_updated.description, "new description")
|
112
|
-
ws =
|
113
|
-
self.assertEqual(ws.display_name, "
|
116
|
+
ws = fc.get_workspace_by_id(id = ws.id)
|
117
|
+
self.assertEqual(ws.display_name, "newn912389u8293")
|
114
118
|
self.assertEqual(ws.description, "new description")
|
115
119
|
|
116
120
|
# def test_unassign_from_capacity(self):
|
117
121
|
|
118
|
-
result_status_code =
|
122
|
+
result_status_code = fc.unassign_from_capacity(workspace_id=ws.id)
|
119
123
|
self.assertEqual(result_status_code, 202)
|
120
|
-
ws =
|
124
|
+
ws = fc.get_workspace_by_id(ws.id)
|
121
125
|
self.assertEqual(ws.capacity_id, None)
|
122
126
|
|
127
|
+
# result = fc.provision_identity(workspace_id=ws.id)
|
128
|
+
# self.assertIsNotNone(result["applicationId"])
|
129
|
+
# fc.deprovision_identity(workspace_id=ws.id)
|
130
|
+
|
131
|
+
|
132
|
+
|
123
133
|
# def test_delete_workspace(self):
|
124
|
-
result_status =
|
134
|
+
result_status = fc.delete_workspace(display_name="newn912389u8293")
|
125
135
|
self.assertEqual(result_status, 200)
|
126
136
|
|
127
137
|
def test_list_capacities(self):
|
msfabricpysdkcore/workspace.py
CHANGED
@@ -6,7 +6,7 @@ from msfabricpysdkcore.lakehouse import Lakehouse
|
|
6
6
|
from msfabricpysdkcore.environment import Environment
|
7
7
|
from msfabricpysdkcore.long_running_operation import check_long_running_operation
|
8
8
|
from msfabricpysdkcore.otheritems import DataPipeline, Eventstream, KQLDatabase, KQLQueryset, SparkJobDefinition
|
9
|
-
from msfabricpysdkcore.otheritems import MLExperiment, MLModel, Notebook, Report, SemanticModel, Warehouse
|
9
|
+
from msfabricpysdkcore.otheritems import Eventhouse, MLExperiment, MLModel, Notebook, Report, SemanticModel, Warehouse
|
10
10
|
from msfabricpysdkcore.spark_custom_pool import SparkCustomPool
|
11
11
|
|
12
12
|
|
@@ -42,10 +42,13 @@ class Workspace:
|
|
42
42
|
def __repr__(self) -> str:
|
43
43
|
return self.__str__()
|
44
44
|
|
45
|
-
def
|
46
|
-
"""
|
45
|
+
def list_role_assignments(self, continuationToken = None):
|
46
|
+
"""List role assignments for the workspace"""
|
47
47
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/roleAssignments"
|
48
48
|
|
49
|
+
if continuationToken:
|
50
|
+
url = f"{url}?continuationToken={continuationToken}"
|
51
|
+
|
49
52
|
for _ in range(10):
|
50
53
|
response = requests.get(url=url, headers=self.auth.get_headers())
|
51
54
|
if response.status_code == 429:
|
@@ -58,7 +61,14 @@ class Workspace:
|
|
58
61
|
raise Exception(f"Error getting role assignments: {response.text}")
|
59
62
|
break
|
60
63
|
|
61
|
-
|
64
|
+
resp_dict = json.loads(response.text)
|
65
|
+
role_assignments = resp_dict["value"]
|
66
|
+
|
67
|
+
if "continuationToken" in resp_dict:
|
68
|
+
role_assignments_next = self.list_role_assignments(continuationToken=resp_dict["continuationToken"])
|
69
|
+
role_assignments.extend(role_assignments_next)
|
70
|
+
|
71
|
+
return role_assignments
|
62
72
|
|
63
73
|
def delete(self):
|
64
74
|
"""Delete the workspace"""
|
@@ -94,7 +104,7 @@ class Workspace:
|
|
94
104
|
print("Too many requests, waiting 10 seconds")
|
95
105
|
sleep(10)
|
96
106
|
continue
|
97
|
-
if response.status_code not in (
|
107
|
+
if response.status_code not in (201, 429):
|
98
108
|
print(response.status_code)
|
99
109
|
print(response.text)
|
100
110
|
raise Exception(f"Error adding role assignments: {response.text}")
|
@@ -103,9 +113,9 @@ class Workspace:
|
|
103
113
|
return response.status_code
|
104
114
|
|
105
115
|
|
106
|
-
def delete_role_assignment(self,
|
116
|
+
def delete_role_assignment(self, workspace_role_assignment_id):
|
107
117
|
"""Delete a role assignment from the workspace"""
|
108
|
-
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/roleAssignments/{
|
118
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/roleAssignments/{workspace_role_assignment_id}"
|
109
119
|
|
110
120
|
for _ in range(10):
|
111
121
|
response = requests.delete(url=url, headers=self.auth.get_headers())
|
@@ -140,9 +150,7 @@ class Workspace:
|
|
140
150
|
sleep(10)
|
141
151
|
continue
|
142
152
|
if response.status_code not in (200, 429):
|
143
|
-
|
144
|
-
print(response.text)
|
145
|
-
raise Exception(f"Error updating workspace: {response.text}")
|
153
|
+
raise Exception(f"Error updating workspace: {response.status_code}, {response.text}")
|
146
154
|
break
|
147
155
|
|
148
156
|
assert response.status_code == 200
|
@@ -152,10 +160,29 @@ class Workspace:
|
|
152
160
|
self.description = description
|
153
161
|
|
154
162
|
return self
|
163
|
+
|
164
|
+
def get_role_assignment(self, workspace_role_assignment_id):
|
165
|
+
# GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/roleAssignments/{workspaceRoleAssignmentId}
|
166
|
+
|
167
|
+
"""Get a role assignment from the workspace"""
|
168
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/roleAssignments/{workspace_role_assignment_id}"
|
169
|
+
|
170
|
+
for _ in range(10):
|
171
|
+
response = requests.get(url=url, headers=self.auth.get_headers())
|
155
172
|
|
156
|
-
|
173
|
+
if response.status_code == 429:
|
174
|
+
print("Too many requests, waiting 10 seconds")
|
175
|
+
sleep(10)
|
176
|
+
continue
|
177
|
+
if response.status_code not in (200, 429):
|
178
|
+
raise Exception(f"Error getting role assignments: {response.status_code}, {response.text}")
|
179
|
+
break
|
180
|
+
|
181
|
+
return json.loads(response.text)
|
182
|
+
|
183
|
+
def update_role_assignment(self, role, workspace_role_assignment_id):
|
157
184
|
"""Update a role assignment in the workspace"""
|
158
|
-
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/roleAssignments/{
|
185
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/roleAssignments/{workspace_role_assignment_id}"
|
159
186
|
body = {
|
160
187
|
'role': role
|
161
188
|
}
|
@@ -224,11 +251,52 @@ class Workspace:
|
|
224
251
|
self.capacity_id = None
|
225
252
|
return response.status_code
|
226
253
|
|
254
|
+
def provision_identity(self):
|
255
|
+
# POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/provisionIdentity
|
256
|
+
"""Provision identity for the workspace"""
|
257
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/provisionIdentity"
|
258
|
+
|
259
|
+
for _ in range(10):
|
260
|
+
response = requests.post(url=url, headers=self.auth.get_headers())
|
261
|
+
if response.status_code == 429:
|
262
|
+
print("Too many requests, waiting 10 seconds")
|
263
|
+
sleep(10)
|
264
|
+
continue
|
265
|
+
if response.status_code == 202:
|
266
|
+
return check_long_running_operation( response.headers, self.auth)
|
267
|
+
if response.status_code not in (200, 201, 202, 429):
|
268
|
+
raise Exception(f"Error provisioning identity: {response.status_code}, {response.text}")
|
269
|
+
break
|
270
|
+
|
271
|
+
return response
|
272
|
+
|
273
|
+
def deprovision_identity(self):
|
274
|
+
# POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/deprovisionIdentity
|
275
|
+
"""Deprovision identity for the workspace"""
|
276
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/deprovisionIdentity"
|
277
|
+
|
278
|
+
for _ in range(10):
|
279
|
+
response = requests.post(url=url, headers=self.auth.get_headers())
|
280
|
+
if response.status_code == 429:
|
281
|
+
print("Too many requests, waiting 10 seconds")
|
282
|
+
sleep(10)
|
283
|
+
continue
|
284
|
+
if response.status_code == 202:
|
285
|
+
return check_long_running_operation( response.headers, self.auth)
|
286
|
+
if response.status_code not in (200, 201, 202, 429):
|
287
|
+
raise Exception(f"Error deprovisioning identity: {response.status_code}, {response.text}")
|
288
|
+
break
|
289
|
+
|
290
|
+
return response
|
291
|
+
|
292
|
+
|
227
293
|
def get_item_specific(self, item_dict):
|
228
294
|
if item_dict["type"] == "DataPipeline":
|
229
295
|
return self.get_data_pipeline(item_dict["id"])
|
230
296
|
if item_dict["type"] == "Eventstream":
|
231
297
|
return self.get_eventstream(item_dict["id"])
|
298
|
+
if item_dict["type"] == "Eventhouse":
|
299
|
+
return self.get_eventhouse(item_dict["id"])
|
232
300
|
if item_dict["type"] == "KQLDatabase":
|
233
301
|
return self.get_kql_database(item_dict["id"])
|
234
302
|
if item_dict["type"] == "KQLQueryset":
|
@@ -255,7 +323,7 @@ class Workspace:
|
|
255
323
|
item_obj = Item.from_dict(item_dict, auth=self.auth)
|
256
324
|
return item_obj
|
257
325
|
|
258
|
-
def create_item(self, display_name, type, definition = None, description = None):
|
326
|
+
def create_item(self, display_name, type, definition = None, description = None, **kwargs):
|
259
327
|
"""Create an item in a workspace"""
|
260
328
|
|
261
329
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/items"
|
@@ -271,7 +339,9 @@ class Workspace:
|
|
271
339
|
|
272
340
|
if type in ["dataPipelines",
|
273
341
|
"environments",
|
274
|
-
"
|
342
|
+
"eventhouses",
|
343
|
+
"eventstreams",
|
344
|
+
"kqlDatabases",
|
275
345
|
"lakehouses",
|
276
346
|
"mlExperiments",
|
277
347
|
"mlModels",
|
@@ -281,6 +351,11 @@ class Workspace:
|
|
281
351
|
"sparkJobDefinitions",
|
282
352
|
"warehouses"]:
|
283
353
|
|
354
|
+
if type == "kqlDatabases":
|
355
|
+
if "creation_payload" not in kwargs:
|
356
|
+
raise Exception("creation_payload is required for KQLDatabase")
|
357
|
+
body["creationPayload"] = kwargs["creation_payload"]
|
358
|
+
|
284
359
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/{type}"
|
285
360
|
body.pop('type')
|
286
361
|
|
@@ -307,7 +382,9 @@ class Workspace:
|
|
307
382
|
|
308
383
|
type_mapping = {"dataPipelines": "DataPipeline",
|
309
384
|
"environments": "Environment",
|
385
|
+
"eventhouses": "Eventhouse",
|
310
386
|
"eventstreams": "Eventstream",
|
387
|
+
"kqlDatabases": "KQLDatabase",
|
311
388
|
"lakehouses": "Lakehouse",
|
312
389
|
"mlExperiments": "MLExperiment",
|
313
390
|
"mlModels": "MLModel",
|
@@ -693,7 +770,7 @@ class Workspace:
|
|
693
770
|
|
694
771
|
def list_data_pipelines(self, with_properties = False):
|
695
772
|
"""List data pipelines in a workspace"""
|
696
|
-
return self.list_items(
|
773
|
+
return self.list_items(type="dataPipelines", with_properties=with_properties)
|
697
774
|
|
698
775
|
def get_data_pipeline(self, data_pipeline_id = None, data_pipeline_name = None):
|
699
776
|
"""Get a data pipeline from a workspace"""
|
@@ -721,7 +798,7 @@ class Workspace:
|
|
721
798
|
|
722
799
|
def list_environments(self, with_properties = False):
|
723
800
|
"""List environments in a workspace"""
|
724
|
-
return self.list_items(type="environments", with_properties=with_properties)
|
801
|
+
return self.list_items(type="environments", with_properties = with_properties)
|
725
802
|
|
726
803
|
def create_environment(self, display_name, description = None):
|
727
804
|
"""Create an environment in a workspace"""
|
@@ -741,10 +818,6 @@ class Workspace:
|
|
741
818
|
|
742
819
|
item_dict = self.get_item_internal(url)
|
743
820
|
env = Environment.from_dict(item_dict, auth=self.auth)
|
744
|
-
#env.get_staging_settings()
|
745
|
-
#env.get_published_settings()
|
746
|
-
#env.get_staging_libraries()
|
747
|
-
#env.get_published_libraries()
|
748
821
|
return env
|
749
822
|
|
750
823
|
def delete_environment(self, environment_id):
|
@@ -765,13 +838,18 @@ class Workspace:
|
|
765
838
|
def get_staging_settings(self, environment_id):
|
766
839
|
return self.get_environment(environment_id).get_staging_settings()
|
767
840
|
|
768
|
-
def update_staging_settings(self, environment_id,
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
841
|
+
def update_staging_settings(self, environment_id,
|
842
|
+
driver_cores = None, driver_memory = None, dynamic_executor_allocation = None,
|
843
|
+
executor_cores = None, executor_memory = None, instance_pool = None,
|
844
|
+
runtime_version = None, spark_properties = None):
|
845
|
+
return self.get_environment(environment_id).update_staging_settings(driver_cores=driver_cores,
|
846
|
+
driver_memory=driver_memory,
|
847
|
+
dynamic_executor_allocation=dynamic_executor_allocation,
|
848
|
+
executor_cores=executor_cores,
|
849
|
+
executor_memory=executor_memory,
|
850
|
+
instance_pool=instance_pool,
|
851
|
+
runtime_version=runtime_version,
|
852
|
+
spark_properties=spark_properties)
|
775
853
|
|
776
854
|
# environment spark libraries
|
777
855
|
|
@@ -781,8 +859,8 @@ class Workspace:
|
|
781
859
|
def get_staging_libraries(self, environment_id):
|
782
860
|
return self.get_environment(environment_id).get_staging_libraries()
|
783
861
|
|
784
|
-
def
|
785
|
-
return self.get_environment(environment_id).
|
862
|
+
def upload_staging_library(self, environment_id, file_path):
|
863
|
+
return self.get_environment(environment_id).upload_staging_library(file_path)
|
786
864
|
|
787
865
|
def publish_environment(self, environment_id):
|
788
866
|
return self.get_environment(environment_id).publish_environment()
|
@@ -793,11 +871,45 @@ class Workspace:
|
|
793
871
|
def cancel_publish(self, environment_id):
|
794
872
|
return self.get_environment(environment_id).cancel_publish()
|
795
873
|
|
874
|
+
# eventhouses
|
875
|
+
def list_eventhouses(self, with_properties = False):
|
876
|
+
"""List eventhouses in a workspace"""
|
877
|
+
return self.list_items(type="eventhouses", with_properties=with_properties)
|
878
|
+
|
879
|
+
def create_eventhouse(self, display_name, description = None):
|
880
|
+
"""Create an eventhouse in a workspace"""
|
881
|
+
return self.create_item(display_name = display_name,
|
882
|
+
type = "eventhouses",
|
883
|
+
definition = None,
|
884
|
+
description = description)
|
885
|
+
|
886
|
+
def get_eventhouse(self, eventhouse_id = None, eventhouse_name = None):
|
887
|
+
"""Get an eventhouse from a workspace"""
|
888
|
+
if eventhouse_id is None and eventhouse_name is not None:
|
889
|
+
return self.get_item_by_name(eventhouse_name, "Eventhouse")
|
890
|
+
elif eventhouse_id is None:
|
891
|
+
raise Exception("eventhouse_id or the eventhouse_name is required")
|
892
|
+
|
893
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.id}/eventhouses/{eventhouse_id}"
|
894
|
+
|
895
|
+
item_dict = self.get_item_internal(url)
|
896
|
+
return Eventhouse.from_dict(item_dict, auth=self.auth)
|
897
|
+
|
898
|
+
def delete_eventhouse(self, eventhouse_id):
|
899
|
+
"""Delete an eventhouse from a workspace"""
|
900
|
+
return self.get_item(item_id=eventhouse_id).delete(type="eventhouses")
|
901
|
+
|
902
|
+
def update_eventhouse(self, eventhouse_id, display_name = None, description = None):
|
903
|
+
"""Update an eventhouse in a workspace"""
|
904
|
+
return self.get_item(item_id=eventhouse_id).update(display_name=display_name,
|
905
|
+
description=description,
|
906
|
+
type="eventhouses")
|
907
|
+
|
796
908
|
# eventstreams
|
797
909
|
|
798
|
-
def list_eventstreams(self):
|
910
|
+
def list_eventstreams(self, with_properties = False):
|
799
911
|
"""List eventstreams in a workspace"""
|
800
|
-
return self.list_items(type="eventstreams")
|
912
|
+
return self.list_items(type="eventstreams", with_properties=with_properties)
|
801
913
|
|
802
914
|
def create_eventstream(self, display_name, description = None):
|
803
915
|
"""Create an eventstream in a workspace"""
|
@@ -830,9 +942,16 @@ class Workspace:
|
|
830
942
|
|
831
943
|
# kqlDatabases
|
832
944
|
|
833
|
-
def list_kql_databases(self):
|
945
|
+
def list_kql_databases(self, with_properties = False):
|
834
946
|
"""List kql databases in a workspace"""
|
835
|
-
return self.list_items(type="kqlDatabases")
|
947
|
+
return self.list_items(type="kqlDatabases", with_properties = with_properties)
|
948
|
+
|
949
|
+
def create_kql_database(self, creation_payload, display_name, description = None, ):
|
950
|
+
"""Create a kql database in a workspace"""
|
951
|
+
return self.create_item(display_name = display_name,
|
952
|
+
type = "kqlDatabases",
|
953
|
+
description = description,
|
954
|
+
creation_payload = creation_payload)
|
836
955
|
|
837
956
|
def get_kql_database(self, kql_database_id = None, kql_database_name = None):
|
838
957
|
"""Get a kql database from a workspace"""
|
@@ -859,9 +978,9 @@ class Workspace:
|
|
859
978
|
|
860
979
|
# kqlQuerysets
|
861
980
|
|
862
|
-
def list_kql_querysets(self):
|
981
|
+
def list_kql_querysets(self, with_properties = False):
|
863
982
|
"""List kql querysets in a workspace"""
|
864
|
-
return self.list_items(type="kqlQuerysets")
|
983
|
+
return self.list_items(type="kqlQuerysets", with_properties = with_properties)
|
865
984
|
|
866
985
|
def get_kql_queryset(self, kql_queryset_id = None, kql_queryset_name = None):
|
867
986
|
"""Get a kql queryset from a workspace"""
|
@@ -925,9 +1044,9 @@ class Workspace:
|
|
925
1044
|
|
926
1045
|
# mlExperiments
|
927
1046
|
|
928
|
-
def list_ml_experiments(self):
|
1047
|
+
def list_ml_experiments(self, with_properties = False):
|
929
1048
|
"""List ml experiments in a workspace"""
|
930
|
-
return self.list_items(type="mlExperiments")
|
1049
|
+
return self.list_items(type="mlExperiments", with_properties = with_properties)
|
931
1050
|
|
932
1051
|
def create_ml_experiment(self, display_name, description = None):
|
933
1052
|
"""Create an ml experiment in a workspace"""
|
@@ -960,9 +1079,9 @@ class Workspace:
|
|
960
1079
|
|
961
1080
|
# mlModels
|
962
1081
|
|
963
|
-
def list_ml_models(self):
|
1082
|
+
def list_ml_models(self, with_properties = False):
|
964
1083
|
"""List ml models in a workspace"""
|
965
|
-
return self.list_items(type="mlModels")
|
1084
|
+
return self.list_items(type="mlModels", with_properties = with_properties)
|
966
1085
|
|
967
1086
|
def create_ml_model(self, display_name, description = None):
|
968
1087
|
"""Create an ml model in a workspace"""
|
@@ -1167,6 +1286,11 @@ class Workspace:
|
|
1167
1286
|
"""Update the definition of a spark job definition in a workspace"""
|
1168
1287
|
return self.get_spark_job_definition(spark_job_definition_id=spark_job_definition_id).update_definition(definition=definition)
|
1169
1288
|
|
1289
|
+
def run_on_demand_spark_job_definition(self, spark_job_definition_id, job_type = "sparkjob"):
|
1290
|
+
"""Run on demand spark job definition"""
|
1291
|
+
sjd = self.get_spark_job_definition(spark_job_definition_id=spark_job_definition_id)
|
1292
|
+
return sjd.run_on_demand_spark_job_definition(job_type=job_type)
|
1293
|
+
|
1170
1294
|
# warehouses
|
1171
1295
|
|
1172
1296
|
def list_warehouses(self, with_properties = False):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: msfabricpysdkcore
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.12
|
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
|
@@ -148,26 +148,40 @@ ws.add_role_assignment(principal = {"id" : "abadfbafb",
|
|
148
148
|
role = 'Member')
|
149
149
|
|
150
150
|
|
151
|
-
#
|
152
|
-
fc.
|
151
|
+
# List workspace role assignments
|
152
|
+
fc.list_workspace_role_assignments(workspace_id = ws.id)
|
153
153
|
# or
|
154
|
-
ws.
|
154
|
+
ws.list_role_assignments()
|
155
155
|
|
156
156
|
|
157
|
+
# Get workspace role assignment
|
158
|
+
fc.get_workspace_role_assignment(workspace_id = ws.id,
|
159
|
+
workspace_role_assignment_id = "dagdasf")
|
160
|
+
# or
|
161
|
+
ws.get_role_assignment(workspace_role_assignment_id = "fsgdg")
|
162
|
+
|
157
163
|
# Update workspace role assignment
|
158
164
|
fc.update_workspace_role_assignment(workspace_id = ws.id,
|
159
165
|
role = "Contributor",
|
160
|
-
|
166
|
+
workspace_role_assignment_id = "abadfbafb")
|
161
167
|
# or
|
162
168
|
ws.update_role_assignment(role = "Contributor",
|
163
|
-
|
169
|
+
workspace_role_assignment_id = "abadfbafb")
|
164
170
|
|
165
171
|
|
166
172
|
# Delete workspace role assignment
|
167
173
|
fc.delete_workspace_role_assignment(workspace_id = ws.id,
|
168
|
-
|
174
|
+
workspace_role_assignment_id = "abadfbafb")
|
169
175
|
# or
|
170
|
-
ws.delete_role_assignment(
|
176
|
+
ws.delete_role_assignment(workspace_role_assignment_id = "abadfbafb")
|
177
|
+
|
178
|
+
|
179
|
+
# Provision Identity
|
180
|
+
result = fc.provision_identity(workspace_id=ws.id)
|
181
|
+
print(result["applicationId"]))
|
182
|
+
|
183
|
+
# Deprovision Identity
|
184
|
+
fc.deprovision_identity(workspace_id=ws.id)
|
171
185
|
|
172
186
|
```
|
173
187
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
msfabricpysdkcore/__init__.py,sha256=nh8-lxdMBWYSbQpbRxWkn3ZRpGipmQplTudjskN2l88,78
|
2
|
+
msfabricpysdkcore/admin_item.py,sha256=OGVfMMqAKy80Ukp8TJnpXoRq8WbWX7Qq1hz7tmfiUBU,4020
|
3
|
+
msfabricpysdkcore/admin_workspace.py,sha256=RctVsXZ57ppiybua69BW_yVpUbrGic6fYOjFPZFPAzA,4862
|
4
|
+
msfabricpysdkcore/adminapi.py,sha256=uithaYq_HWDU-9Et_EFBNQfrjcjnI-NW6OCmWoAsZxk,25649
|
5
|
+
msfabricpysdkcore/auth.py,sha256=v5YkI4jA6T7lv5rjqTK-GEPx2ATDPKQ1LVcaCg98oLM,2562
|
6
|
+
msfabricpysdkcore/capacity.py,sha256=Q_2-XrZtdf9F67fY0qU3D0ocEOGQq4KtIXAv9dXjQhI,1761
|
7
|
+
msfabricpysdkcore/client.py,sha256=yOZ1CW2ilL8a7J_SRNa-EQbG8xNlJKW3ygniIrsADsw,1300
|
8
|
+
msfabricpysdkcore/coreapi.py,sha256=IUutbCz_Dag2rFWbmbSVt8AkFnj4CJdP-v-jXOrFrBA,49645
|
9
|
+
msfabricpysdkcore/deployment_pipeline.py,sha256=RFI86rtG-eTpV-_tVl3cXtcTl9ekRvOI5fLsXo9CMVA,9739
|
10
|
+
msfabricpysdkcore/domain.py,sha256=i8jMJEutDRL5XuQ69woCVQEzLS_lm9uUxl4Kp3xtxHc,14722
|
11
|
+
msfabricpysdkcore/environment.py,sha256=ENgy7URz_gJ4E5-OH355QF6vqawBoHjHMbjnoEJfGwM,10072
|
12
|
+
msfabricpysdkcore/item.py,sha256=HIr32drqNtlIKKXkXCcWI2H_TZMDalCxvikTyDHNprA,11428
|
13
|
+
msfabricpysdkcore/job_instance.py,sha256=C9kKsV-BIJSeU6DfoTnLlg4DLp-8RYpovs0A-mKwi4o,2745
|
14
|
+
msfabricpysdkcore/lakehouse.py,sha256=nv95SBz_jsssT5dEw622WqtDHUyh5bFFsVTwiqo8s-c,6055
|
15
|
+
msfabricpysdkcore/long_running_operation.py,sha256=Itm8ohr9fPIdP7UO9_xehQ6wb6t4hsCuvDbcOSzAgVA,2981
|
16
|
+
msfabricpysdkcore/onelakeshortcut.py,sha256=EYZfP-rl60HdCqJD1O1NXrQTgrYTIw-EWisF4hs4bTU,2102
|
17
|
+
msfabricpysdkcore/otheritems.py,sha256=D-sGriO9ck4pqzsLY6bZLJUDXIBkyNyqCPoJmgextbk,12571
|
18
|
+
msfabricpysdkcore/spark_custom_pool.py,sha256=2H-GkGcDsiKxSpXFSf8Zi7xJI5_krb_8sGdF5vDjEy8,4635
|
19
|
+
msfabricpysdkcore/workspace.py,sha256=IdP0qDXD-0JVZnK_cn9VILNQ5-FQGFzGXq-MoCkLyWs,68563
|
20
|
+
msfabricpysdkcore/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
+
msfabricpysdkcore/tests/test_admin_apis.py,sha256=HTXt72p9FiEf3q9SXyq9aImR6zZo_xIREfB0xPaYazU,2586
|
22
|
+
msfabricpysdkcore/tests/test_datapipelines.py,sha256=rIeZfv-MGewYYscb36jmjL8DLZ3Z1dJWv09foR9z_y8,1812
|
23
|
+
msfabricpysdkcore/tests/test_deployment_pipeline.py,sha256=7bXqSpnU8Hb7KyKldhA7hVM8QqKHj0WoT9_kC27hsxM,2058
|
24
|
+
msfabricpysdkcore/tests/test_domains.py,sha256=KFGQyl0G2v4JjX_xYHY-vPSjYxeLEx3AcXMdiRZzClc,4620
|
25
|
+
msfabricpysdkcore/tests/test_environments.py,sha256=zSIMhkQscMB7doJEQRBRMvAEBxO1Kl1N85MKXP3yeYI,3120
|
26
|
+
msfabricpysdkcore/tests/test_evenstreams.py,sha256=i6hhsOnDJ-BN7kStg7gQhZVPMVaB73K7KJez6pEKlv0,1628
|
27
|
+
msfabricpysdkcore/tests/test_git.py,sha256=pmhVYZGDMEFtgy51hKrDWqtea-MryyeyvPKVCaTsIEA,2415
|
28
|
+
msfabricpysdkcore/tests/test_items_incl_lakehouse.py,sha256=zWNmOI_Ysh96d8P-Sm4IOCzMqXTCEBg63lxCDZZ_9b8,17987
|
29
|
+
msfabricpysdkcore/tests/test_jobs.py,sha256=DC1nQTav_Re7uunRA07wD_56giLqe9KOsgm56Il8Zr4,1632
|
30
|
+
msfabricpysdkcore/tests/test_kqldatabases.py,sha256=Oc2ZzpQAVbiJeZ5ytwlP2Jb-tKe-2e9-1oA-upwRKBQ,1921
|
31
|
+
msfabricpysdkcore/tests/test_shortcuts.py,sha256=TqGLzEWsDyiQ0Gf6JpT_qBHUCgcvYXfVwpXxOay7Qz4,2407
|
32
|
+
msfabricpysdkcore/tests/test_spark.py,sha256=5BCAgHRiuXjIRnGrbvNNh9emq0VyZXlvIWgWAEir5ZQ,3437
|
33
|
+
msfabricpysdkcore/tests/test_sparkjobdefinition.py,sha256=whADi8l4opMaoB4b1W5EbuddyB5tC5OEqGRFKVUYMH4,2820
|
34
|
+
msfabricpysdkcore/tests/test_workspaces_capacities.py,sha256=52FqGZRVvHDegLgu71kGX_Tx4cRh9lO_wuK8BG_czkQ,6699
|
35
|
+
msfabricpysdkcore-0.0.12.dist-info/LICENSE,sha256=1NrGuF-zOmzbwzk3iI6lsP9koyDeKO1B0-8OD_tTvOQ,1156
|
36
|
+
msfabricpysdkcore-0.0.12.dist-info/METADATA,sha256=bK4vYEgjRLyzNJhBUnSSI6I9GlWnZcXIYDoo5z6__TY,17944
|
37
|
+
msfabricpysdkcore-0.0.12.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
38
|
+
msfabricpysdkcore-0.0.12.dist-info/top_level.txt,sha256=3iRonu6ptDGQN4Yl6G76XGM7xbFNsskiEHW-P2gMQGY,18
|
39
|
+
msfabricpysdkcore-0.0.12.dist-info/RECORD,,
|