semantic-link-labs 0.9.0__py3-none-any.whl → 0.9.2__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.

Potentially problematic release.


This version of semantic-link-labs might be problematic. Click here for more details.

Files changed (83) hide show
  1. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/METADATA +68 -7
  2. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/RECORD +83 -76
  3. sempy_labs/__init__.py +14 -12
  4. sempy_labs/_authentication.py +0 -2
  5. sempy_labs/_capacities.py +120 -142
  6. sempy_labs/_capacity_migration.py +61 -94
  7. sempy_labs/_clear_cache.py +9 -8
  8. sempy_labs/_connections.py +72 -105
  9. sempy_labs/_data_pipelines.py +47 -49
  10. sempy_labs/_dataflows.py +45 -51
  11. sempy_labs/_dax.py +228 -6
  12. sempy_labs/_delta_analyzer.py +303 -0
  13. sempy_labs/_deployment_pipelines.py +72 -66
  14. sempy_labs/_environments.py +39 -36
  15. sempy_labs/_eventhouses.py +35 -35
  16. sempy_labs/_eventstreams.py +38 -39
  17. sempy_labs/_external_data_shares.py +29 -42
  18. sempy_labs/_gateways.py +57 -101
  19. sempy_labs/_generate_semantic_model.py +22 -30
  20. sempy_labs/_git.py +46 -66
  21. sempy_labs/_graphQL.py +95 -0
  22. sempy_labs/_helper_functions.py +175 -30
  23. sempy_labs/_job_scheduler.py +47 -59
  24. sempy_labs/_kql_databases.py +27 -34
  25. sempy_labs/_kql_querysets.py +23 -30
  26. sempy_labs/_list_functions.py +262 -164
  27. sempy_labs/_managed_private_endpoints.py +52 -47
  28. sempy_labs/_mirrored_databases.py +110 -134
  29. sempy_labs/_mirrored_warehouses.py +13 -13
  30. sempy_labs/_ml_experiments.py +36 -36
  31. sempy_labs/_ml_models.py +37 -38
  32. sempy_labs/_model_dependencies.py +2 -0
  33. sempy_labs/_notebooks.py +28 -29
  34. sempy_labs/_one_lake_integration.py +2 -0
  35. sempy_labs/_query_scale_out.py +63 -81
  36. sempy_labs/_refresh_semantic_model.py +12 -14
  37. sempy_labs/_spark.py +54 -79
  38. sempy_labs/_sql.py +7 -11
  39. sempy_labs/_vertipaq.py +8 -3
  40. sempy_labs/_warehouses.py +30 -33
  41. sempy_labs/_workloads.py +15 -20
  42. sempy_labs/_workspace_identity.py +13 -17
  43. sempy_labs/_workspaces.py +49 -48
  44. sempy_labs/admin/__init__.py +2 -0
  45. sempy_labs/admin/_basic_functions.py +244 -281
  46. sempy_labs/admin/_domains.py +188 -103
  47. sempy_labs/admin/_external_data_share.py +26 -31
  48. sempy_labs/admin/_git.py +17 -22
  49. sempy_labs/admin/_items.py +34 -48
  50. sempy_labs/admin/_scanner.py +20 -13
  51. sempy_labs/directlake/_directlake_schema_compare.py +2 -0
  52. sempy_labs/directlake/_dl_helper.py +10 -11
  53. sempy_labs/directlake/_generate_shared_expression.py +4 -5
  54. sempy_labs/directlake/_get_directlake_lakehouse.py +1 -0
  55. sempy_labs/directlake/_list_directlake_model_calc_tables.py +1 -0
  56. sempy_labs/directlake/_show_unsupported_directlake_objects.py +2 -0
  57. sempy_labs/directlake/_warm_cache.py +2 -0
  58. sempy_labs/graph/__init__.py +33 -0
  59. sempy_labs/graph/_groups.py +402 -0
  60. sempy_labs/graph/_teams.py +113 -0
  61. sempy_labs/graph/_users.py +191 -0
  62. sempy_labs/lakehouse/__init__.py +4 -0
  63. sempy_labs/lakehouse/_get_lakehouse_columns.py +10 -10
  64. sempy_labs/lakehouse/_get_lakehouse_tables.py +14 -20
  65. sempy_labs/lakehouse/_lakehouse.py +101 -4
  66. sempy_labs/lakehouse/_shortcuts.py +42 -20
  67. sempy_labs/migration/__init__.py +4 -0
  68. sempy_labs/migration/_direct_lake_to_import.py +66 -0
  69. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +1 -0
  70. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +1 -0
  71. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +1 -0
  72. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +2 -0
  73. sempy_labs/report/_download_report.py +8 -13
  74. sempy_labs/report/_generate_report.py +49 -46
  75. sempy_labs/report/_paginated.py +20 -26
  76. sempy_labs/report/_report_functions.py +50 -45
  77. sempy_labs/report/_report_list_functions.py +2 -0
  78. sempy_labs/report/_report_rebind.py +6 -10
  79. sempy_labs/report/_reportwrapper.py +187 -220
  80. sempy_labs/tom/_model.py +8 -5
  81. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/LICENSE +0 -0
  82. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/WHEEL +0 -0
  83. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/top_level.txt +0 -0
