semantic-link-labs 0.9.1__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 (82) hide show
  1. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/METADATA +66 -8
  2. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/RECORD +82 -75
  3. sempy_labs/__init__.py +14 -12
  4. sempy_labs/_capacities.py +120 -142
  5. sempy_labs/_capacity_migration.py +61 -94
  6. sempy_labs/_clear_cache.py +9 -8
  7. sempy_labs/_connections.py +72 -105
  8. sempy_labs/_data_pipelines.py +47 -49
  9. sempy_labs/_dataflows.py +45 -51
  10. sempy_labs/_dax.py +228 -6
  11. sempy_labs/_delta_analyzer.py +303 -0
  12. sempy_labs/_deployment_pipelines.py +72 -66
  13. sempy_labs/_environments.py +39 -36
  14. sempy_labs/_eventhouses.py +35 -35
  15. sempy_labs/_eventstreams.py +38 -39
  16. sempy_labs/_external_data_shares.py +29 -42
  17. sempy_labs/_gateways.py +57 -101
  18. sempy_labs/_generate_semantic_model.py +22 -30
  19. sempy_labs/_git.py +46 -66
  20. sempy_labs/_graphQL.py +95 -0
  21. sempy_labs/_helper_functions.py +175 -30
  22. sempy_labs/_job_scheduler.py +47 -59
  23. sempy_labs/_kql_databases.py +27 -34
  24. sempy_labs/_kql_querysets.py +23 -30
  25. sempy_labs/_list_functions.py +262 -164
  26. sempy_labs/_managed_private_endpoints.py +52 -47
  27. sempy_labs/_mirrored_databases.py +110 -134
  28. sempy_labs/_mirrored_warehouses.py +13 -13
  29. sempy_labs/_ml_experiments.py +36 -36
  30. sempy_labs/_ml_models.py +37 -38
  31. sempy_labs/_model_dependencies.py +2 -0
  32. sempy_labs/_notebooks.py +28 -29
  33. sempy_labs/_one_lake_integration.py +2 -0
  34. sempy_labs/_query_scale_out.py +63 -81
  35. sempy_labs/_refresh_semantic_model.py +12 -14
  36. sempy_labs/_spark.py +54 -79
  37. sempy_labs/_sql.py +7 -11
  38. sempy_labs/_vertipaq.py +8 -3
  39. sempy_labs/_warehouses.py +30 -33
  40. sempy_labs/_workloads.py +15 -20
  41. sempy_labs/_workspace_identity.py +13 -17
  42. sempy_labs/_workspaces.py +49 -48
  43. sempy_labs/admin/__init__.py +2 -0
  44. sempy_labs/admin/_basic_functions.py +244 -281
  45. sempy_labs/admin/_domains.py +188 -103
  46. sempy_labs/admin/_external_data_share.py +26 -31
  47. sempy_labs/admin/_git.py +17 -22
  48. sempy_labs/admin/_items.py +34 -48
  49. sempy_labs/admin/_scanner.py +20 -13
  50. sempy_labs/directlake/_directlake_schema_compare.py +2 -0
  51. sempy_labs/directlake/_dl_helper.py +10 -11
  52. sempy_labs/directlake/_generate_shared_expression.py +4 -5
  53. sempy_labs/directlake/_get_directlake_lakehouse.py +1 -0
  54. sempy_labs/directlake/_list_directlake_model_calc_tables.py +1 -0
  55. sempy_labs/directlake/_show_unsupported_directlake_objects.py +2 -0
  56. sempy_labs/directlake/_warm_cache.py +2 -0
  57. sempy_labs/graph/__init__.py +33 -0
  58. sempy_labs/graph/_groups.py +402 -0
  59. sempy_labs/graph/_teams.py +113 -0
  60. sempy_labs/graph/_users.py +191 -0
  61. sempy_labs/lakehouse/__init__.py +4 -0
  62. sempy_labs/lakehouse/_get_lakehouse_columns.py +10 -10
  63. sempy_labs/lakehouse/_get_lakehouse_tables.py +14 -20
  64. sempy_labs/lakehouse/_lakehouse.py +101 -4
  65. sempy_labs/lakehouse/_shortcuts.py +42 -20
  66. sempy_labs/migration/__init__.py +4 -0
  67. sempy_labs/migration/_direct_lake_to_import.py +66 -0
  68. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +1 -0
  69. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +1 -0
  70. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +1 -0
  71. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +2 -0
  72. sempy_labs/report/_download_report.py +8 -13
  73. sempy_labs/report/_generate_report.py +49 -46
  74. sempy_labs/report/_paginated.py +20 -26
  75. sempy_labs/report/_report_functions.py +50 -45
  76. sempy_labs/report/_report_list_functions.py +2 -0
  77. sempy_labs/report/_report_rebind.py +6 -10
  78. sempy_labs/report/_reportwrapper.py +187 -220
  79. sempy_labs/tom/_model.py +8 -5
  80. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/LICENSE +0 -0
  81. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/WHEEL +0 -0
  82. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/top_level.txt +0 -0
