semantic-link-labs 0.12.8__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.
Files changed (243) hide show
  1. semantic_link_labs-0.12.8.dist-info/METADATA +354 -0
  2. semantic_link_labs-0.12.8.dist-info/RECORD +243 -0
  3. semantic_link_labs-0.12.8.dist-info/WHEEL +5 -0
  4. semantic_link_labs-0.12.8.dist-info/licenses/LICENSE +21 -0
  5. semantic_link_labs-0.12.8.dist-info/top_level.txt +1 -0
  6. sempy_labs/__init__.py +606 -0
  7. sempy_labs/_a_lib_info.py +2 -0
  8. sempy_labs/_ai.py +437 -0
  9. sempy_labs/_authentication.py +264 -0
  10. sempy_labs/_bpa_translation/_model/_translations_am-ET.po +869 -0
  11. sempy_labs/_bpa_translation/_model/_translations_ar-AE.po +908 -0
  12. sempy_labs/_bpa_translation/_model/_translations_bg-BG.po +968 -0
  13. sempy_labs/_bpa_translation/_model/_translations_ca-ES.po +963 -0
  14. sempy_labs/_bpa_translation/_model/_translations_cs-CZ.po +943 -0
  15. sempy_labs/_bpa_translation/_model/_translations_da-DK.po +945 -0
  16. sempy_labs/_bpa_translation/_model/_translations_de-DE.po +988 -0
  17. sempy_labs/_bpa_translation/_model/_translations_el-GR.po +993 -0
  18. sempy_labs/_bpa_translation/_model/_translations_es-ES.po +971 -0
  19. sempy_labs/_bpa_translation/_model/_translations_fa-IR.po +933 -0
  20. sempy_labs/_bpa_translation/_model/_translations_fi-FI.po +942 -0
  21. sempy_labs/_bpa_translation/_model/_translations_fr-FR.po +994 -0
  22. sempy_labs/_bpa_translation/_model/_translations_ga-IE.po +967 -0
  23. sempy_labs/_bpa_translation/_model/_translations_he-IL.po +902 -0
  24. sempy_labs/_bpa_translation/_model/_translations_hi-IN.po +944 -0
  25. sempy_labs/_bpa_translation/_model/_translations_hu-HU.po +963 -0
  26. sempy_labs/_bpa_translation/_model/_translations_id-ID.po +946 -0
  27. sempy_labs/_bpa_translation/_model/_translations_is-IS.po +939 -0
  28. sempy_labs/_bpa_translation/_model/_translations_it-IT.po +986 -0
  29. sempy_labs/_bpa_translation/_model/_translations_ja-JP.po +846 -0
  30. sempy_labs/_bpa_translation/_model/_translations_ko-KR.po +839 -0
  31. sempy_labs/_bpa_translation/_model/_translations_mt-MT.po +967 -0
  32. sempy_labs/_bpa_translation/_model/_translations_nl-NL.po +978 -0
  33. sempy_labs/_bpa_translation/_model/_translations_pl-PL.po +962 -0
  34. sempy_labs/_bpa_translation/_model/_translations_pt-BR.po +962 -0
  35. sempy_labs/_bpa_translation/_model/_translations_pt-PT.po +957 -0
  36. sempy_labs/_bpa_translation/_model/_translations_ro-RO.po +968 -0
  37. sempy_labs/_bpa_translation/_model/_translations_ru-RU.po +964 -0
  38. sempy_labs/_bpa_translation/_model/_translations_sk-SK.po +952 -0
  39. sempy_labs/_bpa_translation/_model/_translations_sl-SL.po +950 -0
  40. sempy_labs/_bpa_translation/_model/_translations_sv-SE.po +942 -0
  41. sempy_labs/_bpa_translation/_model/_translations_ta-IN.po +976 -0
  42. sempy_labs/_bpa_translation/_model/_translations_te-IN.po +947 -0
  43. sempy_labs/_bpa_translation/_model/_translations_th-TH.po +924 -0
  44. sempy_labs/_bpa_translation/_model/_translations_tr-TR.po +953 -0
  45. sempy_labs/_bpa_translation/_model/_translations_uk-UA.po +961 -0
  46. sempy_labs/_bpa_translation/_model/_translations_zh-CN.po +804 -0
  47. sempy_labs/_bpa_translation/_model/_translations_zu-ZA.po +969 -0
  48. sempy_labs/_capacities.py +1198 -0
  49. sempy_labs/_capacity_migration.py +660 -0
  50. sempy_labs/_clear_cache.py +351 -0
  51. sempy_labs/_connections.py +610 -0
  52. sempy_labs/_dashboards.py +69 -0
  53. sempy_labs/_data_access_security.py +98 -0
  54. sempy_labs/_data_pipelines.py +162 -0
  55. sempy_labs/_dataflows.py +668 -0
  56. sempy_labs/_dax.py +501 -0
  57. sempy_labs/_daxformatter.py +80 -0
  58. sempy_labs/_delta_analyzer.py +467 -0
  59. sempy_labs/_delta_analyzer_history.py +301 -0
  60. sempy_labs/_dictionary_diffs.py +221 -0
  61. sempy_labs/_documentation.py +147 -0
  62. sempy_labs/_domains.py +51 -0
  63. sempy_labs/_eventhouses.py +182 -0
  64. sempy_labs/_external_data_shares.py +230 -0
  65. sempy_labs/_gateways.py +521 -0
  66. sempy_labs/_generate_semantic_model.py +521 -0
  67. sempy_labs/_get_connection_string.py +84 -0
  68. sempy_labs/_git.py +543 -0
  69. sempy_labs/_graphQL.py +90 -0
  70. sempy_labs/_helper_functions.py +2833 -0
  71. sempy_labs/_icons.py +149 -0
  72. sempy_labs/_job_scheduler.py +609 -0
  73. sempy_labs/_kql_databases.py +149 -0
  74. sempy_labs/_kql_querysets.py +124 -0
  75. sempy_labs/_kusto.py +137 -0
  76. sempy_labs/_labels.py +124 -0
  77. sempy_labs/_list_functions.py +1720 -0
  78. sempy_labs/_managed_private_endpoints.py +253 -0
  79. sempy_labs/_mirrored_databases.py +416 -0
  80. sempy_labs/_mirrored_warehouses.py +60 -0
  81. sempy_labs/_ml_experiments.py +113 -0
  82. sempy_labs/_model_auto_build.py +140 -0
  83. sempy_labs/_model_bpa.py +557 -0
  84. sempy_labs/_model_bpa_bulk.py +378 -0
  85. sempy_labs/_model_bpa_rules.py +859 -0
  86. sempy_labs/_model_dependencies.py +343 -0
  87. sempy_labs/_mounted_data_factories.py +123 -0
  88. sempy_labs/_notebooks.py +441 -0
  89. sempy_labs/_one_lake_integration.py +151 -0
  90. sempy_labs/_onelake.py +131 -0
  91. sempy_labs/_query_scale_out.py +433 -0
  92. sempy_labs/_refresh_semantic_model.py +435 -0
  93. sempy_labs/_semantic_models.py +468 -0
  94. sempy_labs/_spark.py +455 -0
  95. sempy_labs/_sql.py +241 -0
  96. sempy_labs/_sql_audit_settings.py +207 -0
  97. sempy_labs/_sql_endpoints.py +214 -0
  98. sempy_labs/_tags.py +201 -0
  99. sempy_labs/_translations.py +43 -0
  100. sempy_labs/_user_delegation_key.py +44 -0
  101. sempy_labs/_utils.py +79 -0
  102. sempy_labs/_vertipaq.py +1021 -0
  103. sempy_labs/_vpax.py +388 -0
  104. sempy_labs/_warehouses.py +234 -0
  105. sempy_labs/_workloads.py +140 -0
  106. sempy_labs/_workspace_identity.py +72 -0
  107. sempy_labs/_workspaces.py +595 -0
  108. sempy_labs/admin/__init__.py +170 -0
  109. sempy_labs/admin/_activities.py +167 -0
  110. sempy_labs/admin/_apps.py +145 -0
  111. sempy_labs/admin/_artifacts.py +65 -0
  112. sempy_labs/admin/_basic_functions.py +463 -0
  113. sempy_labs/admin/_capacities.py +508 -0
  114. sempy_labs/admin/_dataflows.py +45 -0
  115. sempy_labs/admin/_datasets.py +186 -0
  116. sempy_labs/admin/_domains.py +522 -0
  117. sempy_labs/admin/_external_data_share.py +100 -0
  118. sempy_labs/admin/_git.py +72 -0
  119. sempy_labs/admin/_items.py +265 -0
  120. sempy_labs/admin/_labels.py +211 -0
  121. sempy_labs/admin/_reports.py +241 -0
  122. sempy_labs/admin/_scanner.py +118 -0
  123. sempy_labs/admin/_shared.py +82 -0
  124. sempy_labs/admin/_sharing_links.py +110 -0
  125. sempy_labs/admin/_tags.py +131 -0
  126. sempy_labs/admin/_tenant.py +503 -0
  127. sempy_labs/admin/_tenant_keys.py +89 -0
  128. sempy_labs/admin/_users.py +140 -0
  129. sempy_labs/admin/_workspaces.py +236 -0
  130. sempy_labs/deployment_pipeline/__init__.py +23 -0
  131. sempy_labs/deployment_pipeline/_items.py +580 -0
  132. sempy_labs/directlake/__init__.py +57 -0
  133. sempy_labs/directlake/_autosync.py +58 -0
  134. sempy_labs/directlake/_directlake_schema_compare.py +120 -0
  135. sempy_labs/directlake/_directlake_schema_sync.py +161 -0
  136. sempy_labs/directlake/_dl_helper.py +274 -0
  137. sempy_labs/directlake/_generate_shared_expression.py +94 -0
  138. sempy_labs/directlake/_get_directlake_lakehouse.py +62 -0
  139. sempy_labs/directlake/_get_shared_expression.py +34 -0
  140. sempy_labs/directlake/_guardrails.py +96 -0
  141. sempy_labs/directlake/_list_directlake_model_calc_tables.py +70 -0
  142. sempy_labs/directlake/_show_unsupported_directlake_objects.py +90 -0
  143. sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +239 -0
  144. sempy_labs/directlake/_update_directlake_partition_entity.py +259 -0
  145. sempy_labs/directlake/_warm_cache.py +236 -0
  146. sempy_labs/dotnet_lib/dotnet.runtime.config.json +10 -0
  147. sempy_labs/environment/__init__.py +23 -0
  148. sempy_labs/environment/_items.py +212 -0
  149. sempy_labs/environment/_pubstage.py +223 -0
  150. sempy_labs/eventstream/__init__.py +37 -0
  151. sempy_labs/eventstream/_items.py +263 -0
  152. sempy_labs/eventstream/_topology.py +652 -0
  153. sempy_labs/graph/__init__.py +59 -0
  154. sempy_labs/graph/_groups.py +651 -0
  155. sempy_labs/graph/_sensitivity_labels.py +120 -0
  156. sempy_labs/graph/_teams.py +125 -0
  157. sempy_labs/graph/_user_licenses.py +96 -0
  158. sempy_labs/graph/_users.py +516 -0
  159. sempy_labs/graph_model/__init__.py +15 -0
  160. sempy_labs/graph_model/_background_jobs.py +63 -0
  161. sempy_labs/graph_model/_items.py +149 -0
  162. sempy_labs/lakehouse/__init__.py +67 -0
  163. sempy_labs/lakehouse/_blobs.py +247 -0
  164. sempy_labs/lakehouse/_get_lakehouse_columns.py +102 -0
  165. sempy_labs/lakehouse/_get_lakehouse_tables.py +274 -0
  166. sempy_labs/lakehouse/_helper.py +250 -0
  167. sempy_labs/lakehouse/_lakehouse.py +351 -0
  168. sempy_labs/lakehouse/_livy_sessions.py +143 -0
  169. sempy_labs/lakehouse/_materialized_lake_views.py +157 -0
  170. sempy_labs/lakehouse/_partitioning.py +165 -0
  171. sempy_labs/lakehouse/_schemas.py +217 -0
  172. sempy_labs/lakehouse/_shortcuts.py +440 -0
  173. sempy_labs/migration/__init__.py +35 -0
  174. sempy_labs/migration/_create_pqt_file.py +238 -0
  175. sempy_labs/migration/_direct_lake_to_import.py +105 -0
  176. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +398 -0
  177. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +148 -0
  178. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +533 -0
  179. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +172 -0
  180. sempy_labs/migration/_migration_validation.py +71 -0
  181. sempy_labs/migration/_refresh_calc_tables.py +131 -0
  182. sempy_labs/mirrored_azure_databricks_catalog/__init__.py +15 -0
  183. sempy_labs/mirrored_azure_databricks_catalog/_discover.py +213 -0
  184. sempy_labs/mirrored_azure_databricks_catalog/_refresh_catalog_metadata.py +45 -0
  185. sempy_labs/ml_model/__init__.py +23 -0
  186. sempy_labs/ml_model/_functions.py +427 -0
  187. sempy_labs/report/_BPAReportTemplate.json +232 -0
  188. sempy_labs/report/__init__.py +55 -0
  189. sempy_labs/report/_bpareporttemplate/.pbi/localSettings.json +9 -0
  190. sempy_labs/report/_bpareporttemplate/.platform +11 -0
  191. sempy_labs/report/_bpareporttemplate/StaticResources/SharedResources/BaseThemes/CY24SU06.json +710 -0
  192. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/page.json +11 -0
  193. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/1b08bce3bebabb0a27a8/visual.json +191 -0
  194. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/2f22ddb70c301693c165/visual.json +438 -0
  195. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/3b1182230aa6c600b43a/visual.json +127 -0
  196. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/58577ba6380c69891500/visual.json +576 -0
  197. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/a2a8fa5028b3b776c96c/visual.json +207 -0
  198. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/adfd47ef30652707b987/visual.json +506 -0
  199. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/b6a80ee459e716e170b1/visual.json +127 -0
  200. sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/ce3130a721c020cc3d81/visual.json +513 -0
  201. sempy_labs/report/_bpareporttemplate/definition/pages/92735ae19b31712208ad/page.json +8 -0
  202. sempy_labs/report/_bpareporttemplate/definition/pages/92735ae19b31712208ad/visuals/66e60dfb526437cd78d1/visual.json +112 -0
  203. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/page.json +11 -0
  204. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/07deb8bce824e1be37d7/visual.json +513 -0
  205. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0b1c68838818b32ad03b/visual.json +352 -0
  206. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0c171de9d2683d10b930/visual.json +37 -0
  207. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0efa01be0510e40a645e/visual.json +542 -0
  208. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/6bf2f0eb830ab53cc668/visual.json +221 -0
  209. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/88d8141cb8500b60030c/visual.json +127 -0
  210. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/a753273590beed656a03/visual.json +576 -0
  211. sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/b8fdc82cddd61ac447bc/visual.json +127 -0
  212. sempy_labs/report/_bpareporttemplate/definition/pages/d37dce724a0ccc30044b/page.json +9 -0
  213. sempy_labs/report/_bpareporttemplate/definition/pages/d37dce724a0ccc30044b/visuals/ce8532a7e25020271077/visual.json +38 -0
  214. sempy_labs/report/_bpareporttemplate/definition/pages/pages.json +10 -0
  215. sempy_labs/report/_bpareporttemplate/definition/report.json +176 -0
  216. sempy_labs/report/_bpareporttemplate/definition/version.json +4 -0
  217. sempy_labs/report/_bpareporttemplate/definition.pbir +14 -0
  218. sempy_labs/report/_download_report.py +76 -0
  219. sempy_labs/report/_export_report.py +257 -0
  220. sempy_labs/report/_generate_report.py +427 -0
  221. sempy_labs/report/_paginated.py +76 -0
  222. sempy_labs/report/_report_bpa.py +354 -0
  223. sempy_labs/report/_report_bpa_rules.py +115 -0
  224. sempy_labs/report/_report_functions.py +581 -0
  225. sempy_labs/report/_report_helper.py +227 -0
  226. sempy_labs/report/_report_list_functions.py +110 -0
  227. sempy_labs/report/_report_rebind.py +149 -0
  228. sempy_labs/report/_reportwrapper.py +3100 -0
  229. sempy_labs/report/_save_report.py +147 -0
  230. sempy_labs/snowflake_database/__init__.py +10 -0
  231. sempy_labs/snowflake_database/_items.py +105 -0
  232. sempy_labs/sql_database/__init__.py +21 -0
  233. sempy_labs/sql_database/_items.py +201 -0
  234. sempy_labs/sql_database/_mirroring.py +79 -0
  235. sempy_labs/theme/__init__.py +12 -0
  236. sempy_labs/theme/_org_themes.py +129 -0
  237. sempy_labs/tom/__init__.py +3 -0
  238. sempy_labs/tom/_model.py +5977 -0
  239. sempy_labs/variable_library/__init__.py +19 -0
  240. sempy_labs/variable_library/_functions.py +403 -0
  241. sempy_labs/warehouse/__init__.py +28 -0
  242. sempy_labs/warehouse/_items.py +234 -0
  243. sempy_labs/warehouse/_restore_points.py +309 -0