@@ -1,37 +1,85 @@
1
- import sempy.fabric as fabric
2
1
  from typing import Optional, List
3
2
  import sempy_labs._icons as icons
4
- from sempy_labs._helper_functions import lro
5
- from sempy.fabric.exceptions import FabricHTTPException
6
3
  import pandas as pd
7
4
  from uuid import UUID
8
5
  from sempy_labs.admin._basic_functions import list_workspaces
9
- import sempy_labs._authentication as auth
6
+ from sempy_labs._helper_functions import (
7
+ _base_api,
8
+ _create_dataframe,
9
+ _is_valid_uuid,
10
+ )
10
11
 
11
12
 
12
- def resolve_domain_id(domain_name: str) -> UUID:
13
+ def resolve_domain_id(domain: Optional[str | UUID] = None, **kwargs) -> UUID:
13
14
  """
14
15
  Obtains the domain Id for a given domain name.
15
16
 
16
17
  Parameters
17
18
  ----------
18
- domain_name : str
19
- The domain name
19
+ domain_name : str | uuid.UUID
20
+ The domain name or ID
20
21
 
21
22
  Returns
22
23
  -------
23
- UUID
24
+ uuid.UUID
24
25
  The domain Id.
25
26
  """
26
27
 
28
+ if "domain_name" in kwargs:
29
+ domain = kwargs["domain_name"]
30
+ print(
31
+ f"{icons.warning} The 'domain_name' parameter is deprecated. Please use 'domain' instead."
32
+ )
33
+
34
+ if domain is None:
35
+ raise ValueError(f"{icons.red_dot} Please provide a domain.")
36
+
37
+ if _is_valid_uuid(domain):
38
+ return domain
39
+
27
40
  dfL = list_domains()
28
- dfL_filt = dfL[dfL["Domain Name"] == domain_name]
29
- if len(dfL_filt) == 0:
30
- raise ValueError(f"{icons.red_dot} '{domain_name}' is not a valid domain name.")
41
+ dfL_filt = dfL[dfL["Domain Name"] == domain]
42
+ if dfL_filt.empty:
43
+ raise ValueError(f"{icons.red_dot} '{domain}' is not a valid domain name.")
31
44
 
32
45
  return dfL_filt["Domain ID"].iloc[0]
33
46
 
34
47
 