sempy_labs/_capacities.py CHANGED
@@ -5,9 +5,17 @@ import sempy_labs._icons as icons
5
5
  from sempy.fabric.exceptions import FabricHTTPException
6
6
  import requests
7
7
  import pandas as pd
8
- from sempy_labs._authentication import _get_headers, ServicePrincipalTokenProvider
8
+ from sempy_labs._authentication import (
9
+ _get_headers,
10
+ ServicePrincipalTokenProvider,
11
+ )
9
12
  from uuid import UUID
10
- from sempy_labs._helper_functions import _is_valid_uuid
13
+ from sempy_labs._helper_functions import (
14
+ _is_valid_uuid,
15
+ _update_dataframe_datatypes,
16
+ _base_api,
17
+ _create_dataframe,
18
+ )
11
19
  import sempy_labs._authentication as auth
12
20
 
13
21
 
@@ -213,12 +221,13 @@ def create_fabric_capacity(
213
221
 
214
222
  def list_vcores() -> pd.DataFrame:
215
223
 
216
- df = pd.DataFrame(columns=["Total Purchased Cores", "Available Cores"])
224
+ columns = {
225
+ "Total Purchased Cores": "int",
226
+ "Available Cores": "int",
227
+ }
228
+ df = _create_dataframe(columns=columns)
217
229
 
218
- client = fabric.PowerBIRestClient()
219
- response = client.get("capacities/vcores")
220
- if response.status_code != 200:
221
- FabricHTTPException(response)
230
+ response = _base_api(request="capacities/vcores")
222
231
  response_json = response.json()
223
232
  new_data = {
224
233
  "Total Purchased Cores": response_json.get("totalPurchasedCores"),
@@ -226,8 +235,7 @@ def list_vcores() -> pd.DataFrame:
226
235
  }
227
236
  df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
228
237
 
229
- int_cols = ["Total Purchased Cores", "Available Cores"]
230
- df[int_cols] = df[int_cols].astype(int)
238
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
231
239
 
232
240
  return df
233
241
 
@@ -237,11 +245,8 @@ def get_capacity_resource_governance(capacity_name: str):
237
245
  dfC = fabric.list_capacities()
238
246
  dfC_filt = dfC[dfC["Display Name"] == capacity_name]
239
247
  capacity_id = dfC_filt["Id"].iloc[0].upper()
240
- client = fabric.PowerBIRestClient()
241
- response = client.get(f"capacities/{capacity_id}/resourceGovernance")
242
248
 
243
- if response.status_code != 200:
244
- FabricHTTPException(response)
249
+ response = _base_api(request=f"capacities/{capacity_id}/resourceGovernance")
245
250
 
246
251
  return response.json()["workloadSettings"]
247
252
 
@@ -408,11 +413,7 @@ def delete_premium_capacity(capacity_name: str):
408
413
  )
409
414
  capacity_id = dfC_filt["Id"].iloc[0].upper()
410
415
 
411
- client = fabric.FabricRestClient()
412
- response = client.delete(f"capacities/{capacity_id}")
413
-
414
- if response.status_code != 204:
415
- raise FabricHTTPException(response)
416
+ _base_api(request=f"capacities/{capacity_id}", method="delete", status_codes=204)
416
417
 
417
418
  print(f"{icons.green_dot} The '{capacity_name}' capacity has been deleted.")
418
419
 