sempy_labs/_git.py ADDED
@@ -0,0 +1,543 @@
1
+ import pandas as pd
2
+ import sempy_labs._icons as icons
3
+ from typing import Optional, List
4
+ from sempy_labs._helper_functions import (
5
+ _update_dataframe_datatypes,
6
+ resolve_workspace_id,
7
+ resolve_workspace_name_and_id,
8
+ _base_api,
9
+ _create_dataframe,
10
+ )
11
+ from uuid import UUID
12
+ from sempy._utils._log import log
13
+
14
+
15
+ @log
16
+ def connect_workspace_to_azure_dev_ops(
17
+ organization_name: str,
18
+ project_name: str,
19
+ repository_name: str,
20
+ branch_name: str,
21
+ directory_name: str,
22
+ workspace: Optional[str | UUID] = None,
23
+ ):
24
+ """
25
+ Connects a workspace to an Azure DevOps git repository.
26
+
27
+ This is a wrapper function for the following API: `Git - Connect <https://learn.microsoft.com/rest/api/fabric/core/git/connect>`_.
28
+
29
+ Parameters
30
+ ----------
31
+ organization_name : str
32
+ The organization name.
33
+ project_name : str
34
+ The project name.
35
+ repository_name : str
36
+ The repository name.
37
+ branch_name : str
38
+ The branch name.
39
+ directory_name : str
40
+ The directory name.
41
+ workspace : str | uuid.UUID, default=None
42
+ The Fabric workspace name or ID.
43
+ Defaults to None which resolves to the workspace of the attached lakehouse
44
+ or if no lakehouse attached, resolves to the workspace of the notebook.
45
+ """
46
+
47
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
48
+
49
+ payload = {
50
+ "gitProviderDetails": {
51
+ "organizationName": organization_name,
52
+ "projectName": project_name,
53
+ "gitProviderType": "AzureDevOps",
54
+ "repositoryName": repository_name,
55
+ "branchName": branch_name,
56
+ "directoryName": directory_name,
57
+ }
58
+ }
59
+
60
+ _base_api(
61
+ request=f"/v1/workspaces/{workspace_id}/git/connect",
62
+ payload=payload,
63
+ method="post",
64
+ )
65
+
66
+ print(
67
+ f"{icons.green_dot} The '{workspace_name}' workspace has been connected to the '{project_name}' Git project in Azure DevOps within the '{repository_name}' repository."
68
+ )
69
+
70
+
71
+ @log
72
+ def connect_workspace_to_github(
73
+ owner_name: str,
74
+ repository_name: str,
75
+ branch_name: str,
76
+ directory_name: str,
77
+ connection_id: UUID,
78
+ source: str = "ConfiguredConnection",
79
+ workspace: Optional[str | UUID] = None,
80
+ ):
81
+ """
82
+ Connects a workspace to a GitHub git repository.
83
+
84
+ This is a wrapper function for the following API: `Git - Connect <https://learn.microsoft.com/rest/api/fabric/core/git/connect>`_.
85
+
86
+ Parameters
87
+ ----------
88
+ owner_name : str
89
+ The owner name.
90
+ repository_name : str
91
+ The repository name.
92
+ branch_name : str
93
+ The branch name.
94
+ directory_name : str
95
+ The directory name.
96
+ source : str, default="ConfiguredConnection"
97
+ The Git credentials source.
98
+ connection_id : uuid.UUID
99
+ The object ID of the connection.
100
+ workspace : str | uuid.UUID, default=None
101
+ The Fabric workspace name or ID.
102
+ Defaults to None which resolves to the workspace of the attached lakehouse
103
+ or if no lakehouse attached, resolves to the workspace of the notebook.
104
+ """
105
+
106
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
107
+
108
+ payload = {
109
+ "gitProviderDetails": {
110
+ "ownerName": owner_name,
111
+ "gitProviderType": "GitHub",
112
+ "repositoryName": repository_name,
113
+ "branchName": branch_name,
114
+ "directoryName": directory_name,
115
+ },
116
+ "myGitCredentials": {
117
+ "source": source,
118
+ "connectionId": connection_id,
119
+ },
120
+ }
121
+
122
+ _base_api(
123
+ request=f"/v1/workspaces/{workspace_id}/git/connect",
124
+ payload=payload,
125
+ method="post",
126
+ )
127
+
128
+ print(
129
+ f"{icons.green_dot} The '{workspace_name}' workspace has been connected to the '{repository_name}' GitHub repository."
130
+ )
131
+
132
+
133
+ @log
134
+ def disconnect_workspace_from_git(workspace: Optional[str | UUID] = None):
135
+ """
136
+ Disconnects a workspace from a git repository.
137
+
138
+ This is a wrapper function for the following API: `Git - Disconnect <https://learn.microsoft.com/rest/api/fabric/core/git/disconnect>`_.
139
+
140
+ Parameters
141
+ ----------
142
+ workspace : str | uuid.UUID, default=None
143
+ The Fabric workspace name or ID.
144
+ Defaults to None which resolves to the workspace of the attached lakehouse
145
+ or if no lakehouse attached, resolves to the workspace of the notebook.
146
+ """
147
+
148
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
149
+
150
+ _base_api(request=f"/v1/workspaces/{workspace_id}/git/disconnect", method="post")
151
+
152
+ print(
153
+ f"{icons.green_dot} The '{workspace_name}' workspace has been disconnected from Git."
154
+ )
155
+
156
+
157
+ @log
158
+ def get_git_status(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
159
+ """
160
+ Obtains the Git status of items in the workspace, that can be committed to Git.
161
+
162
+ This is a wrapper function for the following API: `Git - Get Status <https://learn.microsoft.com/rest/api/fabric/core/git/get-status>`_.
163
+
164
+ Parameters
165
+ ----------
166
+ workspace : str | uuid.UUID, default=None
167
+ The Fabric workspace name or ID.
168
+ Defaults to None which resolves to the workspace of the attached lakehouse
169
+ or if no lakehouse attached, resolves to the workspace of the notebook.
170
+
171
+ Returns
172
+ -------
173
+ pandas.DataFrame
174
+ A pandas dataframe showing the Git status of items in the workspace.
175
+ """
176
+
177
+ workspace_id = resolve_workspace_id(workspace)
178
+
179
+ columns = {
180
+ "Workspace Head": "str",
181
+ "Remote Commit Hash": "str",
182
+ "Object ID": "str",
183
+ "Logical ID": "str",
184
+ "Item Type": "str",
185
+ "Item Name": "str",
186
+ "Workspace Change": "str",
187
+ "Remote Change": "str",
188
+ "Conflict Type": "str",
189
+ }
190
+
191
+ df = _create_dataframe(columns=columns)
192
+
193
+ result = _base_api(
194
+ request=f"/v1/workspaces/{workspace_id}/git/status",
195
+ lro_return_json=True,
196
+ status_codes=None,
197
+ )
198
+
199
+ rows = []
200
+ for changes in result.get("changes", []):
201
+ item_metadata = changes.get("itemMetadata", {})
202
+ item_identifier = item_metadata.get("itemIdentifier", {})
203
+
204
+ rows.append(
205
+ {
206
+ "Workspace Head": result.get("workspaceHead"),
207
+ "Remote Commit Hash": result.get("remoteCommitHash"),
208
+ "Object ID": item_identifier.get("objectId"),
209
+ "Logical ID": item_identifier.get("logicalId"),
210
+ "Item Type": item_metadata.get("itemType"),
211
+ "Item Name": item_metadata.get("displayName"),
212
+ "Remote Change": changes.get("remoteChange"),
213
+ "Workspace Change": changes.get("workspaceChange"),
214
+ "Conflict Type": changes.get("conflictType"),
215
+ }
216
+ )
217
+
218
+ if rows:
219
+ df = pd.DataFrame(rows, columns=columns.keys())
220
+
221
+ return df
222
+
223
+
224
+ @log
225
+ def get_git_connection(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
226
+ """
227
+ Obtains the Git status of items in the workspace, that can be committed to Git.
228
+
229
+ This is a wrapper function for the following API: `Git - Get Connection <https://learn.microsoft.com/rest/api/fabric/core/git/get-connection>`_.
230
+
231
+ Parameters
232
+ ----------
233
+ workspace : str | uuid.UUID, default=None
234
+ The Fabric workspace name or ID.
235
+ Defaults to None which resolves to the workspace of the attached lakehouse
236
+ or if no lakehouse attached, resolves to the workspace of the notebook.
237
+
238
+ Returns
239
+ -------
240
+ pandas.DataFrame
241
+ A pandas dataframe showing the Git status of items in the workspace.
242
+ """
243
+
244
+ workspace_id = resolve_workspace_id(workspace)
245
+
246
+ columns = {
247
+ "Organization Name": "str",
248
+ "Project Name": "str",
249
+ "Git Provider Type": "str",
250
+ "Repository Name": "str",
251
+ "Branch Name": "str",
252
+ "Directory Name": "str",
253
+ "Workspace Head": "str",
254
+ "Last Sync Time": "datetime",
255
+ "Git Connection State": "str",
256
+ }
257
+
258
+ df = _create_dataframe(columns=columns)
259
+
260
+ response = _base_api(request=f"/v1/workspaces/{workspace_id}/git/connection")
261
+
262
+ r = response.json()
263
+ provider_details = r.get("gitProviderDetails", {})
264
+ sync_details = r.get("gitSyncDetails", {})
265
+
266
+ new_data = {
267
+ "Organization Name": provider_details.get("organizationName"),
268
+ "Project Name": provider_details.get("projectName"),
269
+ "Git Provider Type": provider_details.get("gitProviderType"),
270
+ "Repository Name": provider_details.get("repositoryName"),
271
+ "Branch Name": provider_details.get("branchName"),
272
+ "Directory Name": provider_details.get("directoryName"),
273
+ "Workspace Head": sync_details.get("head"),
274
+ "Last Sync Time": sync_details.get("lastSyncTime"),
275
+ "Git Connection State": r.get("gitConnectionState"),
276
+ }
277
+ df = pd.DataFrame([new_data], columns=columns.keys())
278
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
279
+
280
+ return df
281
+
282
+
283
+ @log
284
+ def initialize_git_connection(workspace: Optional[str | UUID] = None) -> str:
285
+ """
286
+ Initializes a connection for a workspace that is connected to Git.
287
+
288
+ This is a wrapper function for the following API: `Git - Initialize Connection <https://learn.microsoft.com/rest/api/fabric/core/git/initialize-connection>`_.
289
+
290
+ Parameters
291
+ ----------
292
+ workspace : str | uuid.UUID, default=None
293
+ The Fabric workspace name or ID.
294
+ Defaults to None which resolves to the workspace of the attached lakehouse
295
+ or if no lakehouse attached, resolves to the workspace of the notebook.
296
+
297
+ Returns
298
+ -------
299
+ str
300
+ Remote full SHA commit hash.
301
+ """
302
+
303
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
304
+
305
+ response_json = _base_api(
306
+ request=f"/v1/workspaces/{workspace_id}/git/initializeConnection",
307
+ method="post",
308
+ lro_return_json=True,
309
+ status_codes=None,
310
+ )
311
+
312
+ print(
313
+ f"{icons.green_dot} The '{workspace_name}' workspace git connection has been initialized."
314
+ )
315
+
316
+ return response_json.get("remoteCommitHash")
317
+
318
+
319
+ @log
320
+ def commit_to_git(
321
+ comment: str,
322
+ item_ids: UUID | List[UUID] = None,
323
+ workspace: Optional[str | UUID] = None,
324
+ ):
325
+ """
326
+ Commits all or a selection of items within a workspace to Git.
327
+
328
+ This is a wrapper function for the following API: `Git - Commit to Git <https://learn.microsoft.com/rest/api/fabric/core/git/commit-to-git>`_.
329
+
330
+ Parameters
331
+ ----------
332
+ comment : str
333
+ The Git commit comment.
334
+ item_ids : uuid.UUID | List[uuid.UUID], default=None
335
+ A list of item Ids to commit to Git.
336
+ Defaults to None which commits all items to Git.
337
+ workspace : str | uuid.UUID, default=None
338
+ The Fabric workspace name or ID.
339
+ Defaults to None which resolves to the workspace of the attached lakehouse
340
+ or if no lakehouse attached, resolves to the workspace of the notebook.
341
+ """
342
+
343
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
344
+
345
+ gs = get_git_status(workspace=workspace_id)
346
+ if not gs.empty:
347
+ workspace_head = gs["Workspace Head"].iloc[0]
348
+
349
+ if item_ids is None:
350
+ commit_mode = "All"
351
+ else:
352
+ commit_mode = "Selective"
353
+
354
+ if isinstance(item_ids, str):
355
+ item_ids = [item_ids]
356
+
357
+ payload = {
358
+ "mode": commit_mode,
359
+ "workspaceHead": workspace_head,
360
+ "comment": comment,
361
+ }
362
+
363
+ if item_ids is not None:
364
+ payload["items"] = [{"objectId": item_id} for item_id in item_ids]
365
+
366
+ _base_api(
367
+ request=f"/v1/workspaces/{workspace_id}/git/commitToGit",
368
+ method="post",
369
+ payload=payload,
370
+ lro_return_status_code=True,
371
+ status_codes=None,
372
+ )
373
+
374
+ if commit_mode == "All":
375
+ print(
376
+ f"{icons.green_dot} All items within the '{workspace_name}' workspace have been committed to Git."
377
+ )
378
+ else:
379
+ print(
380
+ f"{icons.green_dot} The {item_ids} items within the '{workspace_name}' workspace have been committed to Git."
381
+ )
382
+ else:
383
+ print(
384
+ f"{icons.info} Git already up to date: no modified items found within the '{workspace_name}' workspace."
385
+ )
386
+
387
+
388
+ @log
389
+ def update_from_git(
390
+ remote_commit_hash: str,
391
+ conflict_resolution_policy: str,
392
+ workspace_head: Optional[str] = None,
393
+ allow_override: bool = False,
394
+ workspace: Optional[str | UUID] = None,
395
+ ):
396
+ """
397
+ Updates the workspace with commits pushed to the connected branch.
398
+
399
+ This is a wrapper function for the following API: `Git - Update From Git <https://learn.microsoft.com/rest/api/fabric/core/git/update-from-git>`_.
400
+
401
+ Parameters
402
+ ----------
403
+ remote_commit_hash : str
404
+ Remote full SHA commit hash.
405
+ confilict_resolution_policy : str
406
+ The `conflict resolution policy <https://learn.microsoft.com/rest/api/fabric/core/git/update-from-git?tabs=HTTP#conflictresolutionpolicy>`_.
407
+ workspace_head : str
408
+ Full SHA hash that the workspace is synced to. This value may be null only after Initialize Connection.
409
+ In other cases, the system will validate that the given value is aligned with the head known to the system.
410
+ allow_override : bool, default=False
411
+ User consent to override incoming items during the update from Git process. When incoming items are present and the allow override items is not specified or is provided as false, the update operation will not start. Default value is false.
412
+ workspace : str | uuid.UUID, default=None
413
+ The Fabric workspace name or ID.
414
+ Defaults to None which resolves to the workspace of the attached lakehouse
415
+ or if no lakehouse attached, resolves to the workspace of the notebook.
416
+ """
417
+
418
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
419
+
420
+ conflict_resolution_policies = ["PreferWorkspace", "PreferRemote"]
421
+ if "remote" in [policy.lower() for policy in conflict_resolution_policies]:
422
+ conflict_resolution_policies = "PreferRemote"
423
+ elif "workspace" in [policy.lower() for policy in conflict_resolution_policies]:
424
+ conflict_resolution_policies = "PreferWorkspace"
425
+
426
+ if conflict_resolution_policy not in conflict_resolution_policies:
427
+ raise ValueError(
428
+ f"{icons.red_dot} Invalid conflict resolution policy. Valid options: {conflict_resolution_policies}."
429
+ )
430
+
431
+ payload = {}
432
+ payload["remoteCommitHash"] = remote_commit_hash
433
+ payload["conflictResolution"] = {
434
+ "conflictResolutionType": "Workspace",
435
+ "conflictResolutionPolicy": conflict_resolution_policy,
436
+ }
437
+
438
+ if workspace_head is not None:
439
+ payload["workspaceHead"] = workspace_head
440
+ if allow_override is not None:
441
+ payload["options"] = {"allowOverrideItems": allow_override}
442
+
443
+ _base_api(
444
+ request=f"/v1/workspaces/{workspace_id}/git/updateFromGit",
445
+ method="post",
446
+ payload=payload,
447
+ lro_return_status_code=True,
448
+ status_codes=None,
449
+ )
450
+
451
+ print(
452
+ f"{icons.green_dot} The '{workspace_name}' workspace has been updated with commits pushed to the connected branch."
453
+ )
454
+
455
+
456
+ @log
457
+ def get_my_git_credentials(
458
+ workspace: Optional[str | UUID] = None,
459
+ ) -> pd.DataFrame:
460
+ """
461
+ Returns the user's Git credentials configuration details.
462
+
463
+ This is a wrapper function for the following API: `Git - Get My Git Credentials <https://learn.microsoft.com/rest/api/fabric/core/git/get-my-git-credentials>`_.
464
+
465
+ Parameters
466
+ ----------
467
+ workspace : str | uuid.UUID, default=None
468
+ The workspace name or ID.
469
+ Defaults to None which resolves to the workspace of the attached lakehouse
470
+ or if no lakehouse attached, resolves to the workspace of the notebook.
471
+
472
+ Returns
473
+ -------
474
+ pandas.DataFrame
475
+ A pandas dataframe showing the user's Git credentials configuration details.
476
+ """
477
+
478
+ workspace_id = resolve_workspace_id(workspace)
479
+
480
+ columns = {
481
+ "Source": "string",
482
+ }
483
+
484
+ df = _create_dataframe(columns)
485
+
486
+ response = _base_api(request=f"/v1/workspaces/{workspace_id}/git/myGitCredentials")
487
+
488
+ r = response.json()
489
+ new_data = {
490
+ "Source": r.get("source"),
491
+ "Connection Id": r.get("connectionId"),
492
+ }
493
+ df = pd.DataFrame([new_data], columns=columns.keys())
494
+
495
+ return df
496
+
497
+
498
+ @log
499
+ def update_my_git_credentials(
500
+ source: str,
501
+ connection_id: Optional[UUID] = None,
502
+ workspace: Optional[str | UUID] = None,
503
+ ):
504
+ """
505
+ Updates the user's Git credentials configuration details.
506
+
507
+ This is a wrapper function for the following API: `Git - Update My Git Credentials <https://learn.microsoft.com/rest/api/fabric/core/git/update-my-git-credentials>`_.
508
+
509
+ Parameters
510
+ ----------
511
+ source : str
512
+ The Git credentials source. Valid options: 'Automatic', 'ConfiguredConnection', 'None'.
513
+ connection_id : UUID, default=None
514
+ The object ID of the connection. Valid only for the 'ConfiguredConnection' source.
515
+ workspace : str | uuid.UUID, default=None
516
+ The workspace name or ID.
517
+ Defaults to None which resolves to the workspace of the attached lakehouse
518
+ or if no lakehouse attached, resolves to the workspace of the notebook.
519
+ """
520
+
521
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
522
+
523
+ if source == "ConfiguredConnection" and connection_id is None:
524
+ raise ValueError(
525
+ f"{icons.red_dot} The 'ConfiguredConnection' source requires a connection_id."
526
+ )
527
+
528
+ payload = {
529
+ "source": source,
530
+ }
531
+
532
+ if connection_id is not None:
533
+ payload["connectionId"] = connection_id
534
+
535
+ _base_api(
536
+ request=f"/v1/workspaces/{workspace_id}/git/myGitCredentials",
537
+ method="patch",
538
+ payload=payload,
539
+ )
540
+
541
+ print(
542
+ f"{icons.green_dot} The user's Git credentials have been updated accordingly."
543
+ )
sempy_labs/_graphQL.py ADDED
@@ -0,0 +1,90 @@
1
+ import pandas as pd
2
+ from uuid import UUID
3
+ from typing import Optional
4
+ from sempy_labs._helper_functions import (
5
+ _base_api,
6
+ _create_dataframe,
7
+ resolve_workspace_id,
8
+ create_item,
9
+ )
10
+ from sempy._utils._log import log
11
+
12
+
13
+ @log
14
+ def list_graphql_apis(workspace: Optional[str | UUID]) -> pd.DataFrame:
15
+ """
16
+ Shows the Graph QL APIs within a workspace.
17
+
18
+ This is a wrapper function for the following API: `Items - List GraphQLApis <https://learn.microsoft.com/rest/api/fabric/graphqlapi/items/list-graphqlapi-s>`_.
19
+
20
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
21
+
22
+ Parameters
23
+ ----------
24
+ workspace : str | uuid.UUID, default=None
25
+ The Fabric workspace name or ID.
26
+ Defaults to None which resolves to the workspace of the attached lakehouse
27
+ or if no lakehouse attached, resolves to the workspace of the notebook.
28
+
29
+ Returns
30
+ -------
31
+ pandas.DataFrame
32
+ A pandas dataframe showing the GraphQL APIs within a workspace.
33
+ """
34
+
35
+ columns = {
36
+ "GraphQL API Name": "string",
37
+ "GraphQL API Id": "string",
38
+ "Description": "string",
39
+ }
40
+ df = _create_dataframe(columns=columns)
41
+
42
+ workspace_id = resolve_workspace_id(workspace)
43
+
44
+ responses = _base_api(
45
+ request=f"/v1/workspaces/{workspace_id}/GraphQLApis",
46
+ uses_pagination=True,
47
+ client="fabric_sp",
48
+ )
49
+
50
+ rows = []
51
+ for r in responses:
52
+ for v in r.get("value", []):
53
+ rows.append(
54
+ {
55
+ "GraphQL API Name": v.get("displayName"),
56
+ "GraphQL API Id": v.get("id"),
57
+ "Description": v.get("description"),
58
+ }
59
+ )
60
+
61
+ if rows:
62
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
63
+
64
+ return df
65
+
66
+
67
+ @log
68
+ def create_graphql_api(
69
+ name: str, description: Optional[str] = None, workspace: Optional[str | UUID] = None
70
+ ):
71
+ """
72
+ Creates a GraphQL API.
73
+
74
+ This is a wrapper function for the following API: `Items - Create GraphQLApi <https://learn.microsoft.com/rest/api/fabric/graphqlapi/items/create-graphqlapi>`_.
75
+
76
+ Parameters
77
+ ----------
78
+ name: str
79
+ Name of the GraphQL API.
80
+ description : str, default=None
81
+ A description of the GraphQL API.
82
+ workspace : str | uuid.UUID, default=None
83
+ The Fabric workspace name or ID.
84
+ Defaults to None which resolves to the workspace of the attached lakehouse
85
+ or if no lakehouse attached, resolves to the workspace of the notebook.
86
+ """
87
+
88
+ create_item(
89
+ name=name, description=description, type="GraphQLApi", workspace=workspace
90
+ )