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.
- msfabricpysdkcore/admin_item.py +18 -44
- msfabricpysdkcore/admin_workspace.py +13 -60
- msfabricpysdkcore/adminapi.py +400 -429
- msfabricpysdkcore/client.py +115 -1
- msfabricpysdkcore/coreapi.py +2553 -763
- msfabricpysdkcore/deployment_pipeline.py +34 -146
- msfabricpysdkcore/domain.py +20 -219
- msfabricpysdkcore/environment.py +13 -171
- msfabricpysdkcore/item.py +63 -198
- msfabricpysdkcore/job_instance.py +8 -22
- msfabricpysdkcore/lakehouse.py +9 -118
- msfabricpysdkcore/long_running_operation.py +7 -37
- msfabricpysdkcore/onelakeshortcut.py +7 -21
- msfabricpysdkcore/otheritems.py +66 -91
- msfabricpysdkcore/spark_custom_pool.py +7 -47
- msfabricpysdkcore/tests/test_admin_apis.py +21 -1
- msfabricpysdkcore/tests/test_datapipelines.py +14 -17
- msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
- msfabricpysdkcore/tests/test_domains.py +4 -3
- msfabricpysdkcore/tests/test_environments.py +51 -2
- msfabricpysdkcore/tests/test_evenhouses.py +48 -0
- msfabricpysdkcore/tests/test_evenstreams.py +1 -1
- msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
- msfabricpysdkcore/tests/test_items.py +80 -0
- msfabricpysdkcore/tests/test_kql_queryset.py +50 -0
- msfabricpysdkcore/tests/test_kqldatabases.py +1 -1
- msfabricpysdkcore/tests/test_lakehouse.py +86 -0
- msfabricpysdkcore/tests/test_ml_experiments.py +48 -0
- msfabricpysdkcore/tests/test_ml_models.py +48 -0
- msfabricpysdkcore/tests/test_notebooks.py +58 -0
- msfabricpysdkcore/tests/test_one_lake_data_access_security.py +65 -0
- msfabricpysdkcore/tests/test_other_items.py +46 -0
- msfabricpysdkcore/tests/test_reports.py +53 -0
- msfabricpysdkcore/tests/test_semantic_model.py +51 -0
- msfabricpysdkcore/tests/test_spark.py +7 -5
- msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
- msfabricpysdkcore/tests/test_warehouses.py +51 -0
- msfabricpysdkcore/tests/test_workspaces_capacities.py +7 -4
- msfabricpysdkcore/workspace.py +397 -1121
- {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/METADATA +110 -8
- msfabricpysdkcore-0.1.1.dist-info/RECORD +52 -0
- {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/WHEEL +1 -1
- msfabricpysdkcore-0.0.12.dist-info/RECORD +0 -39
- {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.12.dist-info → msfabricpysdkcore-0.1.1.dist-info}/top_level.txt +0 -0
@@ -1,21 +1,18 @@
|
|
1
1
|
import json
|
2
|
-
from time import sleep
|
3
|
-
|
4
|
-
import requests
|
5
|
-
from msfabricpysdkcore.long_running_operation import check_long_running_operation
|
6
2
|
|
3
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
7
4
|
|
8
5
|
class DeploymentPipeline:
|
9
6
|
"""Class to represent a deployment pipeline in Microsoft Fabric"""
|
10
7
|
|
11
|
-
def __init__(self, id, display_name, description,
|
8
|
+
def __init__(self, id, display_name, description, core_client: FabricClientCore) -> None:
|
12
9
|
self.id = id
|
13
10
|
self.display_name = display_name
|
14
11
|
self.description = description
|
15
|
-
self.
|
12
|
+
self.core_client = core_client
|
16
13
|
|
17
14
|
|
18
|
-
def from_dict(dict,
|
15
|
+
def from_dict(dict, core_client):
|
19
16
|
"""Create a Workspace object from a dictionary"""
|
20
17
|
if dict["displayName"] == None:
|
21
18
|
dict["displayName"] = dict["display_name"]
|
@@ -25,7 +22,7 @@ class DeploymentPipeline:
|
|
25
22
|
id=dict["id"],
|
26
23
|
display_name=dict["displayName"],
|
27
24
|
description=dict["description"],
|
28
|
-
|
25
|
+
core_client=core_client
|
29
26
|
)
|
30
27
|
|
31
28
|
|
@@ -37,128 +34,38 @@ class DeploymentPipeline:
|
|
37
34
|
|
38
35
|
def __repr__(self) -> str:
|
39
36
|
return self.__str__()
|
40
|
-
|
41
|
-
def get_pipeline(deployment_pipeline_id, auth):
|
42
|
-
"""Get a deployment pipeline"""
|
43
|
-
# GET https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}
|
44
|
-
|
45
|
-
url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}"
|
46
|
-
|
47
|
-
for _ in range(10):
|
48
|
-
response = requests.get(url=url, headers=auth.get_headers())
|
49
|
-
if response.status_code == 429:
|
50
|
-
print("Too many requests, waiting 10 seconds")
|
51
|
-
sleep(10)
|
52
|
-
continue
|
53
|
-
if response.status_code not in (200, 429):
|
54
|
-
print(response.status_code)
|
55
|
-
print(response.text)
|
56
|
-
raise Exception(f"Error getting item: {response.text}")
|
57
|
-
break
|
58
|
-
|
59
|
-
item_dict = json.loads(response.text)
|
60
|
-
return DeploymentPipeline.from_dict(item_dict, auth)
|
61
|
-
|
62
|
-
def get_stages(self, continuationToken = None):
|
63
|
-
"""Get stages in a deployment pipeline"""
|
64
|
-
# GET https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/stages
|
65
|
-
|
66
|
-
url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{self.id}/stages"
|
67
|
-
|
68
|
-
if continuationToken:
|
69
|
-
url += f"?continuationToken={continuationToken}"
|
70
|
-
|
71
|
-
for _ in range(10):
|
72
|
-
response = requests.get(url=url, headers=self.auth.get_headers())
|
73
|
-
if response.status_code == 429:
|
74
|
-
print("Too many requests, waiting 10 seconds")
|
75
|
-
sleep(10)
|
76
|
-
continue
|
77
|
-
if response.status_code not in (200, 429):
|
78
|
-
print(response.status_code)
|
79
|
-
print(response.text)
|
80
|
-
raise Exception(f"Error getting stages: {response.text}")
|
81
|
-
break
|
82
|
-
|
83
|
-
resp_dict = json.loads(response.text)
|
84
|
-
items = resp_dict["value"]
|
85
|
-
for item in items:
|
86
|
-
item["deploymentPipelineId"] = self.id
|
87
|
-
stages = [Deployment_Pipeline_Stage.from_dict(item, self.auth) for item in items]
|
88
|
-
|
89
|
-
if "continuationToken" in resp_dict:
|
90
|
-
stages_next = self.get_stages(continuationToken=resp_dict["continuationToken"])
|
91
|
-
stages.extend(stages_next)
|
92
|
-
|
93
|
-
return stages
|
94
|
-
|
95
37
|
|
96
38
|
def deploy(self, source_stage_id, target_stage_id, created_workspace_details = None,
|
97
39
|
items = None, note = None, wait_for_completion = True):
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
"targetStageId": target_stage_id
|
105
|
-
}
|
106
|
-
|
107
|
-
if created_workspace_details:
|
108
|
-
body["createdWorkspaceDetails"] = created_workspace_details
|
109
|
-
if items:
|
110
|
-
body["items"] = items
|
111
|
-
if note:
|
112
|
-
body["note"] = note
|
113
|
-
|
114
|
-
|
115
|
-
for _ in range(10):
|
116
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
117
|
-
if response.status_code == 429:
|
118
|
-
print("Too many requests, waiting 10 seconds")
|
119
|
-
sleep(10)
|
120
|
-
continue
|
121
|
-
if response.status_code == 202 and wait_for_completion:
|
122
|
-
print("successfully started the operation")
|
123
|
-
try:
|
124
|
-
operation_result = check_long_running_operation( response.headers, self.auth)
|
125
|
-
return operation_result
|
126
|
-
except Exception as e:
|
127
|
-
print("Problem waiting for long running operation. Returning initial response.")
|
128
|
-
print(e)
|
129
|
-
return response
|
130
|
-
if response.status_code not in (200, 429):
|
131
|
-
print(response.status_code)
|
132
|
-
print(response.text)
|
133
|
-
raise Exception(f"Error deploying: {response.text}")
|
134
|
-
break
|
135
|
-
|
136
|
-
return response.json()
|
40
|
+
return self.core_client.deploy_stage_content(deployment_pipeline_id=self.id, source_stage_id=source_stage_id,
|
41
|
+
target_stage_id=target_stage_id, created_workspace_details=created_workspace_details,
|
42
|
+
items=items, note=note, wait_for_completion=wait_for_completion)
|
43
|
+
|
44
|
+
def get_pipeline(deployment_pipeline_id, core_client: FabricClientCore):
|
45
|
+
return core_client.get_deployment_pipeline(deployment_pipeline_id=deployment_pipeline_id)
|
137
46
|
|
138
47
|
|
48
|
+
def get_stages(self):
|
49
|
+
print("DEPRECATED: Use list_stages() instead")
|
50
|
+
return self.list_stages(self)
|
51
|
+
|
52
|
+
def list_stages(self):
|
53
|
+
return self.core_client.list_deployment_pipeline_stages(deployment_pipeline_id=self.id)
|
54
|
+
|
139
55
|
|
140
56
|
def get_deployment_pipeline_stages_items(self, stage_id = None, stage_name = None):
|
141
|
-
"
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
dep_pip_stages = [stage for stage in stages if stage.display_name == stage_name]
|
148
|
-
if len(dep_pip_stages) == 0:
|
149
|
-
raise Exception(f"Stage with name {stage_name} not found")
|
150
|
-
else:
|
151
|
-
dep_pip_stages = [stage for stage in stages if stage.id == stage_id]
|
152
|
-
if len(dep_pip_stages) == 0:
|
153
|
-
raise Exception(f"Stage with id {stage_id} not found")
|
154
|
-
dep_pip_stage = dep_pip_stages[0]
|
155
|
-
return dep_pip_stage.get_items()
|
57
|
+
print("DEPRECATED: Use list_deployment_pipeline_stages_items() instead")
|
58
|
+
return self.list_deployment_pipeline_stages_items(stage_id=stage_id, stage_name=stage_name)
|
59
|
+
|
60
|
+
|
61
|
+
def list_deployment_pipeline_stages_items(self, stage_id = None, stage_name = None):
|
62
|
+
return self.core_client.list_deployment_pipeline_stages_items(deployment_pipeline_id=self.id, stage_id=stage_id, stage_name=stage_name)
|
156
63
|
|
157
64
|
class Deployment_Pipeline_Stage():
|
158
65
|
|
159
66
|
"""Class to represent a deployment pipeline stage in Microsoft Fabric"""
|
160
67
|
|
161
|
-
def __init__(self, id, order, display_name, description, workspace_id, workspace_name, is_public, deployment_pipeline_id,
|
68
|
+
def __init__(self, id, order, display_name, description, workspace_id, workspace_name, is_public, deployment_pipeline_id, core_client: FabricClientCore) -> None:
|
162
69
|
self.id = id
|
163
70
|
self.order = order
|
164
71
|
self.display_name = display_name
|
@@ -167,10 +74,10 @@ class Deployment_Pipeline_Stage():
|
|
167
74
|
self.workspace_name = workspace_name
|
168
75
|
self.is_public = is_public
|
169
76
|
self.deployment_pipeline_id = deployment_pipeline_id
|
170
|
-
self.
|
77
|
+
self.core_client = core_client
|
171
78
|
|
172
79
|
|
173
|
-
def from_dict(dict,
|
80
|
+
def from_dict(dict, core_client):
|
174
81
|
"""Create a Workspace object from a dictionary"""
|
175
82
|
if dict["displayName"] is None:
|
176
83
|
dict["displayName"] = dict["display_name"]
|
@@ -196,7 +103,7 @@ class Deployment_Pipeline_Stage():
|
|
196
103
|
workspace_name=dict["workspaceName"],
|
197
104
|
is_public=dict["isPublic"],
|
198
105
|
deployment_pipeline_id=dict["deploymentPipelineId"],
|
199
|
-
|
106
|
+
core_client=core_client
|
200
107
|
)
|
201
108
|
|
202
109
|
def __str__(self) -> str:
|
@@ -212,29 +119,10 @@ class Deployment_Pipeline_Stage():
|
|
212
119
|
def __repr__(self) -> str:
|
213
120
|
return self.__str__()
|
214
121
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
if continuationToken is not None:
|
222
|
-
url += f"?continuationToken={continuationToken}"
|
223
|
-
|
224
|
-
for _ in range(10):
|
225
|
-
response = requests.get(url=url, headers=self.auth.get_headers())
|
226
|
-
if response.status_code == 429:
|
227
|
-
print("Too many requests, waiting 10 seconds")
|
228
|
-
sleep(10)
|
229
|
-
continue
|
230
|
-
if response.status_code not in (200, 429):
|
231
|
-
print(response.status_code)
|
232
|
-
print(response.text)
|
233
|
-
raise Exception(f"Error getting items: {response.text}")
|
234
|
-
break
|
235
|
-
|
236
|
-
resp_dict = json.loads(response.text)
|
237
|
-
items = resp_dict["value"]
|
238
|
-
return items
|
239
|
-
|
122
|
+
def get_items(self):
|
123
|
+
print("DEPRECATED: Use list_items() instead")
|
124
|
+
return self.list_items()
|
125
|
+
|
126
|
+
def list_items(self):
|
127
|
+
return self.core_client.list_deployment_pipeline_stages_items(deployment_pipeline_id=self.deployment_pipeline_id, stage_id=self.id)
|
240
128
|
|
msfabricpysdkcore/domain.py
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
import json
|
2
|
-
from
|
3
|
-
|
4
|
-
import requests
|
5
|
-
from msfabricpysdkcore.long_running_operation import check_long_running_operation
|
2
|
+
from msfabricpysdkcore.adminapi import FabricClientAdmin
|
6
3
|
|
7
4
|
class Domain:
|
8
5
|
"""Class to represent a domain in Microsoft Fabric"""
|
9
6
|
|
10
|
-
def __init__(self, id, display_name, description, parent_domain_id, contributors_scope,
|
7
|
+
def __init__(self, id, display_name, description, parent_domain_id, contributors_scope, core_client: FabricClientAdmin):
|
11
8
|
"""Constructor for the Domain class
|
12
9
|
|
13
10
|
Args:
|
@@ -25,7 +22,7 @@ class Domain:
|
|
25
22
|
self.parent_domain_id = parent_domain_id
|
26
23
|
self.contributors_scope = contributors_scope
|
27
24
|
|
28
|
-
self.
|
25
|
+
self.core_client = core_client
|
29
26
|
|
30
27
|
def __str__(self):
|
31
28
|
"""Method to return a string representation of the Domain object
|
@@ -45,7 +42,7 @@ class Domain:
|
|
45
42
|
def __repr__(self) -> str:
|
46
43
|
return self.__str__()
|
47
44
|
|
48
|
-
def from_dict(dic,
|
45
|
+
def from_dict(dic, core_client):
|
49
46
|
"""Method to create a Domain object from a dictionary
|
50
47
|
|
51
48
|
Args:
|
@@ -62,9 +59,9 @@ class Domain:
|
|
62
59
|
dic["contributors_scope"] = dic["contributorsScope"]
|
63
60
|
return Domain(id=dic['id'], display_name=dic['display_name'],
|
64
61
|
description=dic['description'], parent_domain_id=dic['parent_domain_id'],
|
65
|
-
contributors_scope=dic['contributors_scope'],
|
62
|
+
contributors_scope=dic['contributors_scope'], core_client=core_client)
|
66
63
|
|
67
|
-
def list_domain_workspaces(self, workspace_objects = False
|
64
|
+
def list_domain_workspaces(self, workspace_objects = False):
|
68
65
|
"""Method to list the workspaces in the domain
|
69
66
|
|
70
67
|
Args:
|
@@ -72,37 +69,7 @@ class Domain:
|
|
72
69
|
Returns:
|
73
70
|
list: The list of workspaces in the domain
|
74
71
|
"""
|
75
|
-
|
76
|
-
from msfabricpysdkcore import FabricClientCore
|
77
|
-
fc = FabricClientCore()
|
78
|
-
|
79
|
-
url = f"https://api.fabric.microsoft.com/v1/admin/domains/{self.id}/workspaces"
|
80
|
-
if continuationToken:
|
81
|
-
url = f"{url}?continuationToken={continuationToken}"
|
82
|
-
|
83
|
-
for _ in range(10):
|
84
|
-
response = requests.get(url=url, headers=self.auth.get_headers())
|
85
|
-
if response.status_code == 429:
|
86
|
-
print("Too many requests, waiting 10 seconds")
|
87
|
-
sleep(10)
|
88
|
-
continue
|
89
|
-
if response.status_code not in (200, 429):
|
90
|
-
print(response.status_code)
|
91
|
-
print(response.text)
|
92
|
-
raise Exception(f"Error listing workspaces: {response.text}")
|
93
|
-
break
|
94
|
-
|
95
|
-
resp_dict = json.loads(response.text)
|
96
|
-
workspaces = resp_dict["value"]
|
97
|
-
|
98
|
-
if workspace_objects:
|
99
|
-
workspaces = [fc.get_workspace_by_id(workspace["id"]) for workspace in workspaces]
|
100
|
-
|
101
|
-
if "continuationToken" in resp_dict:
|
102
|
-
workspaces_next = self.list_domain_workspaces(continuationToken=resp_dict["continuationToken"])
|
103
|
-
workspaces.extend(workspaces_next)
|
104
|
-
|
105
|
-
return workspaces
|
72
|
+
return self.core_client.list_domain_workspaces(self.id, workspace_objects)
|
106
73
|
|
107
74
|
def delete(self):
|
108
75
|
"""Method to delete the domain
|
@@ -110,21 +77,7 @@ class Domain:
|
|
110
77
|
Returns:
|
111
78
|
int: The status code of the response
|
112
79
|
"""
|
113
|
-
|
114
|
-
url = f"https://api.fabric.microsoft.com/v1/admin/domains/{self.id}"
|
115
|
-
for _ in range(10):
|
116
|
-
response = requests.delete(url=url, headers=self.auth.get_headers())
|
117
|
-
if response.status_code == 429:
|
118
|
-
print("Too many requests, waiting 10 seconds")
|
119
|
-
sleep(10)
|
120
|
-
continue
|
121
|
-
if response.status_code not in (200, 429):
|
122
|
-
print(response.status_code)
|
123
|
-
print(response.text)
|
124
|
-
raise Exception(f"Error deleting domain: {response.text}")
|
125
|
-
break
|
126
|
-
|
127
|
-
return response.status_code
|
80
|
+
return self.core_client.delete_domain(self.id)
|
128
81
|
|
129
82
|
|
130
83
|
# PATCH https://api.fabric.microsoft.com/v1/admin/domains/{domainId}
|
@@ -139,38 +92,12 @@ class Domain:
|
|
139
92
|
Returns:
|
140
93
|
Domain: The Domain object created from the dictionary
|
141
94
|
"""
|
142
|
-
url = f"https://api.fabric.microsoft.com/v1/admin/domains/{self.id}"
|
143
|
-
body = {}
|
144
|
-
if description:
|
145
|
-
body["description"] = description
|
146
|
-
else:
|
147
|
-
body["description"] = self.description
|
148
|
-
|
149
|
-
if display_name:
|
150
|
-
body["displayName"] = display_name
|
151
|
-
else:
|
152
|
-
body["displayName"] = self.display_name
|
153
|
-
|
154
|
-
if contributors_scope:
|
155
|
-
body["contributorsScope"] = contributors_scope
|
156
|
-
else:
|
157
|
-
body["contributorsScope"] = self.contributors_scope
|
158
95
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
continue
|
165
|
-
if response.status_code not in (200, 429):
|
166
|
-
print(response.status_code)
|
167
|
-
print(response.text)
|
168
|
-
raise Exception(f"Error updating domain: {response.text}")
|
169
|
-
break
|
170
|
-
|
171
|
-
self.description = body["description"]
|
172
|
-
self.display_name = body["displayName"]
|
173
|
-
self.contributors_scope = body["contributorsScope"]
|
96
|
+
resp_dict = self.core_client.update_domain(self.id, description, display_name, contributors_scope)
|
97
|
+
assert "id" in resp_dict
|
98
|
+
self.description = description
|
99
|
+
self.display_name = display_name
|
100
|
+
self.contributors_scope = contributors_scope
|
174
101
|
|
175
102
|
return self
|
176
103
|
|
@@ -183,27 +110,7 @@ class Domain:
|
|
183
110
|
int: The status code of the response
|
184
111
|
"""
|
185
112
|
# POST https://api.fabric.microsoft.com/v1/admin/domains/{domainId}/assignWorkspacesByCapacities
|
186
|
-
|
187
|
-
|
188
|
-
body = {
|
189
|
-
"capacitiesIds": capacities_ids
|
190
|
-
}
|
191
|
-
|
192
|
-
for _ in range(10):
|
193
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
194
|
-
if response.status_code == 429:
|
195
|
-
print("Too many requests, waiting 10 seconds")
|
196
|
-
sleep(10)
|
197
|
-
continue
|
198
|
-
if response.status_code == 202 and wait_for_completion:
|
199
|
-
check_long_running_operation(response.headers, self.auth)
|
200
|
-
if response.status_code not in (202, 429):
|
201
|
-
print(response.status_code)
|
202
|
-
print(response.text)
|
203
|
-
raise Exception(f"Error assigning workspaces by capacities: {response.text}")
|
204
|
-
break
|
205
|
-
|
206
|
-
return response.status_code
|
113
|
+
return self.core_client.assign_domain_workspaces_by_capacities(self.id, capacities_ids, wait_for_completion)
|
207
114
|
|
208
115
|
|
209
116
|
def assign_workspaces_by_ids(self, workspaces_ids):
|
@@ -215,24 +122,7 @@ class Domain:
|
|
215
122
|
Returns:
|
216
123
|
int: The status code of the response
|
217
124
|
"""
|
218
|
-
|
219
|
-
body = {
|
220
|
-
"workspacesIds": workspaces_ids
|
221
|
-
}
|
222
|
-
|
223
|
-
for _ in range(10):
|
224
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
225
|
-
if response.status_code == 429:
|
226
|
-
print("Too many requests, waiting 10 seconds")
|
227
|
-
sleep(10)
|
228
|
-
continue
|
229
|
-
if response.status_code not in (200, 429):
|
230
|
-
print(response.status_code)
|
231
|
-
print(response.text)
|
232
|
-
raise Exception(f"Error assigning workspaces by ids: {response.text}")
|
233
|
-
break
|
234
|
-
|
235
|
-
return response.status_code
|
125
|
+
return self.core_client.assign_domain_workspaces_by_ids(self.id, workspaces_ids)
|
236
126
|
|
237
127
|
|
238
128
|
def assign_workspaces_by_principals(self, principals, wait_for_completion=True):
|
@@ -243,29 +133,8 @@ class Domain:
|
|
243
133
|
Returns:
|
244
134
|
int: The status code of the response
|
245
135
|
"""
|
246
|
-
|
247
|
-
body = {
|
248
|
-
"principals": principals
|
249
|
-
}
|
250
|
-
|
251
|
-
for _ in range(10):
|
252
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
253
|
-
if response.status_code == 429:
|
254
|
-
print("Too many requests, waiting 10 seconds")
|
255
|
-
sleep(10)
|
256
|
-
continue
|
257
|
-
if response.status_code == 202 and wait_for_completion:
|
258
|
-
check_long_running_operation(response.headers, self.auth)
|
259
|
-
if response.status_code not in (202, 429):
|
260
|
-
print(response.status_code)
|
261
|
-
print(response.text)
|
262
|
-
raise Exception(f"Error assigning workspaces by principals: {response.text}")
|
263
|
-
break
|
264
|
-
|
265
|
-
return response.status_code
|
136
|
+
return self.core_client.assign_domains_workspaces_by_principals(self.id, principals, wait_for_completion)
|
266
137
|
|
267
|
-
# POST https://api.fabric.microsoft.com/v1/admin/domains/{domainId}/roleAssignments/bulkAssign
|
268
|
-
|
269
138
|
def role_assignments_bulk_assign(self, type, principals):
|
270
139
|
"""Method to bulk assign role assignments
|
271
140
|
|
@@ -275,26 +144,7 @@ class Domain:
|
|
275
144
|
Returns:
|
276
145
|
int: The status code of the response
|
277
146
|
"""
|
278
|
-
|
279
|
-
url = f"https://api.fabric.microsoft.com/v1/admin/domains/{self.id}/roleAssignments/bulkAssign"
|
280
|
-
body = {
|
281
|
-
"type": type,
|
282
|
-
"principals": principals
|
283
|
-
}
|
284
|
-
|
285
|
-
for _ in range(10):
|
286
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
287
|
-
if response.status_code == 429:
|
288
|
-
print("Too many requests, waiting 10 seconds")
|
289
|
-
sleep(10)
|
290
|
-
continue
|
291
|
-
if response.status_code not in (200, 429):
|
292
|
-
print(response.status_code)
|
293
|
-
print(response.text)
|
294
|
-
raise Exception(f"Error bulk assigning role assignments: {response.text}")
|
295
|
-
break
|
296
|
-
|
297
|
-
return response.status_code
|
147
|
+
return self.core_client.role_assignments_bulk_assign(self.id, type, principals)
|
298
148
|
|
299
149
|
|
300
150
|
def role_assignments_bulk_unassign(self, type, principals):
|
@@ -307,25 +157,7 @@ class Domain:
|
|
307
157
|
int: The status code of the response
|
308
158
|
"""
|
309
159
|
|
310
|
-
|
311
|
-
body = {
|
312
|
-
"type": type,
|
313
|
-
"principals": principals
|
314
|
-
}
|
315
|
-
|
316
|
-
for _ in range(10):
|
317
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
318
|
-
if response.status_code == 429:
|
319
|
-
print("Too many requests, waiting 10 seconds")
|
320
|
-
sleep(10)
|
321
|
-
continue
|
322
|
-
if response.status_code not in (200, 429):
|
323
|
-
print(response.status_code)
|
324
|
-
print(response.text)
|
325
|
-
raise Exception(f"Error bulk unassigning role assignments: {response.text}")
|
326
|
-
break
|
327
|
-
|
328
|
-
return response.status_code
|
160
|
+
return self.core_client.role_assignments_bulk_unassign(self.id, type, principals)
|
329
161
|
|
330
162
|
|
331
163
|
def unassign_all_workspaces(self):
|
@@ -334,21 +166,7 @@ class Domain:
|
|
334
166
|
Returns:
|
335
167
|
int: The status code of the response
|
336
168
|
"""
|
337
|
-
|
338
|
-
|
339
|
-
for _ in range(10):
|
340
|
-
response = requests.post(url=url, headers=self.auth.get_headers())
|
341
|
-
if response.status_code == 429:
|
342
|
-
print("Too many requests, waiting 10 seconds")
|
343
|
-
sleep(10)
|
344
|
-
continue
|
345
|
-
if response.status_code not in (200, 429):
|
346
|
-
print(response.status_code)
|
347
|
-
print(response.text)
|
348
|
-
raise Exception(f"Error unassigning all workspaces: {response.text}")
|
349
|
-
break
|
350
|
-
|
351
|
-
return response.status_code
|
169
|
+
return self.core_client.unassign_all_domain_workspaces(self.id)
|
352
170
|
|
353
171
|
def unassign_workspaces_by_ids(self, workspace_ids):
|
354
172
|
"""Method to unassign workspaces from the domain
|
@@ -358,21 +176,4 @@ class Domain:
|
|
358
176
|
Returns:
|
359
177
|
int: The status code of the response
|
360
178
|
"""
|
361
|
-
|
362
|
-
body = {
|
363
|
-
"workspacesIds": workspace_ids
|
364
|
-
}
|
365
|
-
|
366
|
-
for _ in range(10):
|
367
|
-
response = requests.post(url=url, headers=self.auth.get_headers(), json=body)
|
368
|
-
if response.status_code == 429:
|
369
|
-
print("Too many requests, waiting 10 seconds")
|
370
|
-
sleep(10)
|
371
|
-
continue
|
372
|
-
if response.status_code not in (200, 429):
|
373
|
-
print(response.status_code)
|
374
|
-
print(response.text)
|
375
|
-
raise Exception(f"Error unassigning workspaces by ids: {response.text}")
|
376
|
-
break
|
377
|
-
|
378
|
-
return response.status_code
|
179
|
+
return self.core_client.unassign_domain_workspaces_by_ids(self.id, workspace_ids)
|