msfabricpysdkcore 0.2.8__py3-none-any.whl → 0.2.10__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.
@@ -67,7 +67,7 @@ class FabricClientAdmin(FabricClient):
67
67
 
68
68
  return response.status_code
69
69
 
70
- def create_domain(self, display_name, description = None, parent_domain_id = None):
70
+ def create_domain(self, display_name, description = None, parent_domain_id = None, preview="false"):
71
71
  """Method to create a domain
72
72
 
73
73
  Args:
@@ -79,7 +79,7 @@ class FabricClientAdmin(FabricClient):
79
79
  """
80
80
  from msfabricpysdkcore.domain import Domain
81
81
 
82
- url = "https://api.fabric.microsoft.com/v1/admin/domains"
82
+ url = f"https://api.fabric.microsoft.com/v1/admin/domains?preview={preview}"
83
83
  body = {
84
84
  "displayName": display_name
85
85
  }
@@ -110,8 +110,8 @@ class FabricClientAdmin(FabricClient):
110
110
  return_format="response")
111
111
 
112
112
  return response.status_code
113
-
114
- def get_domain_by_id(self, domain_id):
113
+
114
+ def get_domain_by_id(self, domain_id, preview="false"):
115
115
  """Method to get a domain by ID
116
116
 
117
117
  Args:
@@ -121,14 +121,14 @@ class FabricClientAdmin(FabricClient):
121
121
  """
122
122
  from msfabricpysdkcore.domain import Domain
123
123
 
124
- url = f"https://api.fabric.microsoft.com/v1/admin/domains/{domain_id}"
124
+ url = f"https://api.fabric.microsoft.com/v1/admin/domains/{domain_id}?preview={preview}"
125
125
 
126
126
  domain_dict = self.calling_routine(url = url, operation = "GET", response_codes = [200, 429], error_message = "Error getting domain",
127
127
  return_format="json")
128
128
  domain = Domain.from_dict(domain_dict, self)
129
129
  return domain
130
130
 
131
- def get_domain_by_name(self, domain_name):
131
+ def get_domain_by_name(self, domain_name, preview="false"):
132
132
  """Method to get a domain by name
133
133
 
134
134
  Args:
@@ -139,10 +139,10 @@ class FabricClientAdmin(FabricClient):
139
139
  domains = self.list_domains()
140
140
  domains = [domain for domain in domains if domain.display_name == domain_name]
141
141
  if len(domains) > 0:
142
- return self.get_domain_by_id(domains[0].id)
142
+ return self.get_domain_by_id(domains[0].id, preview=preview)
143
143
  raise ValueError("Domain not found")
144
144
 
145
- def get_domain(self, domain_id = None, domain_name = None):
145
+ def get_domain(self, domain_id = None, domain_name = None, preview="false"):
146
146
  """Get a domain by ID or name
147
147
 
148
148
  Args:
@@ -152,9 +152,9 @@ class FabricClientAdmin(FabricClient):
152
152
  Domain: The Domain object
153
153
  """
154
154
  if domain_id:
155
- return self.get_domain_by_id(domain_id)
155
+ return self.get_domain_by_id(domain_id, preview=preview)
156
156
  if domain_name:
157
- return self.get_domain_by_name(domain_name)
157
+ return self.get_domain_by_name(domain_name, preview=preview)
158
158
  raise ValueError("Either domain_id or domain_name must be provided")
159
159
 
160
160
  def list_domain_workspaces(self, domain_id, workspace_objects = False):
@@ -179,7 +179,7 @@ class FabricClientAdmin(FabricClient):
179
179
 
180
180
  return workspaces
181
181
 
182
- def list_domains(self, nonEmptyOnly=False):
182
+ def list_domains(self, nonEmptyOnly=False, preview="false"):
183
183
  """List all domains in the tenant
184
184
 
185
185
  Args:
