msfabricpysdkcore 0.1.4__tar.gz → 0.1.6__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.1.4 → msfabricpysdkcore-0.1.6}/PKG-INFO +6 -2
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/README.md +5 -1
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/adminapi.py +4 -2
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/auth.py +28 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/client.py +16 -7
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/coreapi.py +6 -3
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/fabric_azure_client.py +5 -2
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore.egg-info/PKG-INFO +6 -2
- msfabricpysdkcore-0.1.6/msfabricpysdkcore.egg-info/SOURCES.txt +32 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/pyproject.toml +1 -1
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/setup.py +1 -1
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/__init__.py +0 -0
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_admin_apis.py +0 -98
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_datapipelines.py +0 -45
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_deployment_pipeline.py +0 -63
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_domains.py +0 -126
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_environments.py +0 -114
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_evenhouses.py +0 -47
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_evenstreams.py +0 -44
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_external_data_shares.py +0 -51
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_fabric_azure_client.py +0 -78
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_git.py +0 -63
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_items.py +0 -81
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +0 -418
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_jobs.py +0 -43
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_kql_queryset.py +0 -49
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_kqldatabases.py +0 -48
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_lakehouse.py +0 -84
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_ml_experiments.py +0 -47
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_ml_models.py +0 -47
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_notebooks.py +0 -57
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +0 -63
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_other_items.py +0 -45
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_reports.py +0 -52
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_semantic_model.py +0 -50
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_shortcuts.py +0 -55
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_spark.py +0 -91
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_sparkjobdefinition.py +0 -55
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_warehouses.py +0 -50
- msfabricpysdkcore-0.1.4/msfabricpysdkcore/tests/test_workspaces_capacities.py +0 -159
- msfabricpysdkcore-0.1.4/msfabricpysdkcore.egg-info/SOURCES.txt +0 -61
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/LICENSE +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/__init__.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/admin_item.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/admin_workspace.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/capacity.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/deployment_pipeline.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/domain.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/environment.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/fabric_azure_capacity.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/item.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/job_instance.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/lakehouse.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/long_running_operation.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/onelakeshortcut.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/otheritems.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/spark_custom_pool.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/util/__init__.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/util/logger.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/workspace.py +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore.egg-info/requires.txt +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
- {msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: msfabricpysdkcore
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.6
|
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
|
@@ -25,7 +25,11 @@ They are designed to automate your Fabric processes.
|
|
25
25
|
|
26
26
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
27
27
|
Additionally it brings some extra features like:
|
28
|
-
- Authentication is handled for you
|
28
|
+
- Authentication is handled for you, the following is supported:
|
29
|
+
- Azure CLI Authentication
|
30
|
+
- Authentication from a Microsoft Fabric notebook
|
31
|
+
- Service Principal Authentication
|
32
|
+
- MSALConfidentialClientApplicationAuthentication
|
29
33
|
- Waiting for completion of long running operations
|
30
34
|
- Retry logic when hitting the API rate limits
|
31
35
|
- Referencing objects by name instead of ID
|
@@ -10,7 +10,11 @@ They are designed to automate your Fabric processes.
|
|
10
10
|
|
11
11
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
12
12
|
Additionally it brings some extra features like:
|
13
|
-
- Authentication is handled for you
|
13
|
+
- Authentication is handled for you, the following is supported:
|
14
|
+
- Azure CLI Authentication
|
15
|
+
- Authentication from a Microsoft Fabric notebook
|
16
|
+
- Service Principal Authentication
|
17
|
+
- MSALConfidentialClientApplicationAuthentication
|
14
18
|
- Waiting for completion of long running operations
|
15
19
|
- Retry logic when hitting the API rate limits
|
16
20
|
- Referencing objects by name instead of ID
|
@@ -9,10 +9,12 @@ from msfabricpysdkcore.client import FabricClient
|
|
9
9
|
class FabricClientAdmin(FabricClient):
|
10
10
|
"""FabricClientAdmin class to interact with Fabric Admin APIs"""
|
11
11
|
|
12
|
-
def __init__(self, tenant_id = None, client_id = None, client_secret = None
|
12
|
+
def __init__(self, tenant_id = None, client_id = None, client_secret = None,
|
13
|
+
username = None, password = None) -> None:
|
13
14
|
"""Initialize FabricClientAdmin object"""
|
14
15
|
super().__init__(scope="https://api.fabric.microsoft.com/.default",
|
15
|
-
tenant_id=tenant_id, client_id=client_id, client_secret=client_secret
|
16
|
+
tenant_id=tenant_id, client_id=client_id, client_secret=client_secret,
|
17
|
+
username=username, password=password)
|
16
18
|
|
17
19
|
|
18
20
|
def long_running_operation(self, response_headers):
|
@@ -3,6 +3,7 @@ from warnings import warn
|
|
3
3
|
import requests
|
4
4
|
from abc import abstractmethod
|
5
5
|
from azure.identity import AzureCliCredential
|
6
|
+
import msal
|
6
7
|
from msfabricpysdkcore.util import logger
|
7
8
|
import logging
|
8
9
|
try:
|
@@ -98,3 +99,30 @@ class FabricSparkUtilsAuthentication(FabricAuth):
|
|
98
99
|
return token
|
99
100
|
|
100
101
|
|
102
|
+
class MSALConfidentialClientApplicationAuthentication(FabricAuth):
|
103
|
+
|
104
|
+
def __init__(self, tenant_id, client_id, client_secret, username, password, scope):
|
105
|
+
super().__init__(scope)
|
106
|
+
|
107
|
+
self._logger.info("Using Microsoft Authentication Library (MSAL) ConfidentialClientApplication for authentication")
|
108
|
+
|
109
|
+
self.username = username
|
110
|
+
self.password = password
|
111
|
+
self.scopes = [scope]
|
112
|
+
|
113
|
+
authority = f"https://login.microsoftonline.com/{tenant_id}"
|
114
|
+
|
115
|
+
self.app = msal.ConfidentialClientApplication(
|
116
|
+
client_id=client_id,
|
117
|
+
client_credential=client_secret,
|
118
|
+
authority=authority,
|
119
|
+
)
|
120
|
+
|
121
|
+
def get_token(self):
|
122
|
+
result = self.app.acquire_token_for_client(scopes=self.scopes)
|
123
|
+
result = self.app.acquire_token_by_username_password(
|
124
|
+
username=self.username,
|
125
|
+
password=self.password,
|
126
|
+
scopes=self.scopes,
|
127
|
+
)
|
128
|
+
return result["access_token"]
|
@@ -6,7 +6,7 @@ from time import sleep
|
|
6
6
|
import requests
|
7
7
|
import json
|
8
8
|
|
9
|
-
from msfabricpysdkcore.auth import FabricAuthClient, FabricServicePrincipal, FabricSparkUtilsAuthentication
|
9
|
+
from msfabricpysdkcore.auth import FabricAuthClient, FabricServicePrincipal, FabricSparkUtilsAuthentication, MSALConfidentialClientApplicationAuthentication
|
10
10
|
from msfabricpysdkcore.util import logger
|
11
11
|
|
12
12
|
class FabricClient():
|
@@ -14,7 +14,7 @@ class FabricClient():
|
|
14
14
|
|
15
15
|
_logger: logging.Logger
|
16
16
|
|
17
|
-
def __init__(self, scope, tenant_id = None, client_id = None, client_secret = None, silent=None) -> None:
|
17
|
+
def __init__(self, scope, tenant_id = None, client_id = None, client_secret = None, username = None, password = None, silent=None) -> None:
|
18
18
|
"""Initialize FabricClient object"""
|
19
19
|
|
20
20
|
self._logger = logger.getChild(__name__)
|
@@ -22,8 +22,9 @@ class FabricClient():
|
|
22
22
|
self.tenant_id = tenant_id if tenant_id else os.getenv("FABRIC_TENANT_ID")
|
23
23
|
self.client_id = client_id if client_id else os.getenv("FABRIC_CLIENT_ID")
|
24
24
|
self.client_secret = client_secret if client_secret else os.getenv("FABRIC_CLIENT_SECRET")
|
25
|
+
self.username = username if username else os.getenv("FABRIC_USERNAME")
|
26
|
+
self.password = password if password else os.getenv("FABRIC_PASSWORD")
|
25
27
|
self.scope = scope
|
26
|
-
#self.scope = "https://api.fabric.microsoft.com/.default"
|
27
28
|
|
28
29
|
if self.client_id is None or self.client_secret is None or self.tenant_id is None:
|
29
30
|
try:
|
@@ -31,10 +32,18 @@ class FabricClient():
|
|
31
32
|
except:
|
32
33
|
self.auth = FabricAuthClient(self.scope)
|
33
34
|
else:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
if username and password:
|
36
|
+
self.auth = MSALConfidentialClientApplicationAuthentication(tenant_id = self.tenant_id,
|
37
|
+
client_id = self.client_id,
|
38
|
+
client_secret = self.client_secret,
|
39
|
+
username = self.username,
|
40
|
+
password = self.password,
|
41
|
+
scope = self.scope)
|
42
|
+
else:
|
43
|
+
self.auth = FabricServicePrincipal(scope= self.scope,
|
44
|
+
tenant_id = self.tenant_id,
|
45
|
+
client_id = self.client_id,
|
46
|
+
client_secret = self.client_secret)
|
38
47
|
|
39
48
|
if silent is not None:
|
40
49
|
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
@@ -9,12 +9,15 @@ from msfabricpysdkcore.util import logger
|
|
9
9
|
class FabricClientCore(FabricClient):
|
10
10
|
"""FabricClientCore class to interact with Fabric Core APIs"""
|
11
11
|
|
12
|
-
def __init__(self, tenant_id = None, client_id = None, client_secret = None,
|
12
|
+
def __init__(self, tenant_id = None, client_id = None, client_secret = None,
|
13
|
+
username = None, password = None, silent=None) -> None:
|
13
14
|
"""Initialize FabricClientCore object"""
|
14
15
|
super().__init__(scope="https://api.fabric.microsoft.com/.default",
|
15
16
|
tenant_id=tenant_id,
|
16
17
|
client_id=client_id,
|
17
|
-
client_secret=client_secret
|
18
|
+
client_secret=client_secret,
|
19
|
+
username=username,
|
20
|
+
password=password)
|
18
21
|
if silent is not None:
|
19
22
|
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
20
23
|
|
@@ -660,7 +663,7 @@ class FabricClientCore(FabricClient):
|
|
660
663
|
error_message="Error listing items", return_format="value_json", paging=True)
|
661
664
|
|
662
665
|
if with_properties:
|
663
|
-
items = self.get_item_object_w_properties(items)
|
666
|
+
items = self.get_item_object_w_properties(workspace_id=workspace_id, item_list=items)
|
664
667
|
else:
|
665
668
|
items = [Item.from_dict(item, core_client=self) for item in items]
|
666
669
|
|
{msfabricpysdkcore-0.1.4 → msfabricpysdkcore-0.1.6}/msfabricpysdkcore/fabric_azure_client.py
RENAMED
@@ -5,11 +5,14 @@ from msfabricpysdkcore.client import FabricClient
|
|
5
5
|
|
6
6
|
class FabricAzureClient(FabricClient):
|
7
7
|
|
8
|
-
def __init__(self, tenant_id=None, client_id=None, client_secret=None,
|
8
|
+
def __init__(self, tenant_id=None, client_id=None, client_secret=None,
|
9
|
+
username = None, password = None, silent=None) -> None:
|
9
10
|
super().__init__(scope = "https://management.azure.com/.default",
|
10
11
|
tenant_id = tenant_id,
|
11
12
|
client_id = client_id,
|
12
|
-
client_secret = client_secret,
|
13
|
+
client_secret = client_secret,
|
14
|
+
username = username,
|
15
|
+
password = password)
|
13
16
|
|
14
17
|
if silent is not None:
|
15
18
|
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: msfabricpysdkcore
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.6
|
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
|
@@ -25,7 +25,11 @@ They are designed to automate your Fabric processes.
|
|
25
25
|
|
26
26
|
This SDK helps to interact with the Fabric APIs in a more Pythonic way.
|
27
27
|
Additionally it brings some extra features like:
|
28
|
-
- Authentication is handled for you
|
28
|
+
- Authentication is handled for you, the following is supported:
|
29
|
+
- Azure CLI Authentication
|
30
|
+
- Authentication from a Microsoft Fabric notebook
|
31
|
+
- Service Principal Authentication
|
32
|
+
- MSALConfidentialClientApplicationAuthentication
|
29
33
|
- Waiting for completion of long running operations
|
30
34
|
- Retry logic when hitting the API rate limits
|
31
35
|
- Referencing objects by name instead of ID
|
@@ -0,0 +1,32 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
setup.py
|
5
|
+
msfabricpysdkcore/__init__.py
|
6
|
+
msfabricpysdkcore/admin_item.py
|
7
|
+
msfabricpysdkcore/admin_workspace.py
|
8
|
+
msfabricpysdkcore/adminapi.py
|
9
|
+
msfabricpysdkcore/auth.py
|
10
|
+
msfabricpysdkcore/capacity.py
|
11
|
+
msfabricpysdkcore/client.py
|
12
|
+
msfabricpysdkcore/coreapi.py
|
13
|
+
msfabricpysdkcore/deployment_pipeline.py
|
14
|
+
msfabricpysdkcore/domain.py
|
15
|
+
msfabricpysdkcore/environment.py
|
16
|
+
msfabricpysdkcore/fabric_azure_capacity.py
|
17
|
+
msfabricpysdkcore/fabric_azure_client.py
|
18
|
+
msfabricpysdkcore/item.py
|
19
|
+
msfabricpysdkcore/job_instance.py
|
20
|
+
msfabricpysdkcore/lakehouse.py
|
21
|
+
msfabricpysdkcore/long_running_operation.py
|
22
|
+
msfabricpysdkcore/onelakeshortcut.py
|
23
|
+
msfabricpysdkcore/otheritems.py
|
24
|
+
msfabricpysdkcore/spark_custom_pool.py
|
25
|
+
msfabricpysdkcore/workspace.py
|
26
|
+
msfabricpysdkcore.egg-info/PKG-INFO
|
27
|
+
msfabricpysdkcore.egg-info/SOURCES.txt
|
28
|
+
msfabricpysdkcore.egg-info/dependency_links.txt
|
29
|
+
msfabricpysdkcore.egg-info/requires.txt
|
30
|
+
msfabricpysdkcore.egg-info/top_level.txt
|
31
|
+
msfabricpysdkcore/util/__init__.py
|
32
|
+
msfabricpysdkcore/util/logger.py
|
File without changes
|
@@ -1,98 +0,0 @@
|
|
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
|
-
# List workspace access details
|
29
|
-
|
30
|
-
ws_access = fca.list_workspace_access_details(ws.id)
|
31
|
-
principials = ws_access["accessDetails"]
|
32
|
-
principials_ids = [p["principal"]["id"] for p in principials]
|
33
|
-
self.assertIn(user_id, principials_ids)
|
34
|
-
|
35
|
-
# Get access entities
|
36
|
-
|
37
|
-
access_entities = fca.list_access_entities(user_id, type="Notebook")
|
38
|
-
self.assertGreater(len(access_entities), 0)
|
39
|
-
|
40
|
-
# Get tenant settings
|
41
|
-
|
42
|
-
tenant_settings = fca.list_tenant_settings()
|
43
|
-
self.assertGreater(len(tenant_settings["tenantSettings"]), 0)
|
44
|
-
|
45
|
-
# Get capacity tenant settings overrides
|
46
|
-
|
47
|
-
overrides = fca.list_capacities_tenant_settings_overrides()
|
48
|
-
self.assertGreater(len(overrides), -1)
|
49
|
-
|
50
|
-
# List items
|
51
|
-
|
52
|
-
item_list = fca.list_items(workspace_id=ws.id)
|
53
|
-
self.assertGreater(len(item_list), 0)
|
54
|
-
|
55
|
-
# Get item
|
56
|
-
|
57
|
-
item = fca.get_item(workspace_id=ws.id, item_id=item_list[0].id)
|
58
|
-
self.assertEqual(item.id, item_list[0].id)
|
59
|
-
|
60
|
-
# Get item access details
|
61
|
-
|
62
|
-
item_access = fca.list_item_access_details(workspace_id=ws.id, item_id=item_list[0].id)
|
63
|
-
principials = item_access["accessDetails"]
|
64
|
-
|
65
|
-
principials_ids = [p["principal"]["id"] for p in principials]
|
66
|
-
|
67
|
-
self.assertIn(user_id, principials_ids)
|
68
|
-
|
69
|
-
|
70
|
-
def test_labels(self):
|
71
|
-
|
72
|
-
fca = self.fca
|
73
|
-
|
74
|
-
items = [{"id": "9cdd3192-bcd0-4cbe-b945-29f5964e7ab7", "type": "Lakehouse"}]
|
75
|
-
label_id = "defa4170-0d19-0005-0007-bc88714345d2"
|
76
|
-
resp = fca.bulk_set_labels(items=items, label_id=label_id)
|
77
|
-
self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
|
78
|
-
resp = fca.bulk_remove_labels(items=items)
|
79
|
-
self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
|
80
|
-
|
81
|
-
def test_admin_external_data_shares(self):
|
82
|
-
|
83
|
-
fca = self.fca
|
84
|
-
|
85
|
-
data_shares = fca.list_external_data_shares()
|
86
|
-
ws_id = "63aa9e13-4912-4abe-9156-8a56e565b7a3"
|
87
|
-
|
88
|
-
data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
|
89
|
-
|
90
|
-
self.assertGreater(len(data_shares), 0)
|
91
|
-
fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
|
92
|
-
item_id = data_shares[0]['itemId'],
|
93
|
-
workspace_id = data_shares[0]['workspaceId'])
|
94
|
-
data_shares = fca.list_external_data_shares()
|
95
|
-
|
96
|
-
data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
|
97
|
-
|
98
|
-
self.assertEqual(data_shares[0]['status'], 'Revoked')
|
@@ -1,45 +0,0 @@
|
|
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_data_pipelines(self):
|
17
|
-
|
18
|
-
fc = self.fc
|
19
|
-
workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
|
20
|
-
datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
21
|
-
pipeline_name = f"pipeline_{datetime_str}"
|
22
|
-
|
23
|
-
dp = fc.create_data_pipeline(workspace_id, display_name=pipeline_name, description="asda")
|
24
|
-
dp.update_definition(dp.definition)
|
25
|
-
|
26
|
-
dps = fc.list_data_pipelines(workspace_id)
|
27
|
-
dp_names = [dp.display_name for dp in dps]
|
28
|
-
self.assertGreater(len(dps), 0)
|
29
|
-
self.assertIn(pipeline_name, dp_names)
|
30
|
-
|
31
|
-
self.assertEqual(dp.display_name, pipeline_name)
|
32
|
-
pipeline_name2 = f"pipeline_{datetime_str}_2"
|
33
|
-
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name=pipeline_name2, return_item=True)
|
34
|
-
|
35
|
-
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
36
|
-
self.assertEqual(dp.display_name, pipeline_name2)
|
37
|
-
self.assertEqual(dp.id, dp2.id)
|
38
|
-
|
39
|
-
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name=pipeline_name, return_item=True)
|
40
|
-
|
41
|
-
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
42
|
-
self.assertEqual(dp.display_name, pipeline_name)
|
43
|
-
self.assertEqual(dp.id, dp2.id)
|
44
|
-
status_code = fc.delete_data_pipeline(workspace_id, dp.id)
|
45
|
-
self.assertEqual(status_code, 200)
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
from msfabricpysdkcore.coreapi import FabricClientCore
|
3
|
-
from dotenv import load_dotenv
|
4
|
-
|
5
|
-
load_dotenv()
|
6
|
-
|
7
|
-
|
8
|
-
class TestFabricClientCore(unittest.TestCase):
|
9
|
-
|
10
|
-
def __init__(self, *args, **kwargs):
|
11
|
-
super(TestFabricClientCore, self).__init__(*args, **kwargs)
|
12
|
-
self.fc = FabricClientCore()
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def test_spark_workspace_custom_pools(self):
|
17
|
-
fc = self.fc
|
18
|
-
|
19
|
-
dep_pipes = fc.list_deployment_pipelines()
|
20
|
-
|
21
|
-
self.assertGreater(len(dep_pipes), 0)
|
22
|
-
|
23
|
-
self.assertIn("sdkpipe", [pipe.display_name for pipe in dep_pipes])
|
24
|
-
|
25
|
-
for pipe in dep_pipes:
|
26
|
-
if pipe.display_name == 'sdkpipe':
|
27
|
-
pipe_id = pipe.id
|
28
|
-
break
|
29
|
-
|
30
|
-
pipe = fc.get_deployment_pipeline(pipe_id)
|
31
|
-
|
32
|
-
self.assertEqual(pipe.display_name, 'sdkpipe')
|
33
|
-
self.assertEqual(pipe.id, pipe_id)
|
34
|
-
|
35
|
-
stages = fc.list_deployment_pipeline_stages(pipe_id)
|
36
|
-
|
37
|
-
self.assertGreater(len(stages), 0)
|
38
|
-
names = [stage.display_name for stage in stages]
|
39
|
-
self.assertIn("Development", names)
|
40
|
-
self.assertIn("Production", names)
|
41
|
-
|
42
|
-
dev_stage = [stage for stage in stages if stage.display_name == "Development"][0]
|
43
|
-
prod_stage = [stage for stage in stages if stage.display_name == "Production"][0]
|
44
|
-
|
45
|
-
items = fc.list_deployment_pipeline_stages_items(deployment_pipeline_id=pipe_id, stage_id=dev_stage.id)
|
46
|
-
|
47
|
-
self.assertGreater(len(items), 0)
|
48
|
-
self.assertIn("cicdlakehouse", [item["itemDisplayName"] for item in items])
|
49
|
-
|
50
|
-
items = [item for item in dev_stage.list_items() if item["itemDisplayName"] == 'cicdlakehouse']
|
51
|
-
item = items[0]
|
52
|
-
item = {"sourceItemId": item["itemId"],
|
53
|
-
"itemType": item["itemType"]}
|
54
|
-
items = [item]
|
55
|
-
|
56
|
-
response = fc.deploy_stage_content(deployment_pipeline_id=pipe_id, source_stage_id=dev_stage.id,target_stage_id=prod_stage.id, items=items)
|
57
|
-
|
58
|
-
self.assertEqual(response["status"], "Succeeded")
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
@@ -1,126 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
from dotenv import load_dotenv
|
3
|
-
from datetime import datetime
|
4
|
-
from msfabricpysdkcore import FabricClientCore, FabricClientAdmin
|
5
|
-
|
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
|
-
|
14
|
-
|
15
|
-
def test_domains(self):
|
16
|
-
fcc = FabricClientCore()
|
17
|
-
fca = FabricClientAdmin()
|
18
|
-
|
19
|
-
ws = fcc.get_workspace_by_name("sdktestdomains")
|
20
|
-
cap = fcc.get_capacity(capacity_id=ws.capacity_id)
|
21
|
-
principal = {'id': '1dc64c6e-7a10-4ea9-8488-85d0739a377d', 'type': 'User'}
|
22
|
-
|
23
|
-
# Delete if exists
|
24
|
-
try:
|
25
|
-
domain = fca.get_domain_by_name("sdktestdomains")
|
26
|
-
domain.delete()
|
27
|
-
except:
|
28
|
-
pass
|
29
|
-
try:
|
30
|
-
domain = fca.get_domain_by_name("sdktestdomains2")
|
31
|
-
domain.delete()
|
32
|
-
except:
|
33
|
-
pass
|
34
|
-
|
35
|
-
# Create domain
|
36
|
-
domain_name = "sdktestdomains" + datetime.now().strftime("%Y%m%d%H%M%S")
|
37
|
-
domain = fca.create_domain(display_name=domain_name)
|
38
|
-
self.assertIsNotNone(domain.id)
|
39
|
-
self.assertEqual(domain.display_name, domain_name)
|
40
|
-
|
41
|
-
# Get domain by name
|
42
|
-
domain_clone = fca.get_domain_by_name(domain_name)
|
43
|
-
self.assertIsNotNone(domain_clone.id)
|
44
|
-
self.assertEqual(domain_clone.display_name, domain_name)
|
45
|
-
|
46
|
-
# Get domain by id
|
47
|
-
domain_clone = fca.get_domain_by_id(domain.id)
|
48
|
-
self.assertIsNotNone(domain_clone.id)
|
49
|
-
self.assertEqual(domain_clone.display_name, domain_name)
|
50
|
-
|
51
|
-
# List domains
|
52
|
-
domains = fca.list_domains()
|
53
|
-
self.assertGreater(len(domains), 0)
|
54
|
-
domains_ids = [d.id for d in domains]
|
55
|
-
self.assertIn(domain.id, domains_ids)
|
56
|
-
|
57
|
-
# Update domain
|
58
|
-
domain_new_name = f"{domain_name}2"
|
59
|
-
domain_clone = fca.update_domain(domain.id, display_name=domain_new_name, return_item=True)
|
60
|
-
self.assertEqual(domain_clone.display_name, domain_new_name)
|
61
|
-
|
62
|
-
# Assign domain workspaces by Ids
|
63
|
-
status_code = fca.assign_domain_workspaces_by_ids(domain.id, [ws.id])
|
64
|
-
self.assertEqual(status_code, 200)
|
65
|
-
|
66
|
-
# List domain workspaces
|
67
|
-
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
68
|
-
self.assertGreater(len(workspaces), 0)
|
69
|
-
workspaces_ids = [w.id for w in workspaces]
|
70
|
-
self.assertIn(ws.id, workspaces_ids)
|
71
|
-
|
72
|
-
# Unassign domain workspaces by ids
|
73
|
-
status_code = fca.unassign_domain_workspaces_by_ids(domain.id, [ws.id])
|
74
|
-
self.assertEqual(status_code, 200)
|
75
|
-
|
76
|
-
workspaces = fca.list_domain_workspaces(domain.id)
|
77
|
-
self.assertEqual(len(workspaces), 0)
|
78
|
-
|
79
|
-
# Assign domain workspaces by capacities
|
80
|
-
status_code = fca.assign_domain_workspaces_by_capacities(domain.id, [cap.id])
|
81
|
-
self.assertEqual(status_code, 202)
|
82
|
-
|
83
|
-
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
84
|
-
self.assertGreater(len(workspaces), 0)
|
85
|
-
workspaces_ids = [w.id for w in workspaces]
|
86
|
-
self.assertIn(ws.id, workspaces_ids)
|
87
|
-
|
88
|
-
# Unassign all domain workspaces
|
89
|
-
status_code = fca.unassign_all_domain_workspaces(domain.id)
|
90
|
-
self.assertEqual(status_code, 200)
|
91
|
-
|
92
|
-
workspaces = fca.list_domain_workspaces(domain.id)
|
93
|
-
self.assertEqual(len(workspaces), 0)
|
94
|
-
|
95
|
-
# Assign domain workspaces by principals
|
96
|
-
status_code = fca.assign_domains_workspaces_by_principals(domain.id, [principal], wait_for_completion=True)
|
97
|
-
|
98
|
-
self.assertEqual(status_code, 202)
|
99
|
-
|
100
|
-
workspaces = fca.list_domain_workspaces(domain.id, workspace_objects=True)
|
101
|
-
self.assertGreater(len(workspaces), 0)
|
102
|
-
workspaces_ids = [w.id for w in workspaces]
|
103
|
-
self.assertIn(ws.id, workspaces_ids)
|
104
|
-
|
105
|
-
# Role assignments bulk assign
|
106
|
-
|
107
|
-
principal_2 = {'id': 'e0505016-ef55-4ca7-b106-e085cc201823', 'type': 'User'}
|
108
|
-
principals = [principal, principal_2]
|
109
|
-
|
110
|
-
status_code = fca.role_assignments_bulk_assign(domain.id, "Contributors", principals)
|
111
|
-
|
112
|
-
self.assertEqual(status_code, 200)
|
113
|
-
|
114
|
-
# Role assignments bulk unassign
|
115
|
-
status_code = fca.role_assignments_bulk_unassign(domain.id, "Contributors", [principal_2])
|
116
|
-
|
117
|
-
self.assertEqual(status_code, 200)
|
118
|
-
|
119
|
-
# Delete domain
|
120
|
-
status_code = fca.delete_domain(domain.id)
|
121
|
-
|
122
|
-
self.assertEqual(status_code, 200)
|
123
|
-
|
124
|
-
domains = fca.list_domains()
|
125
|
-
domains_ids = [d.id for d in domains]
|
126
|
-
self.assertNotIn(domain.id, domains_ids)
|