msfabricpysdkcore 0.2.7__tar.gz → 0.2.9__tar.gz
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.
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/PKG-INFO +37 -3
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/README.md +36 -2
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/client.py +2 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/coreapi.py +55 -10
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/item.py +5 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/__init__.py +0 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_admin_apis.py +174 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_admin_tags.py +46 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_apache_airflow_job.py +60 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_connection.py +111 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_copy_jobs.py +60 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_dataflows.py +60 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_datapipelines.py +60 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_deployment_pipelinev2.py +135 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_digital_twin_builder.py +60 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_domains.py +119 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_environments.py +121 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_evenstreams.py +57 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_eventhouses.py +63 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_eventstream_topology.py +82 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_external_data_shares.py +51 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_fabric_azure_client.py +80 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_folders.py +56 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_gateways.py +99 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_git.py +66 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_graphqlapi.py +44 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_items.py +97 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_jobs.py +98 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_kql_dashboards.py +63 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_kql_queryset.py +60 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_kqldatabases.py +56 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_lakehouse.py +89 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_managed_private_endpoints.py +62 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_mirrored_azuredatabricks_catalog.py +81 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_mirroreddatabases.py +80 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_ml_experiments.py +45 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_ml_models.py +46 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_mounted_adf.py +64 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_notebooks.py +58 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +63 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_other_items.py +45 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_reflex.py +56 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_reports.py +56 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_semantic_model.py +56 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_shortcuts.py +59 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_spark.py +91 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_sparkjobdefinition.py +55 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_sql_endpoint.py +28 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_sqldatabases.py +45 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_tags.py +28 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_variable_libary.py +61 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_warehouses.py +50 -0
- msfabricpysdkcore-0.2.9/msfabricpysdkcore/tests/test_workspaces_capacities.py +159 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/workspace.py +28 -7
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore.egg-info/PKG-INFO +37 -3
- msfabricpysdkcore-0.2.9/msfabricpysdkcore.egg-info/SOURCES.txt +82 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/pyproject.toml +1 -1
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/setup.py +1 -1
- msfabricpysdkcore-0.2.7/msfabricpysdkcore.egg-info/SOURCES.txt +0 -34
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/LICENSE +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/__init__.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/admin_item.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/admin_workspace.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/adminapi.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/auth.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/capacity.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/deployment_pipeline.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/domain.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/environment.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/eventstream.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/fabric_azure_capacity.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/fabric_azure_client.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/folder.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/job_instance.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/lakehouse.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/long_running_operation.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/onelakeshortcut.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/otheritems.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/spark_custom_pool.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/util/__init__.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore/util/logger.py +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore.egg-info/requires.txt +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
- {msfabricpysdkcore-0.2.7 → msfabricpysdkcore-0.2.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: msfabricpysdkcore
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.9
|
4
4
|
Summary: A Python SDK for Microsoft Fabric
|
5
5
|
Author: Andreas Rederer
|
6
6
|
Project-URL: Homepage, https://github.com/DaSenf1860/ms-fabric-sdk-core
|
@@ -653,9 +653,15 @@ git_provider_details = {'organizationName': 'dasenf1860',
|
|
653
653
|
'branchName': 'main',
|
654
654
|
'directoryName': '/folder1'}
|
655
655
|
|
656
|
-
|
656
|
+
# Optional:
|
657
|
+
my_git_credentials = {
|
658
|
+
"source": "ConfiguredConnection",
|
659
|
+
"connectionId": "3f2asdfasdf82c3301"
|
660
|
+
}
|
661
|
+
|
662
|
+
fc.git_connect(workspace_id="workspaceid", git_provider_details=git_provider_details, my_git_credentials=my_git_credentials)
|
657
663
|
# or
|
658
|
-
ws.git_connect(git_provider_details=git_provider_details)
|
664
|
+
ws.git_connect(git_provider_details=git_provider_details, my_git_credentials=my_git_credentials)
|
659
665
|
|
660
666
|
|
661
667
|
# Initialize a git connection
|
@@ -731,6 +737,34 @@ item.create_shortcut(path="path",
|
|
731
737
|
"workspaceId": "workspace_id_target"}})
|
732
738
|
|
733
739
|
|
740
|
+
# Bulk create shortcuts
|
741
|
+
fc.create_shortcuts_bulk(workspace_id="workspace_id",
|
742
|
+
item_id="item_id",
|
743
|
+
create_shortcut_requests=[
|
744
|
+
{
|
745
|
+
"path": "Files",
|
746
|
+
"name": "sales_2023",
|
747
|
+
"target": {
|
748
|
+
"oneLake": {
|
749
|
+
"workspaceId": "workspace_id_target",
|
750
|
+
"itemId": "item_id_target",
|
751
|
+
"path": "Tables/Sales2023"
|
752
|
+
}
|
753
|
+
}
|
754
|
+
},
|
755
|
+
{
|
756
|
+
"path": "Files/landingZone",
|
757
|
+
"name": "PartnerProducts",
|
758
|
+
"target": {
|
759
|
+
"adlsGen2": {
|
760
|
+
"location": "https://casdfasdfat.dfs.core.windows.net",
|
761
|
+
"subpath": "/mycontainer/data/ContosoProducts",
|
762
|
+
"connectionId": "91asdfasdfa1e"
|
763
|
+
}
|
764
|
+
}
|
765
|
+
}
|
766
|
+
])
|
767
|
+
|
734
768
|
# Get a shortcut
|
735
769
|
shortcut = fc.get_shortcut(workspace_id="workspace_id",
|
736
770
|
item_id="item_id",
|
@@ -635,9 +635,15 @@ git_provider_details = {'organizationName': 'dasenf1860',
|
|
635
635
|
'branchName': 'main',
|
636
636
|
'directoryName': '/folder1'}
|
637
637
|
|
638
|
-
|
638
|
+
# Optional:
|
639
|
+
my_git_credentials = {
|
640
|
+
"source": "ConfiguredConnection",
|
641
|
+
"connectionId": "3f2asdfasdf82c3301"
|
642
|
+
}
|
643
|
+
|
644
|
+
fc.git_connect(workspace_id="workspaceid", git_provider_details=git_provider_details, my_git_credentials=my_git_credentials)
|
639
645
|
# or
|
640
|
-
ws.git_connect(git_provider_details=git_provider_details)
|
646
|
+
ws.git_connect(git_provider_details=git_provider_details, my_git_credentials=my_git_credentials)
|
641
647
|
|
642
648
|
|
643
649
|
# Initialize a git connection
|
@@ -713,6 +719,34 @@ item.create_shortcut(path="path",
|
|
713
719
|
"workspaceId": "workspace_id_target"}})
|
714
720
|
|
715
721
|
|
722
|
+
# Bulk create shortcuts
|
723
|
+
fc.create_shortcuts_bulk(workspace_id="workspace_id",
|
724
|
+
item_id="item_id",
|
725
|
+
create_shortcut_requests=[
|
726
|
+
{
|
727
|
+
"path": "Files",
|
728
|
+
"name": "sales_2023",
|
729
|
+
"target": {
|
730
|
+
"oneLake": {
|
731
|
+
"workspaceId": "workspace_id_target",
|
732
|
+
"itemId": "item_id_target",
|
733
|
+
"path": "Tables/Sales2023"
|
734
|
+
}
|
735
|
+
}
|
736
|
+
},
|
737
|
+
{
|
738
|
+
"path": "Files/landingZone",
|
739
|
+
"name": "PartnerProducts",
|
740
|
+
"target": {
|
741
|
+
"adlsGen2": {
|
742
|
+
"location": "https://casdfasdfat.dfs.core.windows.net",
|
743
|
+
"subpath": "/mycontainer/data/ContosoProducts",
|
744
|
+
"connectionId": "91asdfasdfa1e"
|
745
|
+
}
|
746
|
+
}
|
747
|
+
}
|
748
|
+
])
|
749
|
+
|
716
750
|
# Get a shortcut
|
717
751
|
shortcut = fc.get_shortcut(workspace_id="workspace_id",
|
718
752
|
item_id="item_id",
|
@@ -118,6 +118,8 @@ class FabricClient():
|
|
118
118
|
if wait_for_completion:
|
119
119
|
operation_result = self.long_running_operation(response.headers)
|
120
120
|
if "operation_result" in return_format:
|
121
|
+
if ("value_json" in return_format and isinstance(operation_result, dict) and "value" in operation_result):
|
122
|
+
return operation_result["value"]
|
121
123
|
return operation_result
|
122
124
|
return response
|
123
125
|
elif response.status_code not in response_codes:
|
@@ -1128,11 +1128,13 @@ class FabricClientCore(FabricClient):
|
|
1128
1128
|
|
1129
1129
|
return response.status_code
|
1130
1130
|
|
1131
|
-
|
1131
|
+
|
1132
|
+
def git_connect(self, workspace_id, git_provider_details, my_git_credentials = None):
|
1132
1133
|
"""Connect git
|
1133
1134
|
Args:
|
1134
1135
|
workspace_id (str): The ID of the workspace
|
1135
1136
|
git_provider_details (dict): The git provider details
|
1137
|
+
my_git_credentials (dict): The git credentials
|
1136
1138
|
Returns:
|
1137
1139
|
int: The status code of the response
|
1138
1140
|
"""
|
@@ -1140,8 +1142,11 @@ class FabricClientCore(FabricClient):
|
|
1140
1142
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/git/connect"
|
1141
1143
|
|
1142
1144
|
payload = {
|
1143
|
-
'gitProviderDetails': git_provider_details
|
1145
|
+
'gitProviderDetails': git_provider_details,
|
1146
|
+
|
1144
1147
|
}
|
1148
|
+
if my_git_credentials:
|
1149
|
+
payload['myGitCredentials'] = my_git_credentials
|
1145
1150
|
|
1146
1151
|
response = self.calling_routine(url=url, operation="POST", body=payload,
|
1147
1152
|
response_codes=[200, 202, 429],
|
@@ -2005,7 +2010,46 @@ class FabricClientCore(FabricClient):
|
|
2005
2010
|
shortcut_dict['itemId'] = item_id
|
2006
2011
|
return OneLakeShortcut.from_dict(shortcut_dict,
|
2007
2012
|
core_client = self)
|
2008
|
-
|
2013
|
+
|
2014
|
+
|
2015
|
+
def create_shortcuts_bulk(self, workspace_id, item_id, create_shortcut_requests):
|
2016
|
+
"""
|
2017
|
+
Bulk create OneLake shortcuts.
|
2018
|
+
|
2019
|
+
Args:
|
2020
|
+
workspace_id (str)
|
2021
|
+
item_id (str)
|
2022
|
+
create_shortcut_requests (list[dict]): Each dict must have:
|
2023
|
+
path, name, target (target has 'oneLake' OR 'adlsGen2' child object)
|
2024
|
+
|
2025
|
+
Returns:
|
2026
|
+
dict: The results of the operation
|
2027
|
+
"""
|
2028
|
+
if not isinstance(create_shortcut_requests, list) or len(create_shortcut_requests) == 0:
|
2029
|
+
raise Exception("create_shortcut_requests must be a non-empty list.")
|
2030
|
+
|
2031
|
+
required_keys = {"path", "name", "target"}
|
2032
|
+
for idx, req in enumerate(create_shortcut_requests):
|
2033
|
+
if not isinstance(req, dict):
|
2034
|
+
raise Exception(f"Shortcut request at index {idx} is not a dict.")
|
2035
|
+
missing = required_keys - set(req.keys())
|
2036
|
+
if missing:
|
2037
|
+
raise Exception(f"Shortcut request at index {idx} missing keys: {missing}")
|
2038
|
+
|
2039
|
+
url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/items/{item_id}/shortcuts/bulkCreate"
|
2040
|
+
body = {
|
2041
|
+
"createShortcutRequests": create_shortcut_requests
|
2042
|
+
}
|
2043
|
+
|
2044
|
+
return self.calling_routine(
|
2045
|
+
url=url,
|
2046
|
+
operation="POST",
|
2047
|
+
body=body,
|
2048
|
+
response_codes=[200, 202, 429],
|
2049
|
+
error_message="Error creating shortcuts in bulk",
|
2050
|
+
return_format="value_json+operation_result",
|
2051
|
+
wait_for_completion=True
|
2052
|
+
)
|
2009
2053
|
|
2010
2054
|
def get_shortcut(self, workspace_id, item_id, path, name):
|
2011
2055
|
"""Get the shortcut in the item
|
@@ -2028,7 +2072,8 @@ class FabricClientCore(FabricClient):
|
|
2028
2072
|
shortcut_dict['itemId'] = id
|
2029
2073
|
return OneLakeShortcut.from_dict(shortcut_dict,
|
2030
2074
|
core_client = self)
|
2031
|
-
|
2075
|
+
|
2076
|
+
|
2032
2077
|
def delete_shortcut(self, workspace_id, item_id, path, name):
|
2033
2078
|
"""Delete the shortcut
|
2034
2079
|
Args:
|
@@ -2267,7 +2312,7 @@ class FabricClientCore(FabricClient):
|
|
2267
2312
|
|
2268
2313
|
return response
|
2269
2314
|
|
2270
|
-
def get_workspace(self, id = None, name = None):
|
2315
|
+
def get_workspace(self, id = None, name = None, return_item=True):
|
2271
2316
|
"""Get workspace by id or name
|
2272
2317
|
Args:
|
2273
2318
|
id (str): The ID of the workspace
|
@@ -2278,12 +2323,12 @@ class FabricClientCore(FabricClient):
|
|
2278
2323
|
ValueError: If neither id nor name is provided
|
2279
2324
|
"""
|
2280
2325
|
if id:
|
2281
|
-
return self.get_workspace_by_id(id)
|
2326
|
+
return self.get_workspace_by_id(id, return_item=return_item)
|
2282
2327
|
if name:
|
2283
2328
|
return self.get_workspace_by_name(name)
|
2284
2329
|
raise ValueError("Either id or name must be provided")
|
2285
2330
|
|
2286
|
-
def get_workspace_by_id(self, id):
|
2331
|
+
def get_workspace_by_id(self, id, return_item=True):
|
2287
2332
|
"""Get workspace by id
|
2288
2333
|
Args:
|
2289
2334
|
id (str): The ID of the workspace
|
@@ -2296,9 +2341,9 @@ class FabricClientCore(FabricClient):
|
|
2296
2341
|
|
2297
2342
|
ws_dict = self.calling_routine(url, operation="GET", response_codes=[200, 404], error_message="Error getting workspace", return_format="json")
|
2298
2343
|
|
2299
|
-
|
2300
|
-
|
2301
|
-
return
|
2344
|
+
if return_item:
|
2345
|
+
return Workspace.from_dict(ws_dict, core_client=self)
|
2346
|
+
return ws_dict
|
2302
2347
|
|
2303
2348
|
def get_workspace_by_name(self, name):
|
2304
2349
|
"""Get workspace by name
|
@@ -95,6 +95,11 @@ class Item:
|
|
95
95
|
return self.core_client.create_shortcut(workspace_id=self.workspace_id, item_id=self.id,
|
96
96
|
path=path, name=name, target=target)
|
97
97
|
|
98
|
+
def create_shortcuts_bulk(self, create_shortcut_requests):
|
99
|
+
"""Create multiple shortcuts in the item"""
|
100
|
+
return self.core_client.create_shortcuts_bulk(workspace_id=self.workspace_id, item_id=self.id,
|
101
|
+
create_shortcut_requests=create_shortcut_requests)
|
102
|
+
|
98
103
|
def delete_shortcut(self, path, name):
|
99
104
|
"""Delete the shortcut in the item"""
|
100
105
|
return self.core_client.delete_shortcut(workspace_id=self.workspace_id, item_id=self.id,
|
File without changes
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientAdmin
|
4
|
+
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fca = FabricClientAdmin()
|
12
|
+
|
13
|
+
def test_admin_api(self):
|
14
|
+
fca = self.fca
|
15
|
+
|
16
|
+
user_id = '1dc64c6e-7a10-4ea9-8488-85d0739a377d'
|
17
|
+
|
18
|
+
# List workspaces
|
19
|
+
ws = fca.list_workspaces(name="testitems")[0]
|
20
|
+
|
21
|
+
self.assertEqual(ws.name, "testitems")
|
22
|
+
|
23
|
+
# Get workspace
|
24
|
+
ws_clone = fca.get_workspace(workspace_id=ws.id)
|
25
|
+
|
26
|
+
self.assertEqual(ws.id, ws_clone.id)
|
27
|
+
|
28
|
+
# Discover git connections
|
29
|
+
|
30
|
+
git_connections = fca.discover_git_connections()
|
31
|
+
|
32
|
+
self.assertGreater(len(git_connections), 0)
|
33
|
+
|
34
|
+
git_conn = [g for g in git_connections if g['workspaceId'] == '63aa9e13-4912-4abe-9156-8a56e565b7a3'][0]
|
35
|
+
self.assertEqual(git_conn['gitProviderDetails']['ownerName'], 'DaSenf1860')
|
36
|
+
|
37
|
+
# List workspace access details
|
38
|
+
|
39
|
+
ws_access = fca.list_workspace_access_details(ws.id)
|
40
|
+
principials = ws_access["accessDetails"]
|
41
|
+
principials_ids = [p["principal"]["id"] for p in principials]
|
42
|
+
self.assertIn(user_id, principials_ids)
|
43
|
+
|
44
|
+
# Get access entities
|
45
|
+
|
46
|
+
access_entities = fca.list_access_entities(user_id, type="Notebook")
|
47
|
+
self.assertGreater(len(access_entities), 0)
|
48
|
+
|
49
|
+
# List tenant settings
|
50
|
+
|
51
|
+
settings = fca.list_tenant_settings()
|
52
|
+
monitoring_setting = [setting for setting in settings if setting['settingName'] == 'PlatformMonitoringTenantSetting'][0]
|
53
|
+
|
54
|
+
self.assertIsNotNone(monitoring_setting)
|
55
|
+
|
56
|
+
# List tenant settings capacity overrides
|
57
|
+
|
58
|
+
settings_capa = fca.list_capacities_tenant_settings_overrides()
|
59
|
+
setting = [s for s in settings_capa if s['id'] == '9E7E757D-D567-4FB3-BC4F-D230AABF2A00']
|
60
|
+
|
61
|
+
self.assertGreater(len(setting), 0)
|
62
|
+
|
63
|
+
|
64
|
+
# List tenant settings overrides on domains
|
65
|
+
|
66
|
+
domain_overrides = fca.list_domain_tenant_settings_overrides()
|
67
|
+
len(domain_overrides) == 0
|
68
|
+
self.assertEqual(len(domain_overrides), 0)
|
69
|
+
|
70
|
+
# List tenant settings overrides on workspaces
|
71
|
+
|
72
|
+
workspace_overrides = fca.list_workspace_tenant_settings_overrides()
|
73
|
+
wover = [w for w in workspace_overrides if w["id"] == "192333b2-5f89-4da5-ae69-64a3ee4c649c"]
|
74
|
+
self.assertIsNotNone(wover)
|
75
|
+
|
76
|
+
# Update tenant settings
|
77
|
+
|
78
|
+
if monitoring_setting["enabled"] == False:
|
79
|
+
changed_settings = fca.update_tenant_setting("PlatformMonitoringTenantSetting", enabled=True)
|
80
|
+
"tenantSettings" in changed_settings and len(changed_settings["tenantSettings"]) > 0 and changed_settings["tenantSettings"][0]["enabled"] == True
|
81
|
+
else:
|
82
|
+
changed_settings = fca.update_tenant_setting("PlatformMonitoringTenantSetting", enabled=False)
|
83
|
+
"tenantSettings" in changed_settings and len(changed_settings["tenantSettings"]) > 0 and changed_settings["tenantSettings"][0]["enabled"] == False
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
# Update tenant settings capacity overrides
|
88
|
+
|
89
|
+
|
90
|
+
enabledSecurityGroups = [{'graphId': '73ba0244-b701-41ed-96d9-79917b74f5f8', 'name': 'fabricadmins'}]
|
91
|
+
excludedSecurityGroups = [{'graphId': '16450670-829a-4b70-b80e-6524eea067cb', 'name': 'fabricuser'}]
|
92
|
+
feedback = fca.update_capacity_tenant_setting_override("9e7e757d-d567-4fb3-bc4f-d230aabf2a00",
|
93
|
+
"PlatformMonitoringTenantSetting",
|
94
|
+
enabled=True,
|
95
|
+
excluded_security_groups=excludedSecurityGroups,
|
96
|
+
enabled_security_groups=enabledSecurityGroups)
|
97
|
+
|
98
|
+
|
99
|
+
# List tenant settings overrides by capacity id
|
100
|
+
|
101
|
+
settings_capa = fca.list_capacity_tenant_settings_overrides_by_capacity_id("9e7e757d-d567-4fb3-bc4f-d230aabf2a00")
|
102
|
+
setting = [s for s in settings_capa if s['settingName'] == 'PlatformMonitoringTenantSetting']
|
103
|
+
|
104
|
+
self.assertGreater(len(setting), 0)
|
105
|
+
|
106
|
+
# Update tenant settings capacity overrides
|
107
|
+
|
108
|
+
status_code = fca.delete_capacity_tenant_setting_override("9e7e757d-d567-4fb3-bc4f-d230aabf2a00", "PlatformMonitoringTenantSetting")
|
109
|
+
|
110
|
+
self.assertEqual(status_code, 200)
|
111
|
+
|
112
|
+
settings = [set for set in fca.list_capacity_tenant_settings_overrides_by_capacity_id("9e7e757d-d567-4fb3-bc4f-d230aabf2a00") if set["settingName"] == "PlatformMonitoringTenantSetting"]
|
113
|
+
|
114
|
+
self.assertEqual(len(settings), 0)
|
115
|
+
|
116
|
+
self.assertIn("overrides", feedback)
|
117
|
+
self.assertGreater(len(feedback["overrides"]), 0)
|
118
|
+
self.assertEqual(feedback["overrides"][0]["enabled"], True)
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
# List items
|
127
|
+
|
128
|
+
item_list = fca.list_items(workspace_id=ws.id)
|
129
|
+
self.assertGreater(len(item_list), 0)
|
130
|
+
|
131
|
+
# Get item
|
132
|
+
|
133
|
+
item = fca.get_item(workspace_id=ws.id, item_id=item_list[0].id)
|
134
|
+
self.assertEqual(item.id, item_list[0].id)
|
135
|
+
|
136
|
+
# Get item access details
|
137
|
+
|
138
|
+
item_access = fca.list_item_access_details(workspace_id=ws.id, item_id=item_list[0].id)
|
139
|
+
principials = item_access["accessDetails"]
|
140
|
+
|
141
|
+
principials_ids = [p["principal"]["id"] for p in principials]
|
142
|
+
|
143
|
+
self.assertIn(user_id, principials_ids)
|
144
|
+
|
145
|
+
|
146
|
+
def test_labels(self):
|
147
|
+
|
148
|
+
fca = self.fca
|
149
|
+
|
150
|
+
items = [{"id": "e79d7a0e-1741-4ddf-a705-b861f2775f97", "type": "Lakehouse"}]
|
151
|
+
label_id = "defa4170-0d19-0005-0007-bc88714345d2"
|
152
|
+
resp = fca.bulk_set_labels(items=items, label_id=label_id)
|
153
|
+
self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
|
154
|
+
resp = fca.bulk_remove_labels(items=items)
|
155
|
+
self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
|
156
|
+
|
157
|
+
def test_admin_external_data_shares(self):
|
158
|
+
|
159
|
+
fca = self.fca
|
160
|
+
|
161
|
+
data_shares = fca.list_external_data_shares()
|
162
|
+
ws_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
163
|
+
|
164
|
+
data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
|
165
|
+
|
166
|
+
self.assertGreater(len(data_shares), 0)
|
167
|
+
# fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
168
|
+
# item_id = data_shares[0]['itemId'],
|
169
|
+
# workspace_id = data_shares[0]['workspaceId'])
|
170
|
+
# data_shares = fca.list_external_data_shares()
|
171
|
+
|
172
|
+
# data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
|
173
|
+
|
174
|
+
# self.assertEqual(data_shares[0]['status'], 'Revoked')
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientAdmin
|
4
|
+
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fca = FabricClientAdmin()
|
12
|
+
|
13
|
+
def test_admin_api(self):
|
14
|
+
fca = self.fca
|
15
|
+
|
16
|
+
sdk_tag = [tag for tag in fca.list_tags() if tag["displayName"] == "sdk_tag_temp"]
|
17
|
+
if len(sdk_tag) > 0:
|
18
|
+
sdk_tag = sdk_tag[0]
|
19
|
+
resp = fca.delete_tag(tag_id=sdk_tag["id"])
|
20
|
+
self.assertEqual(resp, 200)
|
21
|
+
|
22
|
+
new_tags = [{"displayName": "sdk_tag_temp"}]
|
23
|
+
resp = fca.bulk_create_tags(create_tags_request=new_tags)
|
24
|
+
self.assertEqual(len(resp["tags"]), 1)
|
25
|
+
resp = resp["tags"][0]
|
26
|
+
self.assertEqual(resp["displayName"], "sdk_tag_temp")
|
27
|
+
|
28
|
+
sdk_tag = [tag for tag in fca.list_tags() if tag["displayName"] == "sdk_tag_temp"]
|
29
|
+
self.assertEqual(len(sdk_tag), 1)
|
30
|
+
sdk_tag = sdk_tag[0]
|
31
|
+
|
32
|
+
self.assertIsNotNone(sdk_tag["id"])
|
33
|
+
|
34
|
+
resp = fca.update_tag(tag_id=sdk_tag["id"], display_name="sdk_tag_updated")
|
35
|
+
self.assertIsNotNone(resp["id"])
|
36
|
+
self.assertEqual(resp["displayName"], "sdk_tag_updated")
|
37
|
+
|
38
|
+
|
39
|
+
resp = fca.delete_tag(tag_id=resp["id"])
|
40
|
+
self.assertEqual(resp, 200)
|
41
|
+
|
42
|
+
sdk_tag = [tag for tag in fca.list_tags() if tag["displayName"] == "sdk_tag_temp"]
|
43
|
+
self.assertEqual(len(sdk_tag), 0)
|
44
|
+
|
45
|
+
|
46
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import unittest
|
2
|
+
from dotenv import load_dotenv
|
3
|
+
from msfabricpysdkcore import FabricClientCore
|
4
|
+
from datetime import datetime
|
5
|
+
load_dotenv()
|
6
|
+
|
7
|
+
class TestFabricClientCore(unittest.TestCase):
|
8
|
+
|
9
|
+
def __init__(self, *args, **kwargs):
|
10
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
11
|
+
self.fcc = FabricClientCore()
|
12
|
+
|
13
|
+
def test_apache_airflow_job(self):
|
14
|
+
fcc = self.fcc
|
15
|
+
|
16
|
+
workspace_id = "05bc5baa-ef02-4a31-ab20-158a478151d3"
|
17
|
+
item_id = "4e685286-d909-4ccb-911f-590ee3c3df14"
|
18
|
+
|
19
|
+
apache_airflow_job = fcc.list_apache_airflow_jobs(workspace_id=workspace_id)
|
20
|
+
for apache_airflow_job in apache_airflow_job:
|
21
|
+
if apache_airflow_job.id != item_id:
|
22
|
+
resp = fcc.delete_apache_airflow_job(workspace_id=workspace_id, apache_airflow_job_id=apache_airflow_job.id)
|
23
|
+
self.assertEqual(resp, 200)
|
24
|
+
|
25
|
+
apache_airflow_job_definition = fcc.get_apache_airflow_job_definition(workspace_id=workspace_id, apache_airflow_job_id=item_id)
|
26
|
+
self.assertIn("definition", apache_airflow_job_definition)
|
27
|
+
definition = apache_airflow_job_definition["definition"]
|
28
|
+
|
29
|
+
date_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
30
|
+
date_str = date_str.replace(" ", "T").replace(":", "").replace("-", "")
|
31
|
+
date_str = f"copyjob{date_str}"
|
32
|
+
|
33
|
+
apache_airflow_job_new = fcc.create_apache_airflow_job(workspace_id=workspace_id, display_name=date_str, definition=definition)
|
34
|
+
|
35
|
+
self.assertEqual(apache_airflow_job_new.display_name, date_str)
|
36
|
+
|
37
|
+
apache_airflow_job_get = fcc.get_apache_airflow_job(workspace_id=workspace_id, apache_airflow_job_id=apache_airflow_job_new.id)
|
38
|
+
self.assertEqual(apache_airflow_job_get.display_name, date_str)
|
39
|
+
|
40
|
+
apache_airflow_job = fcc.list_apache_airflow_jobs(workspace_id=workspace_id)
|
41
|
+
self.assertEqual(len(apache_airflow_job), 2)
|
42
|
+
|
43
|
+
date_str_updated = date_str + "_updated"
|
44
|
+
apache_airflow_job_updated = fcc.update_apache_airflow_job(workspace_id=workspace_id, apache_airflow_job_id=apache_airflow_job_new.id, display_name=date_str_updated, return_item=True)
|
45
|
+
self.assertEqual(apache_airflow_job_updated.display_name, date_str_updated)
|
46
|
+
|
47
|
+
apache_airflow_job_updated = fcc.update_apache_airflow_job_definition(workspace_id=workspace_id, apache_airflow_job_id=apache_airflow_job_new.id, definition=definition)
|
48
|
+
self.assertEqual(apache_airflow_job_updated.status_code, 200)
|
49
|
+
|
50
|
+
for apache_airflow_job in apache_airflow_job:
|
51
|
+
if apache_airflow_job.id != item_id:
|
52
|
+
resp = fcc.delete_apache_airflow_job(workspace_id=workspace_id, apache_airflow_job_id=apache_airflow_job.id)
|
53
|
+
self.assertEqual(resp, 200)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import unittest
|
2
|
+
from datetime import datetime
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
from time import sleep
|
5
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
6
|
+
|
7
|
+
load_dotenv()
|
8
|
+
|
9
|
+
class TestFabricClientCore(unittest.TestCase):
|
10
|
+
|
11
|
+
def __init__(self, *args, **kwargs):
|
12
|
+
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
13
|
+
#load_dotenv()
|
14
|
+
self.fc = FabricClientCore()
|
15
|
+
|
16
|
+
def test_connection(self):
|
17
|
+
|
18
|
+
datetime_str = datetime.now().strftime("%Y%m%H%M%S")
|
19
|
+
datetime_str
|
20
|
+
fc = self.fc
|
21
|
+
|
22
|
+
# display_name = "ContosoCloudConnection" + datetime_str
|
23
|
+
|
24
|
+
# cr = {"connectivityType": "ShareableCloud",
|
25
|
+
# "displayName": display_name,
|
26
|
+
# "connectionDetails": {
|
27
|
+
# 'type': "SQL",
|
28
|
+
# 'creationMethod': 'SQL',
|
29
|
+
# "parameters": [
|
30
|
+
# {
|
31
|
+
# "dataType": "Text",
|
32
|
+
# "name": "server",
|
33
|
+
# "value": "dfsdemo.database.windows.net"
|
34
|
+
# },
|
35
|
+
# {
|
36
|
+
# "dataType": "Text",
|
37
|
+
# "name": "database",
|
38
|
+
# "value": "dfsdemo"
|
39
|
+
# }
|
40
|
+
# ]},
|
41
|
+
# 'privacyLevel': 'Organizational',
|
42
|
+
# 'credentialDetails': {'credentials':{'credentialType': 'Basic',
|
43
|
+
# 'userName': 'new_user',
|
44
|
+
# 'password': 'StrongPassword123!'},
|
45
|
+
# 'singleSignOnType': 'None',
|
46
|
+
# 'connectionEncryption': 'NotEncrypted',
|
47
|
+
# 'skipTestConnection': False}
|
48
|
+
# }
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
# connection = fc.create_connection(connection_request=cr)
|
53
|
+
# self.assertIsNotNone(connection)
|
54
|
+
# self.assertIn('id', connection)
|
55
|
+
# self.assertIn('displayName', connection)
|
56
|
+
# self.assertEqual(connection['displayName'], display_name)
|
57
|
+
|
58
|
+
# connection2 = fc.get_connection(connection_name=display_name)
|
59
|
+
# self.assertEqual(connection['id'], connection2['id'])
|
60
|
+
|
61
|
+
|
62
|
+
# connections = fc.list_connections()
|
63
|
+
# connection_names = [conn['displayName'] for conn in connections]
|
64
|
+
# self.assertIn(display_name, connection_names)
|
65
|
+
|
66
|
+
# id = connection['id']
|
67
|
+
|
68
|
+
# role_assis = fc.list_connection_role_assignments(connection_id=id)
|
69
|
+
# self.assertEqual(len(role_assis), 1)
|
70
|
+
|
71
|
+
# principal = {"id" : "755f273c-98f8-408c-a886-691794938bd8",
|
72
|
+
# "type" : "ServicePrincipal"}
|
73
|
+
|
74
|
+
# add_role_assi = fc.add_connection_role_assignment(connection_id=id, principal=principal, role='User')
|
75
|
+
# self.assertIsNotNone(add_role_assi)
|
76
|
+
# self.assertIn('id', add_role_assi)
|
77
|
+
# role_assi_id = add_role_assi['id']
|
78
|
+
|
79
|
+
# role_assis = fc.list_connection_role_assignments(connection_id=id)
|
80
|
+
# self.assertEqual(len(role_assis), 2)
|
81
|
+
|
82
|
+
# role_assi = fc.get_connection_role_assignment(connection_id=id,
|
83
|
+
# connection_role_assignment_id=role_assi_id)
|
84
|
+
# self.assertEqual(role_assi['id'], role_assi_id)
|
85
|
+
|
86
|
+
# role_assi = fc.update_connection_role_assignment(connection_id=id,
|
87
|
+
# connection_role_assignment_id=role_assi_id,
|
88
|
+
# role='UserWithReshare')
|
89
|
+
# self.assertEqual(role_assi['role'], 'UserWithReshare')
|
90
|
+
|
91
|
+
# status_code = fc.delete_connection_role_assignment(connection_id=id,
|
92
|
+
# connection_role_assignment_id=role_assi_id)
|
93
|
+
# self.assertEqual(status_code, 200)
|
94
|
+
|
95
|
+
|
96
|
+
# cr = {
|
97
|
+
# "connectivityType": "ShareableCloud",
|
98
|
+
# "displayName": f"sqlserver{datetime_str}"
|
99
|
+
# }
|
100
|
+
|
101
|
+
# updated_connection = fc.update_connection(connection_id=id, connection_request=cr)
|
102
|
+
# self.assertIsNotNone(updated_connection)
|
103
|
+
|
104
|
+
|
105
|
+
# connection2 = fc.get_connection(connection_id=id)
|
106
|
+
# self.assertEqual(connection['id'], connection2['id'])
|
107
|
+
# self.assertEqual(connection2['displayName'], f"sqlserver{datetime_str}")
|
108
|
+
|
109
|
+
# status_code = fc.delete_connection(connection_id=id)
|
110
|
+
# self.assertEqual(status_code, 200)
|
111
|
+
|