@@ -681,13 +682,15 @@ def list_skus_for_capacity(
681
682
  A pandas dataframe showing a list of eligible SKUs for a Microsoft Fabric resource.
682
683
  """
683
684
 
684
- df = pd.DataFrame(columns=["Resource Type", "Sku", "Sku Tier"])
685
- url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Fabric/capacities/{capacity}/skus?api-version=2023-11-01"
686
- headers = _get_headers(token_provider=auth.token_provider.get(), audience="azure")
685
+ columns = {
686
+ "Resource Type": "string",
687
+ "Sku": "string",
688
+ "Sku Tier": "string",
689
+ }
690
+ df = _create_dataframe(columns=columns)
687
691
 
688
- response = requests.get(url, headers=headers)
689
- if response.status_code != 200:
690
- raise FabricHTTPException(response)
692
+ url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Fabric/capacities/{capacity}/skus?api-version=2023-11-01"
693
+ response = _base_api(request=url, client="azure")
691
694
 
692
695
  for v in response.json().get("value", []):
693
696
  sku = v.get("sku", {})
@@ -724,13 +727,14 @@ def list_skus(
724
727
  A pandas dataframe showing a list of eligible SKUs for Microsoft Fabric resource provider.
725
728
  """
726
729
 
727
- df = pd.DataFrame(columns=["Sku", "Locations"])
728
- url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/providers/Microsoft.Fabric/skus?api-version=2023-11-01"
729
- headers = _get_headers(token_provider=auth.token_provider.get(), audience="azure")
730
+ columns = {
731
+ "Sku": "string",
732
+ "Locations": "str",
733
+ }
734
+ df = _create_dataframe(columns=columns)
730
735
 
731
- response = requests.get(url, headers=headers)
732
- if response.status_code != 200:
733
- raise FabricHTTPException(response)
736
+ url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/providers/Microsoft.Fabric/skus?api-version=2023-11-01"
737
+ response = _base_api(request=url, client="azure")
734
738
 
735
739
  for v in response.json().get("value", []):
736
740
  new_data = {
@@ -758,26 +762,22 @@ def list_subscriptions() -> pd.DataFrame:
758
762
  A pandas dataframe showing a list of all subscriptions for a tenant.
759
763
  """
760
764
 
761
- df = pd.DataFrame(
762
- columns=[
763
- "Subscription Id",
764
- "Subscription Name",
765
- "Tenant Id",
766
- "State",
767
- "Location Placement Id",
768
- "Quota Id",
769
- "Spending Limit",
770
- "Authorization Source",
771
- "Managed By Tenants",
772
- "Tags",
773
- ]
774
- )
775
- url = "https://management.azure.com/subscriptions?api-version=2022-12-01"
776
- headers = _get_headers(token_provider=auth.token_provider.get(), audience="azure")
765
+ columns = {
766
+ "Subscription Id": "string",
767
+ "Subscription Name": "string",
768
+ "Tenant Id": "string",
769
+ "State": "string",
770
+ "Location Placement Id": "string",
771
+ "Quota Id": "string",
772
+ "Spending Limit": "string",
773
+ "Authorization Source": "string",
774
+ "Managed by Tenants": "string",
775
+ "Tags": "string",
776
+ }
777
+ df = _create_dataframe(columns=columns)
777
778
 
778
- response = requests.get(url, headers=headers)
779
- if response.status_code != 200:
780
- raise FabricHTTPException(response)
779
+ url = "https://management.azure.com/subscriptions?api-version=2022-12-01"
780
+ response = _base_api(request=url, client="azure")
781
781
 
782
782
  for v in response.json().get("value", []):
783
783
  policy = v.get("subscriptionPolicies", {})
@@ -820,27 +820,23 @@ def get_subscription(azure_subscription_id: str) -> pd.DataFrame:
820
820
  A pandas dataframe showing details of a specific subscription.
821
821
  """
822
822
 
823
- df = pd.DataFrame(
824
- columns=[
825
- "Subscription Id",
826
- "Subscription Name",
827
- "Tenant Id",
828
- "State",
829
- "Location Placement Id",
830
- "Quota Id",
831
- "Spending Limit",
832
- "Authorization Source",
833
- "Managed By Tenants",
834
- "Tags",
835
- ]
836
- )
837
- url = f"https://management.azure.com/subscriptions/{azure_subscription_id}?api-version=2022-12-01"
838
- headers = _get_headers(token_provider=auth.token_provider.get(), audience="azure")
823
+ columns = {
824
+ "Subscription Id": "string",
825
+ "Subscription Name": "string",
826
+ "Tenant Id": "string",
827
+ "State": "string",
828
+ "Location Placement Id": "string",
829
+ "Quota Id": "string",
830
+ "Spending Limit": "string",
831
+ "Authorization Source": "string",
832
+ "Managed by Tenants": "string",
833
+ "Tags": "string",
834
+ }
835
+ df = _create_dataframe(columns=columns)
839
836
 
840
- response = requests.get(url, headers=headers)
841
- if response.status_code != 200:
842
- raise FabricHTTPException(response)
837
+ url = f"https://management.azure.com/subscriptions/{azure_subscription_id}?api-version=2022-12-01"
843
838
 
839
+ response = _base_api(request=url, client="azure")
844
840
  v = response.json()
845
841
  policy = v.get("subscriptionPolicies", {})
846
842
  tenants = v.get("managedByTenants")
@@ -898,24 +894,21 @@ def list_tenants() -> pd.DataFrame:
898
894
  A pandas dataframe showing a list of all tenants for your account.
899
895
  """
900
896
 
901
- df = pd.DataFrame(
902
- columns=[
903
- "Tenant Id",
904
- "Tenant Name",
905
- "Country Code",
906
- "Domains",
907
- "Tenant Category",
908
- "Default Domain",
909
- "Tenant Type",
910
- "Tenant Branding Logo Url",
911
- ]
912
- )
897
+ columns = {
898
+ "Tenant Id": "string",
899
+ "Tenant Name": "string",
900
+ "Country Code": "string",
901
+ "Domains": "string",
902
+ "Tenant Category": "string",
903
+ "Default Domain": "string",
904
+ "Tenant Type": "string",
905
+ "Tenant Branding Logo Url": "string",
906
+ }
907
+ df = _create_dataframe(columns=columns)
908
+
913
909
  url = "https://management.azure.com/tenants?api-version=2022-12-01"
914
- headers = _get_headers(token_provider=auth.token_provider.get(), audience="azure")
915
910
 
916
- response = requests.get(url, headers=headers)
917
- if response.status_code != 200:
918
- raise FabricHTTPException(response)
911
+ response = _base_api(request=url, client="azure")
919
912
 
920
913
  for v in response.json().get("value", []):
921
914
  d = v.get("domains")
@@ -958,16 +951,19 @@ def create_or_update_resource_group(
958
951
  The name of the region.
959
952
  """
960
953
 
961
- headers = _get_headers(auth.token_provider.get(), audience="azure")
962
954
  url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourcegroups/{resource_group}?api-version=2021-04-01"
963
955
 
964
956
  payload = {
965
957
  "location": region,
966
958
  }
967
959
 
968
- response = requests.put(url, headers=headers, json=payload)
969
- if response.status_code not in [200, 201]:
970
- raise FabricHTTPException(response)
960
+ _base_api(
961
+ request=url,
962
+ client="azure",
963
+ method="put",
964
+ payload=payload,
965
+ status_codes=[200, 201],
966
+ )
971
967
 
972
968
  print(
973
969
  f"{icons.green_dot} The '{resource_group}' resource group has been created/updated."
@@ -1000,7 +996,6 @@ def create_storage_account(
1000
996
  The name of the region.
1001
997
  """
1002
998
 
1003
- headers = _get_headers(auth.token_provider.get(), audience="azure")
1004
999
  url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Storage/storageAccounts/{storage_account}?api-version=2018-02-01"
1005
1000
 
1006
1001
  payload = {
@@ -1009,10 +1004,7 @@ def create_storage_account(
1009
1004
  "location": region,
1010
1005
  }
1011
1006
 
1012
- response = requests.put(url, headers=headers, json=payload)
1013
-
1014
- if response.status_code != 200:
1015
- raise FabricHTTPException(response)
1007
+ _base_api(request=url, client="azure", method="put", payload=payload)
1016
1008
 
1017
1009
  print(
1018
1010
  f"{icons.green_dot} The '{storage_account}' storage account has been created."
@@ -1044,8 +1036,6 @@ def list_storage_accounts(
1044
1036
  A pandas dataframe showing a list of all storage accounts within the subscription (or resource group).
1045
1037
  """
1046
1038
 
1047
- headers = _get_headers(auth.token_provider.get(), audience="azure")
1048
-
1049
1039
  url = f"https://management.azure.com/subscriptions/{azure_subscription_id}"
1050
1040
 
1051
1041
  if resource_group is not None:
@@ -1053,35 +1043,32 @@ def list_storage_accounts(
1053
1043
 
1054
1044
  url += "/providers/Microsoft.Storage/storageAccounts?api-version=2023-05-01"
1055
1045
 
1056
- df = pd.DataFrame(
1057
- columns=[
1058
- "Storage Account Id",
1059
- "Storage Account Name",
1060
- "Kind",
1061
- "Location",
1062
- "Sku Name",
1063
- "Sku Tier",
1064
- "Is HNS Enabled",
1065
- "Creation Time",
1066
- "Web Endpoint",
1067
- "DFS Endpoint",
1068
- "Blob Endpoint",
1069
- "File Endpoint",
1070
- "Queue Endpoint",
1071
- "Table Endpoint",
1072
- "Primary Location",
1073
- "Provisioning State",
1074
- "Secondary Location",
1075
- "Status of Primary",
1076
- "Status of Secondary",
1077
- "Supports HTTPS Traffic Only",
1078
- "Tags",
1079
- ]
1080
- )
1081
- response = requests.get(url, headers=headers)
1046
+ columns = {
1047
+ "Storage Account Id": "string",
1048
+ "Storage Account Name": "string",
1049
+ "Kind": "string",
1050
+ "Location": "string",
1051
+ "Sku Name": "string",
1052
+ "Sku Tier": "string",
1053
+ "Is HNS Enabled": "bool",
1054
+ "Creation Time": "datetime",
1055
+ "Web Endpoint": "string",
1056
+ "DFS Endpoint": "string",
1057
+ "Blob Endpoint": "string",
1058
+ "File Endpoint": "string",
1059
+ "Queue Endpoint": "string",
1060
+ "Table Endpoint": "string",
1061
+ "Primary Location": "string",
1062
+ "Provisioning State": "string",
1063
+ "Secondary Location": "string",
1064
+ "Status of Primary": "string",
1065
+ "Status of Secondary": "string",
1066
+ "Supports HTTPS Traffic Only": "bool",
1067
+ "Tags": "string",
1068
+ }
1069
+ df = _create_dataframe(columns=columns)
1082
1070
 
1083
- if response.status_code != 200:
1084
- raise FabricHTTPException(response)
1071
+ response = _base_api(request=url, client="azure")
1085
1072
 
1086
1073
  for v in response.json().get("value", []):
1087
1074
  p = v.get("properties", {})
@@ -1111,9 +1098,7 @@ def list_storage_accounts(
1111
1098
 
1112
1099
  df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
1113
1100
 
1114
- bool_cols = ["Is HNS Enabled", "Supports HTTPS Traffic Only"]
1115
- df[bool_cols] = df[bool_cols].astype(bool)
1116
- df["Creation Time"] = pd.to_datetime(df["Creation Time"])
1101
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
1117
1102
 
1118
1103
  return df
1119
1104
 
@@ -1142,13 +1127,9 @@ def check_resource_group_existence(
1142
1127
  True/False indicating if the resource group exists or not.
1143
1128
  """
1144
1129
 
1145
- headers = _get_headers(auth.token_provider.get(), audience="azure")
1146
1130
  url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourceGroups/{resource_group}?api-version=2021-04-01"
1147
1131
 
1148
- response = requests.get(url, headers=headers)
1149
-
1150
- if response.status_code not in [200, 204, 404]:
1151
- raise FabricHTTPException(response)
1132
+ response = _base_api(request=url, client="azure", status_codes=[200, 204, 404])
1152
1133
 
1153
1134
  if response.status_code == 200:
1154
1135
  return True
@@ -1184,7 +1165,6 @@ def list_resource_groups(
1184
1165
  A pandas dataframe showing a list of all resource groups within the subscription.
1185
1166
  """
1186
1167
 
1187
- headers = _get_headers(auth.token_provider.get(), audience="azure")
1188
1168
  url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourceGroups?"
1189
1169
 
1190
1170
  if filter is not None:
@@ -1194,11 +1174,14 @@ def list_resource_groups(
1194
1174
 
1195
1175
  url += "api-version=2021-04-01"
1196
1176
 
1197
- df = pd.DataFrame(columns=["Resource Group Name", "Location", "Tags"])
1198
- response = requests.get(url, headers=headers)
1177
+ columns = {
1178
+ "Resource Group Name": "string",
1179
+ "Location": "string",
1180
+ "Tags": "string",
1181
+ }
1182
+ df = _create_dataframe(columns=columns)
1199
1183
 
1200
- if response.status_code != 200:
1201
- raise FabricHTTPException(response)
1184
+ response = _base_api(request=url, client="azure")
1202
1185
 
1203
1186
  for v in response.json().get("value", []):
1204
1187
  new_data = {
@@ -1238,13 +1221,8 @@ def get_resource_group(azure_subscription_id: str, resource_group: str) -> pd.Da
1238
1221
  A pandas dataframe showing details of a specific resource group.
1239
1222
  """
1240
1223
 
1241
- headers = _get_headers(auth.token_provider.get(), audience="azure")
1242
1224
  url = f"https://management.azure.com/subscriptions/{azure_subscription_id}/resourceGroups/{resource_group}?api-version=2021-04-01"
1243
-
1244
- response = requests.get(url, headers=headers)
1245
-
1246
- if response.status_code != 200:
1247
- raise FabricHTTPException(response)
1225
+ response = _base_api(request=url, client="azure")
1248
1226
 
1249
1227
  v = response.json()
1250
1228
  new_data = {