@@ -188,7 +188,7 @@ class FabricClientAdmin(FabricClient):
188
188
  list: List of Domain objects"""
189
189
  from msfabricpysdkcore.domain import Domain
190
190
 
191
- url = "https://api.fabric.microsoft.com/v1/admin/domains"
191
+ url = f"https://api.fabric.microsoft.com/v1/admin/domains?preview={preview}"
192
192
  if nonEmptyOnly:
193
193
  url = f"{url}?nonEmptyOnly=True"
194
194
 
@@ -198,6 +198,23 @@ class FabricClientAdmin(FabricClient):
198
198
 
199
199
  domains = [Domain.from_dict(i, self) for i in domains]
200
200
  return domains
201
+
202
+ # GET https://api.fabric.microsoft.com/v1/admin/domains/{domainId}/roleAssignments?continuationToken={continuationToken}
203
+ def list_role_assignments(self, domain_id):
204
+ """List role assignments in a domain
205
+
206
+ Args:
207
+ domain_id (str): The ID of the domain
208
+ Returns:
209
+ list: The list of role assignments
210
+ """
211
+ url = f"https://api.fabric.microsoft.com/v1/admin/domains/{domain_id}/roleAssignments"
212
+
213
+ items: list = self.calling_routine(url = url, operation = "GET", response_codes = [200, 429],
214
+ error_message = "Error listing role assignments",
215
+ return_format="value_json", paging=True)
216
+
217
+ return items
201
218
 
202
219
  def role_assignments_bulk_assign(self, domain_id, type, principals):
203
220
  """Assign a role to principals in bulk
@@ -243,6 +260,27 @@ class FabricClientAdmin(FabricClient):
243
260
  return_format="response")
244
261
 
245
262
  return response.status_code
263
+
264
+ # POST https://api.fabric.microsoft.com/v1/admin/domains/{domainId}/roleAssignments/syncToSubdomains
265
+ def sync_role_assignments_to_subdomains(self, domain_id, role):
266
+ """Sync role assignments to subdomains
267
+
268
+ Args:
269
+ domain_id (str): The ID of the domain
270
+ role (str): The role to sync
271
+ Returns:
272
+ int: The status code of the response
273
+ """
274
+ url = f"https://api.fabric.microsoft.com/v1/admin/domains/{domain_id}/roleAssignments/syncToSubdomains"
275
+ body = {
276
+ "role": role
277
+ }
278
+
279
+ response:requests.Response = self.calling_routine(url = url, operation = "POST", body = body, response_codes = [200, 429],
280
+ error_message = "Error syncing role assignments to subdomains",
281
+ return_format="response")
282
+
283
+ return response.status_code
246
284
 
247
285
  def unassign_all_domain_workspaces(self, domain_id):
248
286
  """Unassign all workspaces from a domain
@@ -279,7 +317,7 @@ class FabricClientAdmin(FabricClient):
279
317
 
280
318
  return response.status_code
281
319
 
282
- def update_domain(self, domain_id, description = None, display_name = None, contributors_scope = None, return_item = False):
320
+ def update_domain(self, domain_id, description = None, display_name = None, contributors_scope = None, return_item = False, preview="false"):
283
321
  """Method to update a domain
284
322
 
285
323
  Args:
@@ -287,7 +325,7 @@ class FabricClientAdmin(FabricClient):
287
325
  Returns:
288
326
  Domain: The Domain object
289
327
  """
290
- url = f"https://api.fabric.microsoft.com/v1/admin/domains/{domain_id}"
328
+ url = f"https://api.fabric.microsoft.com/v1/admin/domains/{domain_id}?preview={preview}"
291
329
  body = {}
292
330
  if description:
293
331
  body["description"] = description
@@ -118,6 +118,8 @@ class FabricClient():
118
118
  if wait_for_completion:
119
119
  operation_result = self.long_running_operation(response.headers)
120
120
  if "operation_result" in return_format:
121
+ if ("value_json" in return_format and isinstance(operation_result, dict) and "value" in operation_result):
122
+ return operation_result["value"]
121
123
  return operation_result
122
124
  return response
123
125
  elif response.status_code not in response_codes: