semantic-link-labs 0.8.10__py3-none-any.whl → 0.9.0__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 (81) hide show
  1. {semantic_link_labs-0.8.10.dist-info → semantic_link_labs-0.9.0.dist-info}/METADATA +6 -5
  2. {semantic_link_labs-0.8.10.dist-info → semantic_link_labs-0.9.0.dist-info}/RECORD +81 -80
  3. {semantic_link_labs-0.8.10.dist-info → semantic_link_labs-0.9.0.dist-info}/WHEEL +1 -1
  4. sempy_labs/__init__.py +34 -3
  5. sempy_labs/_authentication.py +80 -4
  6. sempy_labs/_capacities.py +770 -200
  7. sempy_labs/_capacity_migration.py +7 -37
  8. sempy_labs/_clear_cache.py +37 -35
  9. sempy_labs/_connections.py +13 -13
  10. sempy_labs/_data_pipelines.py +20 -20
  11. sempy_labs/_dataflows.py +27 -28
  12. sempy_labs/_dax.py +41 -47
  13. sempy_labs/_deployment_pipelines.py +1 -1
  14. sempy_labs/_environments.py +26 -23
  15. sempy_labs/_eventhouses.py +16 -15
  16. sempy_labs/_eventstreams.py +16 -15
  17. sempy_labs/_external_data_shares.py +18 -20
  18. sempy_labs/_gateways.py +16 -14
  19. sempy_labs/_generate_semantic_model.py +107 -62
  20. sempy_labs/_git.py +105 -43
  21. sempy_labs/_helper_functions.py +251 -194
  22. sempy_labs/_job_scheduler.py +227 -0
  23. sempy_labs/_kql_databases.py +16 -15
  24. sempy_labs/_kql_querysets.py +16 -15
  25. sempy_labs/_list_functions.py +150 -126
  26. sempy_labs/_managed_private_endpoints.py +19 -17
  27. sempy_labs/_mirrored_databases.py +51 -48
  28. sempy_labs/_mirrored_warehouses.py +5 -4
  29. sempy_labs/_ml_experiments.py +16 -15
  30. sempy_labs/_ml_models.py +15 -14
  31. sempy_labs/_model_bpa.py +210 -207
  32. sempy_labs/_model_bpa_bulk.py +2 -2
  33. sempy_labs/_model_bpa_rules.py +3 -3
  34. sempy_labs/_model_dependencies.py +55 -29
  35. sempy_labs/_notebooks.py +29 -25
  36. sempy_labs/_one_lake_integration.py +23 -26
  37. sempy_labs/_query_scale_out.py +75 -64
  38. sempy_labs/_refresh_semantic_model.py +25 -26
  39. sempy_labs/_spark.py +33 -32
  40. sempy_labs/_sql.py +19 -12
  41. sempy_labs/_translations.py +10 -7
  42. sempy_labs/_vertipaq.py +38 -33
  43. sempy_labs/_warehouses.py +26 -25
  44. sempy_labs/_workspace_identity.py +11 -10
  45. sempy_labs/_workspaces.py +40 -33
  46. sempy_labs/admin/_basic_functions.py +166 -115
  47. sempy_labs/admin/_domains.py +7 -2
  48. sempy_labs/admin/_external_data_share.py +3 -3
  49. sempy_labs/admin/_git.py +4 -1
  50. sempy_labs/admin/_items.py +11 -6
  51. sempy_labs/admin/_scanner.py +10 -5
  52. sempy_labs/directlake/_directlake_schema_compare.py +25 -16
  53. sempy_labs/directlake/_directlake_schema_sync.py +24 -12
  54. sempy_labs/directlake/_dl_helper.py +74 -55
  55. sempy_labs/directlake/_generate_shared_expression.py +10 -9
  56. sempy_labs/directlake/_get_directlake_lakehouse.py +32 -36
  57. sempy_labs/directlake/_get_shared_expression.py +4 -3
  58. sempy_labs/directlake/_guardrails.py +12 -6
  59. sempy_labs/directlake/_list_directlake_model_calc_tables.py +15 -9
  60. sempy_labs/directlake/_show_unsupported_directlake_objects.py +16 -10
  61. sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +35 -31
  62. sempy_labs/directlake/_update_directlake_partition_entity.py +39 -31
  63. sempy_labs/directlake/_warm_cache.py +87 -65
  64. sempy_labs/lakehouse/_get_lakehouse_columns.py +23 -26
  65. sempy_labs/lakehouse/_get_lakehouse_tables.py +27 -38
  66. sempy_labs/lakehouse/_lakehouse.py +7 -20
  67. sempy_labs/lakehouse/_shortcuts.py +42 -23
  68. sempy_labs/migration/_create_pqt_file.py +16 -11
  69. sempy_labs/migration/_refresh_calc_tables.py +16 -10
  70. sempy_labs/report/_download_report.py +9 -8
  71. sempy_labs/report/_generate_report.py +85 -44
  72. sempy_labs/report/_paginated.py +9 -9
  73. sempy_labs/report/_report_bpa.py +15 -11
  74. sempy_labs/report/_report_functions.py +80 -91
  75. sempy_labs/report/_report_helper.py +8 -4
  76. sempy_labs/report/_report_list_functions.py +24 -13
  77. sempy_labs/report/_report_rebind.py +17 -16
  78. sempy_labs/report/_reportwrapper.py +41 -33
  79. sempy_labs/tom/_model.py +139 -21
  80. {semantic_link_labs-0.8.10.dist-info → semantic_link_labs-0.9.0.dist-info}/LICENSE +0 -0
  81. {semantic_link_labs-0.8.10.dist-info → semantic_link_labs-0.9.0.dist-info}/top_level.txt +0 -0
@@ -8,11 +8,14 @@ from sempy_labs._helper_functions import (
8
8
  _is_valid_uuid,
9
9
  _build_url,
10
10
  )
11
+ from sempy._utils._log import log
11
12
  import numpy as np
12
13
  import pandas as pd
13
14
  from dateutil.parser import parse as dtparser
15
+ import sempy_labs._authentication as auth
14
16
 
15
17
 
18
+ @log
16
19
  def list_workspaces(
17
20
  capacity: Optional[str | UUID] = None,
18
21
  workspace: Optional[str | UUID] = None,
@@ -25,11 +28,13 @@ def list_workspaces(
25
28
 
26
29
  This is a wrapper function for the following API: `Workspaces - List Workspaces - REST API (Admin) <https://learn.microsoft.com/en-us/rest/api/fabric/admin/workspaces/list-workspaces>`_.
27
30
 
31
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
32
+
28
33
  Parameters
29
34
  ----------
30
- capacity : str | UUID, default=None
35
+ capacity : str | uuid.UUID, default=None
31
36
  Returns only the workspaces in the specified Capacity.
32
- workspace : str | UUID, default=None
37
+ workspace : str | uuid.UUID, default=None
33
38
  Returns the workspace with the specific name.
34
39
  workspace_state : str, default=None
35
40
  Return only the workspace with the requested state. You can find the possible states in `Workspace States <https://learn.microsoft.com/en-us/rest/api/fabric/admin/workspaces/list-workspaces?tabs=HTTP#workspacestate>`_.
@@ -59,7 +64,7 @@ def list_workspaces(
59
64
  )
60
65
  del kwargs["skip"]
61
66
 
62
- client = fabric.FabricRestClient()
67
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
63
68
 
64
69
  df = pd.DataFrame(
65
70
  columns=[
@@ -121,6 +126,7 @@ def list_workspaces(
121
126
  return df
122
127
 
123
128
 
129
+ @log
124
130
  def list_capacities(
125
131
  capacity: Optional[str | UUID] = None,
126
132
  ) -> pd.DataFrame:
@@ -129,9 +135,11 @@ def list_capacities(
129
135
 
130
136
  This is a wrapper function for the following API: `Admin - Get Capacities As Admin <https://learn.microsoft.com/rest/api/power-bi/admin/get-capacities-as-admin>`_.
131
137
 
138
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
139
+
132
140
  Parameters
133
141
  ----------
134
- capacity : str | UUID, default=None
142
+ capacity : str | uuid.UUID, default=None
135
143
  Capacity name or id to filter.
136
144
 
137
145
  Returns
@@ -139,7 +147,7 @@ def list_capacities(
139
147
  pandas.DataFrame
140
148
  A pandas dataframe showing the capacities and their properties.
141
149
  """
142
- client = fabric.FabricRestClient()
150
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
143
151
 
144
152
  df = pd.DataFrame(
145
153
  columns=["Capacity Id", "Capacity Name", "Sku", "Region", "State", "Admins"]
@@ -173,6 +181,7 @@ def list_capacities(
173
181
  return df
174
182
 
175
183
 
184
+ @log
176
185
  def assign_workspaces_to_capacity(
177
186
  source_capacity: Optional[str | UUID] = None,
178
187
  target_capacity: Optional[str | UUID] = None,
@@ -185,11 +194,11 @@ def assign_workspaces_to_capacity(
185
194
 
186
195
  Parameters
187
196
  ----------
188
- source_capacity : str | UUID, default=None
197
+ source_capacity : str | uuid.UUID, default=None
189
198
  The name of the source capacity. If the Workspace is not specified, this is parameter mandatory.
190
- target_capacity : str | UUID, default=None
199
+ target_capacity : str | uuid.UUID, default=None
191
200
  The name of the target capacity.
192
- workspace : str | List[str] | UUID | List[UUID], default=None
201
+ workspace : str | List[str] | uuid.UUID | List[uuid.UUID], default=None
193
202
  The name or id of the workspace(s).
194
203
  Defaults to None which resolves to migrating all workspaces within the source capacity to the target capacity.
195
204
  """
@@ -264,6 +273,7 @@ def assign_workspaces_to_capacity(
264
273
  )
265
274
 
266
275
 
276
+ @log
267
277
  def unassign_workspaces_from_capacity(
268
278
  workspaces: str | List[str] | UUID | List[UUID],
269
279
  ):
@@ -274,7 +284,7 @@ def unassign_workspaces_from_capacity(
274
284
 
275
285
  Parameters
276
286
  ----------
277
- workspaces : str | List[str] | UUID | List[UUID]
287
+ workspaces : str | List[str] | uuid.UUID | List[uuid.UUID]
278
288
  The Fabric workspace name(s) or id(s).
279
289
  """
280
290
  if isinstance(workspaces, str):
@@ -305,18 +315,21 @@ def unassign_workspaces_from_capacity(
305
315
  )
306
316
 
307
317
 
318
+ @log
308
319
  def list_tenant_settings() -> pd.DataFrame:
309
320
  """
310
321
  Lists all tenant settings.
311
322
 
312
323
  This is a wrapper function for the following API: `Tenants - List Tenant Settings <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-tenant-settings>`_.
313
324
 
325
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
326
+
314
327
  Returns
315
328
  -------
316
329
  pandas.DataFrame
317
330
  A pandas dataframe showing the tenant settings.
318
331
  """
319
- client = fabric.FabricRestClient()
332
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
320
333
 
321
334
  response = client.get("/v1/admin/tenantsettings")
322
335
 
@@ -359,6 +372,8 @@ def list_capacities_delegated_tenant_settings(
359
372
 
360
373
  This is a wrapper function for the following API: `Tenants - List Capacities Tenant Settings Overrides <https://learn.microsoft.com/rest/api/fabric/admin/tenants/list-capacities-tenant-settings-overrides>`_.
361
374
 
375
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
376
+
362
377
  Parameters
363
378
  ----------
364
379
  return_dataframe : bool, default=True
@@ -384,7 +399,7 @@ def list_capacities_delegated_tenant_settings(
384
399
  ]
385
400
  )
386
401
 
387
- client = fabric.FabricRestClient()
402
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
388
403
  response = client.get("/v1/admin/capacities/delegatedTenantSettingOverrides")
389
404
 
390
405
  if response.status_code != 200:
@@ -450,6 +465,8 @@ def list_modified_workspaces(
450
465
 
451
466
  This is a wrapper function for the following API: `Admin - WorkspaceInfo GetModifiedWorkspaces <https://learn.microsoft.com/rest/api/power-bi/admin/workspace-info-get-modified-workspaces>`_.
452
467
 
468
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
469
+
453
470
  Parameters
454
471
  ----------
455
472
  modified_since : str, default=None
@@ -464,7 +481,7 @@ def list_modified_workspaces(
464
481
  pandas.DataFrame
465
482
  A pandas dataframe showing a list of workspace IDs in the organization.
466
483
  """
467
- client = fabric.PowerBIRestClient()
484
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
468
485
 
469
486
  params = {}
470
487
 
@@ -504,6 +521,8 @@ def list_datasets(
504
521
 
505
522
  This is a wrapper function for the following API: `Admin - Datasets GetDatasetsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/datasets-get-datasets-as-admin>`_.
506
523
 
524
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
525
+
507
526
  Parameters
508
527
  ----------
509
528
  top : int, default=None
@@ -512,39 +531,38 @@ def list_datasets(
512
531
  Returns a subset of a results based on Odata filter query parameter condition.
513
532
  skip : int, default=None
514
533
  Skips the first n results.
515
- token_provider : Optional[TokenProvider] = None,
516
- Authentication provider used to be use in the request. Supports Service Principal.
517
534
 
518
535
  Returns
519
536
  -------
520
537
  pandas.DataFrame
521
538
  A pandas dataframe showing a list of datasets for the organization.
522
539
  """
523
- df = pd.DataFrame(
524
- columns=[
525
- "Dataset Id",
526
- "Dataset Name",
527
- "Web URL",
528
- "Add Rows API Enabled",
529
- "Configured By",
530
- "Is Refreshable",
531
- "Is Effective Identity Required",
532
- "Is Effective Identity Roles Required",
533
- "Target Storage Mode",
534
- "Created Date",
535
- "Content Provider Type",
536
- "Create Report Embed URL",
537
- "QnA Embed URL",
538
- "Upstream Datasets",
539
- "Users",
540
- "Is In Place Sharing Enabled",
541
- "Workspace Id",
542
- "Auto Sync Read Only Replicas",
543
- "Max Read Only Replicas",
544
- ]
545
- )
546
540
 
547
- client = fabric.PowerBIRestClient()
541
+ columns = [
542
+ "Dataset Id",
543
+ "Dataset Name",
544
+ "Web URL",
545
+ "Add Rows API Enabled",
546
+ "Configured By",
547
+ "Is Refreshable",
548
+ "Is Effective Identity Required",
549
+ "Is Effective Identity Roles Required",
550
+ "Target Storage Mode",
551
+ "Created Date",
552
+ "Content Provider Type",
553
+ "Create Report Embed URL",
554
+ "QnA Embed URL",
555
+ "Upstream Datasets",
556
+ "Users",
557
+ "Is In Place Sharing Enabled",
558
+ "Workspace Id",
559
+ "Auto Sync Read Only Replicas",
560
+ "Max Read Only Replicas",
561
+ ]
562
+
563
+ df = pd.DataFrame(columns=columns)
564
+
565
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
548
566
 
549
567
  params = {}
550
568
  url = "/v1.0/myorg/admin/datasets"
@@ -565,35 +583,40 @@ def list_datasets(
565
583
  if response.status_code != 200:
566
584
  raise FabricHTTPException(response)
567
585
 
586
+ rows = []
568
587
  for v in response.json().get("value", []):
569
- new_data = {
570
- "Dataset Id": v.get("id"),
571
- "Dataset Name": v.get("name"),
572
- "Web URL": v.get("webUrl"),
573
- "Add Rows API Enabled": v.get("addRowsAPIEnabled"),
574
- "Configured By": v.get("configuredBy"),
575
- "Is Refreshable": v.get("isRefreshable"),
576
- "Is Effective Identity Required": v.get("isEffectiveIdentityRequired"),
577
- "Is Effective Identity Roles Required": v.get(
578
- "isEffectiveIdentityRolesRequired"
579
- ),
580
- "Target Storage Mode": v.get("targetStorageMode"),
581
- "Created Date": pd.to_datetime(v.get("createdDate")),
582
- "Content Provider Type": v.get("contentProviderType"),
583
- "Create Report Embed URL": v.get("createReportEmbedURL"),
584
- "QnA Embed URL": v.get("qnaEmbedURL"),
585
- "Upstream Datasets": v.get("upstreamDatasets", []),
586
- "Users": v.get("users", []),
587
- "Is In Place Sharing Enabled": v.get("isInPlaceSharingEnabled"),
588
- "Workspace Id": v.get("workspaceId"),
589
- "Auto Sync Read Only Replicas": v.get("queryScaleOutSettings", {}).get(
590
- "autoSyncReadOnlyReplicas"
591
- ),
592
- "Max Read Only Replicas": v.get("queryScaleOutSettings", {}).get(
593
- "maxReadOnlyReplicas"
594
- ),
595
- }
596
- df = pd.concat([df, pd.DataFrame([new_data])], ignore_index=True)
588
+ rows.append(
589
+ {
590
+ "Dataset Id": v.get("id"),
591
+ "Dataset Name": v.get("name"),
592
+ "Web URL": v.get("webUrl"),
593
+ "Add Rows API Enabled": v.get("addRowsAPIEnabled"),
594
+ "Configured By": v.get("configuredBy"),
595
+ "Is Refreshable": v.get("isRefreshable"),
596
+ "Is Effective Identity Required": v.get("isEffectiveIdentityRequired"),
597
+ "Is Effective Identity Roles Required": v.get(
598
+ "isEffectiveIdentityRolesRequired"
599
+ ),
600
+ "Target Storage Mode": v.get("targetStorageMode"),
601
+ "Created Date": pd.to_datetime(v.get("createdDate")),
602
+ "Content Provider Type": v.get("contentProviderType"),
603
+ "Create Report Embed URL": v.get("createReportEmbedURL"),
604
+ "QnA Embed URL": v.get("qnaEmbedURL"),
605
+ "Upstream Datasets": v.get("upstreamDatasets", []),
606
+ "Users": v.get("users", []),
607
+ "Is In Place Sharing Enabled": v.get("isInPlaceSharingEnabled"),
608
+ "Workspace Id": v.get("workspaceId"),
609
+ "Auto Sync Read Only Replicas": v.get("queryScaleOutSettings", {}).get(
610
+ "autoSyncReadOnlyReplicas"
611
+ ),
612
+ "Max Read Only Replicas": v.get("queryScaleOutSettings", {}).get(
613
+ "maxReadOnlyReplicas"
614
+ ),
615
+ }
616
+ )
617
+
618
+ if rows:
619
+ df = pd.DataFrame(rows, columns=columns)
597
620
 
598
621
  bool_cols = [
599
622
  "Add Rows API Enabled",
@@ -619,6 +642,8 @@ def list_access_entities(
619
642
 
620
643
  This is a wrapper function for the following API: `Users - List Access Entities <https://learn.microsoft.com/rest/api/fabric/admin/users/list-access-entities>`_.
621
644
 
645
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
646
+
622
647
  Parameters
623
648
  ----------
624
649
  user_email_address : str
@@ -638,7 +663,7 @@ def list_access_entities(
638
663
  "Additional Permissions",
639
664
  ]
640
665
  )
641
- client = fabric.FabricRestClient()
666
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
642
667
 
643
668
  response = client.get(f"/v1/admin/users/{user_email_address}/access")
644
669
 
@@ -664,16 +689,18 @@ def list_access_entities(
664
689
 
665
690
 
666
691
  def list_workspace_access_details(
667
- workspace: Optional[Union[str, UUID]] = None
692
+ workspace: Optional[Union[str, UUID]] = None,
668
693
  ) -> pd.DataFrame:
669
694
  """
670
695
  Shows a list of users (including groups and Service Principals) that have access to the specified workspace.
671
696
 
672
697
  This is a wrapper function for the following API: `Workspaces - List Workspace Access Details <https://learn.microsoft.com/rest/api/fabric/admin/workspaces/list-workspace-access-details>`_.
673
698
 
699
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
700
+
674
701
  Parameters
675
702
  ----------
676
- workspace : str | UUID, default=None
703
+ workspace : str | uuid.UUID, default=None
677
704
  The Fabric workspace name or id.
678
705
  Defaults to None which resolves to the workspace of the attached lakehouse
679
706
  or if no lakehouse attached, resolves to the workspace of the notebook.
@@ -683,7 +710,7 @@ def list_workspace_access_details(
683
710
  pandas.DataFrame
684
711
  A pandas dataframe showing a list of users (including groups and Service Principals) that have access to the specified workspace.
685
712
  """
686
- workspace_name, workspace_id = _resolve_workspace_name_and_id(workspace)
713
+ (workspace_name, workspace_id) = _resolve_workspace_name_and_id(workspace)
687
714
 
688
715
  df = pd.DataFrame(
689
716
  columns=[
@@ -696,7 +723,7 @@ def list_workspace_access_details(
696
723
  ]
697
724
  )
698
725
 
699
- client = fabric.FabricRestClient()
726
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
700
727
 
701
728
  response = client.get(f"/v1/admin/workspaces/{workspace_id}/users")
702
729
  if response.status_code != 200:
@@ -721,13 +748,15 @@ def list_activity_events(
721
748
  end_time: str,
722
749
  activity_filter: Optional[str] = None,
723
750
  user_id_filter: Optional[str] = None,
724
- return_dataframe: Optional[bool] = True,
751
+ return_dataframe: bool = True,
725
752
  ) -> pd.DataFrame | dict:
726
753
  """
727
754
  Shows a list of audit activity events for a tenant.
728
755
 
729
756
  This is a wrapper function for the following API: `Admin - Get Activity Events <https://learn.microsoft.com/rest/api/power-bi/admin/get-activity-events>`_.
730
757
 
758
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
759
+
731
760
  Parameters
732
761
  ----------
733
762
  start_time : str
@@ -798,7 +827,7 @@ def list_activity_events(
798
827
  )
799
828
 
800
829
  response_json = {"activityEventEntities": []}
801
- client = fabric.PowerBIRestClient()
830
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
802
831
  url = f"/v1.0/myorg/admin/activityevents?startDateTime='{start_time}'&endDateTime='{end_time}'"
803
832
 
804
833
  conditions = []
@@ -951,38 +980,51 @@ def _resolve_workspace_name_and_id(
951
980
 
952
981
 
953
982
  def list_reports(
954
- top: Optional[int] = None, skip: Optional[int] = None, filter: Optional[str] = None
983
+ top: Optional[int] = None,
984
+ skip: Optional[int] = None,
985
+ filter: Optional[str] = None,
955
986
  ) -> pd.DataFrame:
956
987
  """
957
988
  Shows a list of reports for the organization.
958
989
 
959
990
  This is a wrapper function for the following API: `Admin - Reports GetReportsAsAdmin <https://learn.microsoft.com/rest/api/power-bi/admin/reports-get-reports-as-admin>`_.
960
991
 
992
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
993
+
994
+ Parameters
995
+ ----------
996
+ top : int, default=None
997
+ Returns only the first n results.
998
+ skip : int, default=None
999
+ Skips the first n results.
1000
+ filter : str, default=None
1001
+ Returns a subset of a results based on Odata filter query parameter condition.
1002
+
961
1003
  Returns
962
1004
  -------
963
1005
  pandas.DataFrame
964
1006
  A pandas dataframe showing a list of reports for the organization.
965
1007
  """
966
1008
 
967
- df = pd.DataFrame(
968
- columns=[
969
- "Report Id",
970
- "Report Name",
971
- "Type",
972
- "Web URL",
973
- "Embed URL",
974
- "Dataset Id",
975
- "Created Date",
976
- "Modified Date",
977
- "Created By",
978
- "Modified By",
979
- "Sensitivity Label Id",
980
- "Users",
981
- "Subscriptions",
982
- "Workspace Id",
983
- "Report Flags",
984
- ]
985
- )
1009
+ columns = [
1010
+ "Report Id",
1011
+ "Report Name",
1012
+ "Type",
1013
+ "Web URL",
1014
+ "Embed URL",
1015
+ "Dataset Id",
1016
+ "Created Date",
1017
+ "Modified Date",
1018
+ "Created By",
1019
+ "Modified By",
1020
+ "Sensitivity Label Id",
1021
+ "Users",
1022
+ "Subscriptions",
1023
+ "Workspace Id",
1024
+ "Report Flags",
1025
+ ]
1026
+
1027
+ df = pd.DataFrame(columns=columns)
986
1028
 
987
1029
  url = "/v1.0/myorg/admin/reports?"
988
1030
  if top is not None:
@@ -994,31 +1036,36 @@ def list_reports(
994
1036
 
995
1037
  url.rstrip("$").rstrip("?")
996
1038
 
997
- client = fabric.PowerBIRestClient()
1039
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
998
1040
  response = client.get(url)
999
1041
 
1000
1042
  if response.status_code != 200:
1001
1043
  raise FabricHTTPException(response)
1002
1044
 
1045
+ rows = []
1003
1046
  for v in response.json().get("value", []):
1004
- new_data = {
1005
- "Report Id": v.get("id"),
1006
- "Report Name": v.get("name"),
1007
- "Type": v.get("reportType"),
1008
- "Web URL": v.get("webUrl"),
1009
- "Embed URL": v.get("embedUrl"),
1010
- "Dataset Id": v.get("datasetId"),
1011
- "Created Date": v.get("createdDateTime"),
1012
- "Modified Date": v.get("modifiedDateTime"),
1013
- "Created By": v.get("createdBy"),
1014
- "Modified By": v.get("modifiedBy"),
1015
- "Sensitivity Label Id": v.get("sensitivityLabel", {}).get("labelId"),
1016
- "Users": v.get("users"),
1017
- "Subscriptions": v.get("subscriptions"),
1018
- "Workspace Id": v.get("workspaceId"),
1019
- "Report Flags": v.get("reportFlags"),
1020
- }
1021
- df = pd.concat([df, pd.DataFrame([new_data])], ignore_index=True)
1047
+ rows.append(
1048
+ {
1049
+ "Report Id": v.get("id"),
1050
+ "Report Name": v.get("name"),
1051
+ "Type": v.get("reportType"),
1052
+ "Web URL": v.get("webUrl"),
1053
+ "Embed URL": v.get("embedUrl"),
1054
+ "Dataset Id": v.get("datasetId"),
1055
+ "Created Date": v.get("createdDateTime"),
1056
+ "Modified Date": v.get("modifiedDateTime"),
1057
+ "Created By": v.get("createdBy"),
1058
+ "Modified By": v.get("modifiedBy"),
1059
+ "Sensitivity Label Id": v.get("sensitivityLabel", {}).get("labelId"),
1060
+ "Users": v.get("users"),
1061
+ "Subscriptions": v.get("subscriptions"),
1062
+ "Workspace Id": v.get("workspaceId"),
1063
+ "Report Flags": v.get("reportFlags"),
1064
+ }
1065
+ )
1066
+
1067
+ if rows:
1068
+ df = pd.DataFrame(rows, columns=columns)
1022
1069
 
1023
1070
  int_cols = ["Report Flags"]
1024
1071
  df[int_cols] = df[int_cols].astype(int)
@@ -1029,15 +1076,19 @@ def list_reports(
1029
1076
  return df
1030
1077
 
1031
1078
 
1032
- def get_capacity_assignment_status(workspace: Optional[str | UUID] = None):
1079
+ def get_capacity_assignment_status(
1080
+ workspace: Optional[str | UUID] = None,
1081
+ ) -> pd.DataFrame:
1033
1082
  """
1034
1083
  Gets the status of the assignment-to-capacity operation for the specified workspace.
1035
1084
 
1036
1085
  This is a wrapper function for the following API: `Capacities - Groups CapacityAssignmentStatus <https://learn.microsoft.com/rest/api/power-bi/capacities/groups-capacity-assignment-status>`_.
1037
1086
 
1087
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
1088
+
1038
1089
  Parameters
1039
1090
  ----------
1040
- workspace : str | UUID, default=None
1091
+ workspace : str | uuid.UUID, default=None
1041
1092
  The Fabric workspace name or id.
1042
1093
  Defaults to None which resolves to the workspace of the attached lakehouse
1043
1094
  or if no lakehouse attached, resolves to the workspace of the notebook.
@@ -1061,7 +1112,7 @@ def get_capacity_assignment_status(workspace: Optional[str | UUID] = None):
1061
1112
  ]
1062
1113
  )
1063
1114
 
1064
- client = fabric.FabricRestClient()
1115
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
1065
1116
  response = client.get(f"/v1.0/myorg/groups/{workspace_id}/CapacityAssignmentStatus")
1066
1117
 
1067
1118
  if response.status_code != 200:
@@ -6,6 +6,7 @@ from sempy.fabric.exceptions import FabricHTTPException
6
6
  import pandas as pd
7
7
  from uuid import UUID
8
8
  from sempy_labs.admin._basic_functions import list_workspaces
9
+ import sempy_labs._authentication as auth
9
10
 
10
11
 
11
12
  def resolve_domain_id(domain_name: str) -> UUID:
@@ -37,6 +38,8 @@ def list_domains(non_empty_only: bool = False) -> pd.DataFrame:
37
38
 
38
39
  This is a wrapper function for the following API: `Domains - List Domains <https://learn.microsoft.com/rest/api/fabric/admin/domains/list-domains>`_.
39
40
 
41
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
42
+
40
43
  Parameters
41
44
  ----------
42
45
  non_empty_only : bool, default=False
@@ -59,7 +62,7 @@ def list_domains(non_empty_only: bool = False) -> pd.DataFrame:
59
62
  ]
60
63
  )
61
64
 
62
- client = fabric.FabricRestClient()
65
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
63
66
  url = "/v1/admin/domains"
64
67
  if non_empty_only:
65
68
  url = f"{url}?nonEmptyOnly=True"
@@ -87,6 +90,8 @@ def list_domain_workspaces(domain_name: str) -> pd.DataFrame:
87
90
 
88
91
  This is a wrapper function for the following API: `Domains - List Domain Workspaces <https://learn.microsoft.com/rest/api/fabric/admin/domains/list-domain-workspaces>`_.
89
92
 
93
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
94
+
90
95
  Parameters
91
96
  ----------
92
97
  domain_name : str
@@ -102,7 +107,7 @@ def list_domain_workspaces(domain_name: str) -> pd.DataFrame:
102
107
 
103
108
  df = pd.DataFrame(columns=["Workspace ID", "Workspace Name"])
104
109
 
105
- client = fabric.FabricRestClient()
110
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
106
111
  response = client.get(f"/v1/admin/domains/{domain_id}/workspaces")
107
112
 
108
113
  if response.status_code != 200:
@@ -75,11 +75,11 @@ def revoke_external_data_share(
75
75
 
76
76
  Parameters
77
77
  ----------
78
- external_data_share_id : UUID
78
+ external_data_share_id : uuid.UUID
79
79
  The external data share ID.
80
- item_id : int, default=None
80
+ item_id : uuid.UUID, default=None
81
81
  The Item ID
82
- workspace : str
82
+ workspace : str | uuid.UUID
83
83
  The Fabric workspace name or id.
84
84
  """
85
85
  (workspace, workspace_id) = _resolve_workspace_name_and_id(workspace)
sempy_labs/admin/_git.py CHANGED
@@ -5,6 +5,7 @@ from sempy_labs._helper_functions import (
5
5
  )
6
6
  import pandas as pd
7
7
  from sempy_labs.admin._basic_functions import list_workspaces
8
+ import sempy_labs._authentication as auth
8
9
 
9
10
 
10
11
  def list_git_connections() -> pd.DataFrame:
@@ -13,13 +14,15 @@ def list_git_connections() -> pd.DataFrame:
13
14
 
14
15
  This is a wrapper function for the following API: `Workspaces - List Git Connections <https://learn.microsoft.com/rest/api/fabric/admin/workspaces/list-git-connections>`_.
15
16
 
17
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
18
+
16
19
  Returns
17
20
  -------
18
21
  pandas.DataFrame
19
22
  A pandas dataframe showing a list of Git connections.
20
23
  """
21
24
 
22
- client = fabric.FabricRestClient()
25
+ client = fabric.FabricRestClient(token_provider=auth.token_provider.get())
23
26
  response = client.get("/v1/admin/workspaces/discoverGitConnections")
24
27
 
25
28
  df = pd.DataFrame(