48
+ def resolve_domain_name(domain: Optional[str | UUID], **kwargs) -> UUID:
49
+ """
50
+ Obtains the domain name for a given domain ID.
51
+
52
+ Parameters
53
+ ----------
54
+ domain : str | uuid.UUID
55
+ The domain name or ID
56
+
57
+ Returns
58
+ -------
59
+ str
60
+ The domain Name.
61
+ """
62
+
63
+ if "domain_name" in kwargs:
64
+ domain = kwargs["domain_name"]
65
+ print(
66
+ f"{icons.warning} The 'domain_name' parameter is deprecated. Please use 'domain' instead."
67
+ )
68
+
69
+ if domain is None:
70
+ raise ValueError(f"{icons.red_dot} Please provide a domain.")
71
+
72
+ if not _is_valid_uuid(domain):
73
+ return domain
74
+
75
+ dfL = list_domains()
76
+ dfL_filt = dfL[dfL["Domain ID"] == domain]
77
+ if dfL_filt.empty:
78
+ raise ValueError(f"{icons.red_dot} '{domain}' is not a valid domain name.")
79
+
80
+ return dfL_filt["Domain Name"].iloc[0]
81
+
82
+
35
83
  def list_domains(non_empty_only: bool = False) -> pd.DataFrame:
36
84
  """
37
85
  Shows a list of domains.
@@ -52,24 +100,20 @@ def list_domains(non_empty_only: bool = False) -> pd.DataFrame:
52
100
  A pandas dataframe showing a list of the domains.
53
101
  """
54
102
 
55
- df = pd.DataFrame(
56
- columns=[
57
- "Domain ID",
58
- "Domain Name",
59
- "Description",
60
- "Parent Domain ID",
61
- "Contributors Scope",
62
- ]
63
- )
103
+ columns = {
104
+ "Domain ID": "string",
105
+ "Domain Name": "string",
106
+ "Description": "string",
107
+ "Parent Domain ID": "string",
108
+ "Contributors Scope": "string",
109
+ }
110
+ df = _create_dataframe(columns=columns)
64
111
 
65
- client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
66
112
  url = "/v1/admin/domains"
67
113
  if non_empty_only:
68
114
  url = f"{url}?nonEmptyOnly=True"
69
- response = client.get(url)
70
115
 
71
- if response.status_code != 200:
72
- raise FabricHTTPException(response)
116
+ response = _base_api(request=url, client="fabric_sp")
73
117
 
74
118
  for v in response.json().get("domains", []):
75
119
  new_data = {
@@ -84,7 +128,7 @@ def list_domains(non_empty_only: bool = False) -> pd.DataFrame:
84
128
  return df
85
129
 
86
130
 
87
- def list_domain_workspaces(domain_name: str) -> pd.DataFrame:
131
+ def list_domain_workspaces(domain: Optional[str] = None, **kwargs) -> pd.DataFrame:
88
132
  """
89
133
  Shows a list of workspaces within the domain.
90
134
 
@@ -94,8 +138,8 @@ def list_domain_workspaces(domain_name: str) -> pd.DataFrame:
94
138
 
95
139
  Parameters
96
140
  ----------
97
- domain_name : str
98
- The domain name.
141
+ domain : str | uuid.UUID
142
+ The domain name or ID.
99
143
 
100
144
  Returns
101
145
  -------
@@ -103,15 +147,26 @@ def list_domain_workspaces(domain_name: str) -> pd.DataFrame:
103
147
  A pandas dataframe showing a list of workspaces within the domain.
104
148
  """
105
149
 
106
- domain_id = resolve_domain_id(domain_name)
150
+ if "domain_name" in kwargs:
151
+ domain = kwargs["domain_name"]
152
+ print(
153
+ f"{icons.warning} The 'domain_name' parameter is deprecated. Please use 'domain' instead."
154
+ )
155
+
156
+ if domain is None:
157
+ raise ValueError(f"{icons.red_dot} Please provide a domain.")
107
158
 
108
- df = pd.DataFrame(columns=["Workspace ID", "Workspace Name"])
159
+ domain_id = resolve_domain_id(domain)
109
160
 
110
- client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
111
- response = client.get(f"/v1/admin/domains/{domain_id}/workspaces")
161
+ columns = {
162
+ "Workspace ID": "string",
163
+ "Workspace Name": "string",
164
+ }
165
+ df = _create_dataframe(columns=columns)
112
166
 
113
- if response.status_code != 200:
114
- raise FabricHTTPException(response)
167
+ response = _base_api(
168
+ request=f"/v1/admin/domains/{domain_id}/workspaces", client="fabric_sp"
169
+ )
115
170
 
116
171
  for v in response.json().get("value", []):
117
172
  new_data = {
@@ -126,7 +181,8 @@ def list_domain_workspaces(domain_name: str) -> pd.DataFrame:
126
181
  def create_domain(
127
182
  domain_name: str,
128
183
  description: Optional[str] = None,
129
- parent_domain_name: Optional[str] = None,
184
+ parent_domain: Optional[str | UUID] = None,
185
+ **kwargs,
130
186
  ):
131
187
  """
132
188
  Creates a new domain.
@@ -139,30 +195,34 @@ def create_domain(
139
195
  The domain name.
140
196
  description : str, default=None
141
197
  The domain description.
142
- parent_domain_name : str, default=None
143
- The parent domain name.
198
+ parent_domain : str | uuid.UUID, default=None
199
+ The parent domain name or ID.
144
200
  """
145
201
 
146
- if parent_domain_name is not None:
147
- parent_domain_id = resolve_domain_id(parent_domain_name)
202
+ if "parent_domain_name" in kwargs:
203
+ parent_domain = kwargs["parent_domain_name"]
204
+ print(
205
+ f"{icons.warning} The 'parent_domain_name' parameter is deprecated. Please use 'parent_domain' instead."
206
+ )
207
+
208
+ if parent_domain is not None:
209
+ parent_domain_id = resolve_domain_id(domain=parent_domain)
148
210
 
149
211
  payload = {}
150
212
  payload["displayName"] = domain_name
151
213
  if description is not None:
152
214
  payload["description"] = description
153
- if parent_domain_name is not None:
215
+ if parent_domain is not None:
154
216
  payload["parentDomainId"] = parent_domain_id
155
217
 
156
- client = fabric.FabricRestClient()
157
- response = client.post("/v1/admin/domains", json=payload)
158
-
159
- if response.status_code != 201:
160
- raise FabricHTTPException(response)
218
+ _base_api(
219
+ request="/v1/admin/domains", method="post", payload=payload, status_codes=201
220
+ )
161
221
 
162
222
  print(f"{icons.green_dot} The '{domain_name}' domain has been created.")
163
223
 
164
224
 
165
- def delete_domain(domain_name: str):
225
+ def delete_domain(domain: Optional[str | UUID], **kwargs):
166
226
  """
167
227
  Deletes a domain.
168
228
 
@@ -170,25 +230,30 @@ def delete_domain(domain_name: str):
170
230
 
171
231
  Parameters
172
232
  ----------
173
- domain_name : str
174
- The domain name.
233
+ domain : str | uuid.UUID
234
+ The domain name or ID.
175
235
  """
176
236
 
177
- domain_id = resolve_domain_id(domain_name)
237
+ if "domain_name" in kwargs:
238
+ domain = kwargs["domain_name"]
239
+ print(
240
+ f"{icons.warning} The 'domain_name' parameter is deprecated. Please use 'domain' instead."
241
+ )
178
242
 
179
- client = fabric.FabricRestClient()
180
- response = client.delete(f"/v1/admin/domains/{domain_id}")
243
+ if domain is None:
244
+ raise ValueError(f"{icons.red_dot} Please provide a domain.")
181
245
 
182
- if response.status_code != 200:
183
- raise FabricHTTPException(response)
246
+ domain_id = resolve_domain_id(domain)
247
+ _base_api(request=f"/v1/admin/domains/{domain_id}", method="delete")
184
248
 
185
- print(f"{icons.green_dot} The '{domain_name}' domain has been deleted.")
249
+ print(f"{icons.green_dot} The '{domain}' domain has been deleted.")
186
250
 
187
251
 
188
252
  def update_domain(
189
- domain_name: str,
253
+ domain: Optional[str | UUID] = None,
190
254
  description: Optional[str] = None,
191
255
  contributors_scope: Optional[str] = None,
256
+ **kwargs,
192
257
  ):
193
258
  """
194
259
  Updates a domain's properties.
@@ -197,14 +262,22 @@ def update_domain(
197
262
 
198
263
  Parameters
199
264
  ----------
200
- domain_name : str
201
- The domain name.
265
+ domain : str | uuid.UUID
266
+ The domain name or ID.
202
267
  description : str, default=None
203
268
  The domain description.
204
269
  contributors_scope : str, default=None
205
270
  The domain `contributor scope <https://learn.microsoft.com/rest/api/fabric/admin/domains/update-domain?tabs=HTTP#contributorsscopetype>`_.
206
271
  """
207
272
 
273
+ if "domain_name" in kwargs:
274
+ domain = kwargs["domain_name"]
275
+ print(
276
+ f"{icons.warning} The 'domain_name' parameter is deprecated. Please use 'domain' instead."
277
+ )
278
+
279
+ if domain is None:
280
+ raise ValueError(f"{icons.red_dot} Please provide a domain.")
208
281
  contributors_scopes = ["AdminsOnly", "AllTenant", "SpecificUsersAndGroups"]
209
282
 
210
283
  if contributors_scope not in contributors_scopes:
@@ -212,7 +285,8 @@ def update_domain(
212
285
  f"{icons.red_dot} Invalid contributors scope. Valid options: {contributors_scopes}."
213
286
  )
214
287
 
215
- domain_id = resolve_domain_id(domain_name)
288
+ domain_id = resolve_domain_id(domain)
289
+ domain_name = resolve_domain_name(domain)
216
290
 
217
291
  payload = {}
218
292
  payload["displayName"] = domain_name
@@ -222,17 +296,15 @@ def update_domain(
222
296
  if contributors_scope is not None:
223
297
  payload["contributorsScope"] = contributors_scope
224
298
 
225
- client = fabric.FabricRestClient()
226
- response = client.patch(f"/v1/admin/domains/{domain_id}", json=payload)
227
-
228
- if response != 200:
229
- raise FabricHTTPException(response)
299
+ _base_api(request=f"/v1/admin/domains/{domain_id}", method="patch", payload=payload)
230
300
 
231
301
  print(f"{icons.green_dot} The '{domain_name}' domain has been updated.")
232
302
 
233
303
 
234
304
  def assign_domain_workspaces_by_capacities(
235
- domain_name: str, capacity_names: str | List[str]
305
+ domain: str | UUID,
306
+ capacity_names: str | List[str],
307
+ **kwargs,
236
308
  ):
237
309
  """
238
310
  Assigns all workspaces that reside on the specified capacities to the specified domain.
@@ -241,15 +313,23 @@ def assign_domain_workspaces_by_capacities(
241
313
 
242
314
  Parameters
243
315
  ----------
244
- domain_name : str
245
- The domain name.
316
+ domain : str | uuid.UUID
317
+ The domain name or ID.
246
318
  capacity_names : str | List[str]
247
319
  The capacity names.
248
320
  """
249
321
 
250
322
  from sempy_labs.admin import list_capacities
251
323
 
252
- domain_id = resolve_domain_id(domain_name)
324
+ if "domain_name" in kwargs:
325
+ domain = kwargs["domain_name"]
326
+ print(
327
+ f"{icons.warning} The 'domain_name' parameter is deprecated. Please use 'domain' instead."
328
+ )
329
+
330
+ if domain is None:
331
+ raise ValueError(f"{icons.red_dot} Please provide a domain.")
332
+ domain_id = resolve_domain_id(domain)
253
333
 
254
334
  if isinstance(capacity_names, str):
255
335
  capacity_names = [capacity_names]
@@ -276,20 +356,20 @@ def assign_domain_workspaces_by_capacities(
276
356
 
277
357
  payload = {"capacitiesIds": capacity_list}
278
358
 
279
- client = fabric.FabricRestClient()
280
- response = client.post(
281
- f"/v1/admin/domains/{domain_id}/assignWorkspacesByCapacities",
282
- json=payload,
359
+ _base_api(
360
+ request=f"/v1/admin/domains/{domain_id}/assignWorkspacesByCapacities",
361
+ method="post",
362
+ payload=payload,
363
+ lro_return_status_code=True,
364
+ status_codes=202,
283
365
  )
284
366
 
285
- lro(client, response)
286
-
287
367
  print(
288
- f"{icons.green_dot} The workspaces in the {capacity_names} capacities have been assigned to the '{domain_name}' domain."
368
+ f"{icons.green_dot} The workspaces in the {capacity_names} capacities have been assigned to the '{domain}' domain."
289
369
  )
290
370
 
291
371
 
292
- def assign_domain_workspaces(domain_name: str, workspace_names: str | List[str]):
372
+ def assign_domain_workspaces(domain: str | UUID, workspace_names: str | List[str]):
293
373
  """
294
374
  Assigns workspaces to the specified domain by workspace.
295
375
 
@@ -297,13 +377,13 @@ def assign_domain_workspaces(domain_name: str, workspace_names: str | List[str])
297
377
 
298
378
  Parameters
299
379
  ----------
300
- domain_name : str
301
- The domain name.
380
+ domain : str | uuid.UUID
381
+ The domain name or ID.
302
382
  workspace_names : str | List[str]
303
383
  The Fabric workspace(s).
304
384
  """
305
385
 
306
- domain_id = resolve_domain_id(domain_name=domain_name)
386
+ domain_id = resolve_domain_id(domain)
307
387
 
308
388
  if isinstance(workspace_names, str):
309
389
  workspace_names = [workspace_names]
@@ -329,20 +409,20 @@ def assign_domain_workspaces(domain_name: str, workspace_names: str | List[str])
329
409
 
330
410
  payload = {"workspacesIds": workspace_list}
331
411
 
332
- client = fabric.FabricRestClient()
333
- response = client.post(
334
- f"/v1/admin/domains/{domain_id}/assignWorkspaces",
335
- json=payload,
412
+ _base_api(
413
+ request=f"/v1/admin/domains/{domain_id}/assignWorkspaces",
414
+ method="post",
415
+ payload=payload,
416
+ lro_return_status_code=True,
417
+ status_codes=200,
336
418
  )
337
419
 
338
- lro(client, response)
339
-
340
420
  print(
341
- f"{icons.green_dot} The {workspace_names} workspaces have been assigned to the '{domain_name}' domain."
421
+ f"{icons.green_dot} The {workspace_names} workspaces have been assigned to the '{domain}' domain."
342
422
  )
343
423
 
344
424
 
345
- def unassign_all_domain_workspaces(domain_name: str):
425
+ def unassign_all_domain_workspaces(domain: str | UUID):
346
426
  """
347
427
  Unassigns all workspaces from the specified domain.
348
428
 
@@ -350,23 +430,28 @@ def unassign_all_domain_workspaces(domain_name: str):
350
430
 
351
431
  Parameters
352
432
  ----------
353
- domain_name : str
354
- The domain name.
433
+ domain : str | uuid.UUID
434
+ The domain name or ID.
355
435
  """
356
436
 
357
- domain_id = resolve_domain_id(domain_name=domain_name)
437
+ domain_id = resolve_domain_id(domain)
358
438
 
359
- client = fabric.FabricRestClient()
360
- response = client.post(f"/v1/admin/domains/{domain_id}/unassignAllWorkspaces")
439
+ _base_api(
440
+ request=f"/v1/admin/domains/{domain_id}/unassignAllWorkspaces",
441
+ method="post",
442
+ lro_return_status_code=True,
443
+ status_codes=200,
444
+ )
361
445
 
362
- if response.status_code != 200:
363
- raise FabricHTTPException(response)
364
446
  print(
365
- f"{icons.green_dot} All workspaces assigned to the '{domain_name}' domain have been unassigned."
447
+ f"{icons.green_dot} All workspaces assigned to the '{domain}' domain have been unassigned."
366
448
  )
367
449
 
368
450
 
369
- def unassign_domain_workspaces(domain_name: str, workspace_names: str | List[str]):
451
+ def unassign_domain_workspaces(
452
+ domain: str | UUID,
453
+ workspace_names: str | List[str],
454
+ ):
370
455
  """
371
456
  Unassigns workspaces from the specified domain by workspace.
372
457
 
@@ -374,13 +459,13 @@ def unassign_domain_workspaces(domain_name: str, workspace_names: str | List[str
374
459
 
375
460
  Parameters
376
461
  ----------
377
- domain_name : str
378
- The domain name.
462
+ domain : str | uuid.UUID
463
+ The domain name or ID.
379
464
  workspace_names : str | List[str]
380
465
  The Fabric workspace(s).
381
466
  """
382
467
 
383
- domain_id = resolve_domain_id(domain_name=domain_name)
468
+ domain_id = resolve_domain_id(domain)
384
469
 
385
470
  if isinstance(workspace_names, str):
386
471
  workspace_names = [workspace_names]
@@ -405,13 +490,13 @@ def unassign_domain_workspaces(domain_name: str, workspace_names: str | List[str
405
490
  workspace_list = list(dfW_filt["Id"])
406
491
 
407
492
  payload = {"workspacesIds": workspace_list}
408
- client = fabric.FabricRestClient()
409
- response = client.post(
410
- f"/v1/admin/domains/{domain_id}/unassignWorkspaces", json=payload
493
+
494
+ _base_api(
495
+ request=f"/v1/admin/domains/{domain_id}/unassignWorkspaces",
496
+ method="post",
497
+ payload=payload,
411
498
  )
412
499
 
413
- if response.status_code != 200:
414
- raise FabricHTTPException(response)
415
500
  print(
416
- f"{icons.green_dot} The {workspace_names} workspaces assigned to the '{domain_name}' domain have been unassigned."
501
+ f"{icons.green_dot} The {workspace_names} workspaces assigned to the '{domain}' domain have been unassigned."
417
502
  )
@@ -1,9 +1,12 @@
1
- import sempy.fabric as fabric
2
1
  from uuid import UUID
3
2
  import sempy_labs._icons as icons
4
- from sempy.fabric.exceptions import FabricHTTPException
5
3
  import pandas as pd
6
4
  from sempy_labs.admin._basic_functions import _resolve_workspace_name_and_id
5
+ from sempy_labs._helper_functions import (
6
+ _base_api,
7
+ _create_dataframe,
8
+ _update_dataframe_datatypes,
9
+ )
7
10
 
8
11
 
9
12
  def list_external_data_shares() -> pd.DataFrame:
@@ -17,28 +20,24 @@ def list_external_data_shares() -> pd.DataFrame:
17
20
  pandas.DataFrame
18
21
  A pandas dataframe showing a list of external data shares in the tenant.
19
22
  """
20
- df = pd.DataFrame(
21
- columns=[
22
- "External Data Share Id",
23
- "Paths",
24
- "Creater Principal Id",
25
- "Creater Principal Name",
26
- "Creater Principal Type",
27
- "Creater Principal UPN",
28
- "Recipient UPN",
29
- "Status",
30
- "Expiration Time UTC",
31
- "Workspace Id",
32
- "Item Id",
33
- "Invitation URL",
34
- ]
35
- )
36
-
37
- client = fabric.FabricRestClient()
38
- response = client.get("/v1/admin/items/externalDataShares")
39
23
 
40
- if response.status_code != 200:
41
- raise FabricHTTPException(response)
24
+ columns = {
25
+ "External Data Share Id": "string",
26
+ "Paths": "string",
27
+ "Creater Principal Id": "string",
28
+ "Creater Principal Name": "string",
29
+ "Creater Principal Type": "string",
30
+ "Creater Principal UPN": "string",
31
+ "Recipient UPN": "string",
32
+ "Status": "string",
33
+ "Expiration Time UTC": "datetime",
34
+ "Workspace Id": "string",
35
+ "Item Id": "string",
36
+ "Invitation URL": "string",
37
+ }
38
+ df = _create_dataframe(columns=columns)
39
+
40
+ response = _base_api(request="/v1/admin/items/externalDataShares")
42
41
 
43
42
  for i in response.json().get("value", []):
44
43
  cp = i.get("creatorPrincipal", {})
@@ -59,8 +58,7 @@ def list_external_data_shares() -> pd.DataFrame:
59
58
 
60
59
  df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
61
60
 
62
- date_time_columns = ["Expiration Time UTC"]
63
- df[date_time_columns] = pd.to_datetime(df[date_time_columns])
61
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
64
62
 
65
63
  return df
66
64
 
@@ -84,14 +82,11 @@ def revoke_external_data_share(
84
82
  """
85
83
  (workspace, workspace_id) = _resolve_workspace_name_and_id(workspace)
86
84
 
87
- client = fabric.FabricRestClient()
88
- response = client.post(
89
- f"/v1/admin/workspaces/{workspace_id}/items/{item_id}/externalDataShares/{external_data_share_id}/revoke"
85
+ _base_api(
86
+ request=f"/v1/admin/workspaces/{workspace_id}/items/{item_id}/externalDataShares/{external_data_share_id}/revoke",
87
+ method="post",
90
88
  )
91
89
 
92
- if response.status_code != 200:
93
- raise FabricHTTPException(response)
94
-
95
90
  print(
96
91
  f"{icons.green_dot} The '{external_data_share_id}' external data share for the '{item_id}' item within the '{workspace}' workspace has been revoked."
97
92
  )
sempy_labs/admin/_git.py CHANGED
@@ -1,11 +1,9 @@
1
- import sempy.fabric as fabric
2
- from sempy.fabric.exceptions import FabricHTTPException
3
1
  from sempy_labs._helper_functions import (
4
- pagination,
2
+ _base_api,
3
+ _create_dataframe,
5
4
  )
6
5
  import pandas as pd
7
6
  from sempy_labs.admin._basic_functions import list_workspaces
8
- import sempy_labs._authentication as auth
9
7
 
10
8
 
11
9
  def list_git_connections() -> pd.DataFrame:
@@ -22,27 +20,24 @@ def list_git_connections() -> pd.DataFrame:
22
20
  A pandas dataframe showing a list of Git connections.
23
21
  """
24
22
 
25
- client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
26
- response = client.get("/v1/admin/workspaces/discoverGitConnections")
23
+ columns = {
24
+ "Workspace Id": "string",
25
+ "Organization Name": "string",
26
+ "Owner Name": "string",
27
+ "Project Name": "string",
28
+ "Git Provider Type": "string",
29
+ "Repository Name": "string",
30
+ "Branch Name": "string",
31
+ "Directory Name": "string",
32
+ }
33
+ df = _create_dataframe(columns=columns)
27
34
 
28
- df = pd.DataFrame(
29
- columns=[
30
- "Workspace Id",
31
- "Organization Name",
32
- "Owner Name",
33
- "Project Name",
34
- "Git Provider Type",
35
- "Repository Name",
36
- "Branch Name",
37
- "Directory Name",
38
- ]
35
+ responses = _base_api(
36
+ request="/v1/admin/workspaces/discoverGitConnections",
37
+ client="fabric_sp",
38
+ uses_pagination=True,
39
39
  )
40
40
 
41
- if response.status_code != 200:
42
- raise FabricHTTPException(response)
43
-
44
- responses = pagination(client, response)
45
-
46
41
  for r in responses:
47
42
  for v in r.get("value", []):
48
43
  git = v.get("gitProviderDetails", {})