msfabricpysdkcore 0.1.3__py3-none-any.whl → 0.1.5__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 (40) hide show
  1. msfabricpysdkcore/adminapi.py +4 -2
  2. msfabricpysdkcore/auth.py +28 -0
  3. msfabricpysdkcore/client.py +16 -7
  4. msfabricpysdkcore/coreapi.py +5 -2
  5. msfabricpysdkcore/fabric_azure_client.py +6 -3
  6. {msfabricpysdkcore-0.1.3.dist-info → msfabricpysdkcore-0.1.5.dist-info}/METADATA +6 -2
  7. msfabricpysdkcore-0.1.5.dist-info/RECORD +28 -0
  8. {msfabricpysdkcore-0.1.3.dist-info → msfabricpysdkcore-0.1.5.dist-info}/WHEEL +1 -1
  9. msfabricpysdkcore/tests/__init__.py +0 -0
  10. msfabricpysdkcore/tests/test_admin_apis.py +0 -98
  11. msfabricpysdkcore/tests/test_datapipelines.py +0 -45
  12. msfabricpysdkcore/tests/test_deployment_pipeline.py +0 -63
  13. msfabricpysdkcore/tests/test_domains.py +0 -126
  14. msfabricpysdkcore/tests/test_environments.py +0 -114
  15. msfabricpysdkcore/tests/test_evenhouses.py +0 -47
  16. msfabricpysdkcore/tests/test_evenstreams.py +0 -44
  17. msfabricpysdkcore/tests/test_external_data_shares.py +0 -51
  18. msfabricpysdkcore/tests/test_fabric_azure_client.py +0 -78
  19. msfabricpysdkcore/tests/test_git.py +0 -63
  20. msfabricpysdkcore/tests/test_items.py +0 -81
  21. msfabricpysdkcore/tests/test_items_incl_lakehouse.py +0 -418
  22. msfabricpysdkcore/tests/test_jobs.py +0 -43
  23. msfabricpysdkcore/tests/test_kql_queryset.py +0 -49
  24. msfabricpysdkcore/tests/test_kqldatabases.py +0 -48
  25. msfabricpysdkcore/tests/test_lakehouse.py +0 -84
  26. msfabricpysdkcore/tests/test_ml_experiments.py +0 -47
  27. msfabricpysdkcore/tests/test_ml_models.py +0 -47
  28. msfabricpysdkcore/tests/test_notebooks.py +0 -57
  29. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +0 -63
  30. msfabricpysdkcore/tests/test_other_items.py +0 -45
  31. msfabricpysdkcore/tests/test_reports.py +0 -52
  32. msfabricpysdkcore/tests/test_semantic_model.py +0 -50
  33. msfabricpysdkcore/tests/test_shortcuts.py +0 -55
  34. msfabricpysdkcore/tests/test_spark.py +0 -91
  35. msfabricpysdkcore/tests/test_sparkjobdefinition.py +0 -55
  36. msfabricpysdkcore/tests/test_warehouses.py +0 -50
  37. msfabricpysdkcore/tests/test_workspaces_capacities.py +0 -159
  38. msfabricpysdkcore-0.1.3.dist-info/RECORD +0 -57
  39. {msfabricpysdkcore-0.1.3.dist-info → msfabricpysdkcore-0.1.5.dist-info}/LICENSE +0 -0
  40. {msfabricpysdkcore-0.1.3.dist-info → msfabricpysdkcore-0.1.5.dist-info}/top_level.txt +0 -0
@@ -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) -> 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):
msfabricpysdkcore/auth.py CHANGED
@@ -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
- self.auth = FabricServicePrincipal(scope= self.scope,
35
- tenant_id = self.tenant_id,
36
- client_id = self.client_id,
37
- client_secret = self.client_secret)
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, silent=None) -> 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
 
@@ -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, silent=None) -> None:
9
- super().__init__(scope = "https://management.azure.com/",
8
+ def __init__(self, tenant_id=None, client_id=None, client_secret=None,
9
+ username = None, password = None, silent=None) -> None:
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
3
+ Version: 0.1.5
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 (currently Azure CLI Authentication, Authentication from a Microsoft Fabric notebook and Service Principal Authentication are supported)
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,28 @@
1
+ msfabricpysdkcore/__init__.py,sha256=ObRW5Q8IMqrvA6VH6zXSv3n01AzRCGjn5RojJXAR6VE,208
2
+ msfabricpysdkcore/admin_item.py,sha256=9L09Kb7kn7JW0bqVu1qPOMT6oHLduX4Q5_qhVJZTLxQ,3290
3
+ msfabricpysdkcore/admin_workspace.py,sha256=umNnIF8sf5Y8BDgfQdfG6sOZrQQc7RJINL9j8DPnm3c,3180
4
+ msfabricpysdkcore/adminapi.py,sha256=90OcFVXYhv6wf3bQCwspbw-NRxVugrgACkyru-h79MU,26188
5
+ msfabricpysdkcore/auth.py,sha256=CwagXOYpGlfOh9zGA8nP8g-L602ujp0aqBWJuZNYt98,4332
6
+ msfabricpysdkcore/capacity.py,sha256=Q_2-XrZtdf9F67fY0qU3D0ocEOGQq4KtIXAv9dXjQhI,1761
7
+ msfabricpysdkcore/client.py,sha256=KpHREbfzQRRighyJzyES3COZP3raK0C1-WhxGd07LHU,7890
8
+ msfabricpysdkcore/coreapi.py,sha256=X4gj7fJBVdkypliZFig5rlc9qaCFRD1TJPsVCiO2fK0,132261
9
+ msfabricpysdkcore/deployment_pipeline.py,sha256=2d7BqRPgfBiAlQOP4UfYLmFMM8xonSjPkJKhevIKGEY,5756
10
+ msfabricpysdkcore/domain.py,sha256=92IVvZ3jXHIT1a0zlTPD7uoQX6TcBBE_Y_b4dScxHSU,6949
11
+ msfabricpysdkcore/environment.py,sha256=4k2Le1mAQIrfcpNc3n1DbgdCzAldGTSTCbiDQGk0DlA,2784
12
+ msfabricpysdkcore/fabric_azure_capacity.py,sha256=7JxMp9weiKG_mDjlRK-88oIXr0kdG0pzv-Ouycf3fus,2808
13
+ msfabricpysdkcore/fabric_azure_client.py,sha256=I7Z0Y8Xy_esQcPaXgPL7EAkQmoQkAklJO4hxk_90dno,10722
14
+ msfabricpysdkcore/item.py,sha256=3ixgRDTmrKXw82xl1MkaaOQ2986s2_DFEJQeUkKPcEU,6376
15
+ msfabricpysdkcore/job_instance.py,sha256=HXSUVoE4XaG2Ic5RYZ1Mx3ymiIarHDAnyjaXXY4Aj74,2381
16
+ msfabricpysdkcore/lakehouse.py,sha256=yIrzatWM9emPn-Y54Cg_ZdAydIWjxrpK65jIQ4SClgE,1703
17
+ msfabricpysdkcore/long_running_operation.py,sha256=XTlsueSZKVFICxhx99geEQ6btZFlFb8-lssigmQ9c6Y,2133
18
+ msfabricpysdkcore/onelakeshortcut.py,sha256=H02wR6Z86qTEJOwVRMKz1Ou3K88Y9pfJa91vizjprvo,1661
19
+ msfabricpysdkcore/otheritems.py,sha256=rkIbF-LxUUZh0ZDqFiWeutMeIsBXw_R8UUCglIifWBQ,12024
20
+ msfabricpysdkcore/spark_custom_pool.py,sha256=YsEULaQG-FO507aPIb-4kk93ZWBmDZj6fbOEHYoyxHE,3188
21
+ msfabricpysdkcore/workspace.py,sha256=7ZOt8ovlUOfusQ-avl4OOgMueN1XAp7AXdfpzAhXh3s,40428
22
+ msfabricpysdkcore/util/__init__.py,sha256=p-1dC4AurfKdIUppNVlRCIcmwHBTURqfgIwxcie3fEA,50
23
+ msfabricpysdkcore/util/logger.py,sha256=XXdeaqI-BhXZgacChKrWP88TPU4FTWvS8L0YWjCT54A,1166
24
+ msfabricpysdkcore-0.1.5.dist-info/LICENSE,sha256=1NrGuF-zOmzbwzk3iI6lsP9koyDeKO1B0-8OD_tTvOQ,1156
25
+ msfabricpysdkcore-0.1.5.dist-info/METADATA,sha256=t6LBXzBORqvYmBULkAZ8AONvTY1wlJfqkWZhAHQV_FY,23352
26
+ msfabricpysdkcore-0.1.5.dist-info/WHEEL,sha256=Rp8gFpivVLXx-k3U95ozHnQw8yDcPxmhOpn_Gx8d5nc,91
27
+ msfabricpysdkcore-0.1.5.dist-info/top_level.txt,sha256=3iRonu6ptDGQN4Yl6G76XGM7xbFNsskiEHW-P2gMQGY,18
28
+ msfabricpysdkcore-0.1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (71.1.0)
2
+ Generator: setuptools (72.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
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)
@@ -1,114 +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
- self.fc = FabricClientCore()
14
-
15
- def test_environments_crudl(self):
16
- fc = self.fc
17
- workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
18
- datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
19
-
20
- env_name = "env" + datetime_str
21
- environment1 = fc.create_environment(workspace_id, display_name=env_name)
22
- self.assertEqual(environment1.display_name, env_name)
23
-
24
- environments = fc.list_environments(workspace_id)
25
- environment_names = [env.display_name for env in environments]
26
- self.assertGreater(len(environments), 0)
27
- self.assertIn(env_name, environment_names)
28
-
29
- env = fc.get_environment(workspace_id, environment_name=env_name)
30
- self.assertIsNotNone(env.id)
31
- self.assertEqual(env.display_name, env_name)
32
- new_name = env_name + "2"
33
- env2 = fc.update_environment(workspace_id, env.id, display_name=new_name, return_item=True)
34
-
35
- env = fc.get_environment(workspace_id, environment_id=env.id)
36
- self.assertEqual(env.display_name, new_name)
37
- self.assertEqual(env.id, env2.id)
38
-
39
- status_code = fc.delete_environment(workspace_id, env.id)
40
- self.assertEqual(status_code, 200)
41
-
42
- def test_environment_details(self):
43
- fc = FabricClientCore()
44
- workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
45
- environment_id = '5648be67-28fa-48b6-9d1f-3c87c3704d3c'
46
- published_settings = fc.get_published_settings(workspace_id=workspace_id, environment_id=environment_id)
47
- self.assertIsNotNone(published_settings)
48
- self.assertIn("instancePool", published_settings)
49
- self.assertIn("dynamicExecutorAllocation", published_settings)
50
- staging_settings = fc.get_staging_settings(workspace_id=workspace_id, environment_id=environment_id)
51
- self.assertIsNotNone(staging_settings)
52
- self.assertIn("instancePool", staging_settings)
53
- self.assertIn("dynamicExecutorAllocation", staging_settings)
54
- if staging_settings["driverCores"] == 8:
55
- driver_cores = 4
56
- else:
57
- driver_cores = 8
58
- updated_settings = fc.update_staging_settings(workspace_id=workspace_id, environment_id=environment_id, driver_cores=driver_cores)
59
- self.assertIn("instancePool", updated_settings)
60
- self.assertIn("dynamicExecutorAllocation", updated_settings)
61
- self.assertEqual(updated_settings["driverCores"], driver_cores)
62
- updated_settings = fc.get_staging_settings(workspace_id=workspace_id, environment_id=environment_id)
63
- self.assertIn("instancePool", updated_settings)
64
- self.assertIn("dynamicExecutorAllocation", updated_settings)
65
- self.assertEqual(updated_settings["driverCores"], driver_cores)
66
-
67
-
68
- def test_environment_spark_libraries(self):
69
- fc = self.fc
70
- workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
71
- environment_id = '5648be67-28fa-48b6-9d1f-3c87c3704d3c'
72
-
73
- resp = fc.get_published_libraries(workspace_id, environment_id)
74
- self.assertIn('customLibraries', resp)
75
- self.assertIn('wheelFiles', resp['customLibraries'])
76
- self.assertIn('msfabricpysdkcore-0.1.1-py3-none-any.whl', resp['customLibraries']['wheelFiles'])
77
-
78
- resp = fc.upload_staging_library(workspace_id, environment_id, 'dummy.whl')
79
- self.assertEqual(resp.status_code, 200)
80
-
81
- resp = fc.get_staging_libraries(workspace_id, environment_id)
82
-
83
- self.assertIn('customLibraries', resp)
84
- self.assertIn('wheelFiles', resp['customLibraries'])
85
- self.assertIn('dummy.whl', resp['customLibraries']['wheelFiles'])
86
- self.assertIn('staging.whl', resp['customLibraries']['wheelFiles'])
87
-
88
-
89
- resp = fc.publish_environment(workspace_id, environment_id)
90
- self.assertIn('publishDetails', resp)
91
- self.assertIn('state', resp['publishDetails'])
92
- self.assertEqual(resp['publishDetails']['state'], 'running')
93
-
94
-
95
- resp = fc.cancel_publish(workspace_id, environment_id)
96
- self.assertIn('publishDetails', resp)
97
- self.assertIn('state', resp['publishDetails'])
98
- self.assertEqual(resp['publishDetails']['state'], 'cancelled')
99
-
100
- resp = fc.delete_staging_library(workspace_id, environment_id, 'dummy.whl')
101
- self.assertEqual(resp.status_code, 200)
102
-
103
- resp = fc.get_staging_libraries(workspace_id, environment_id)
104
-
105
- self.assertIn('customLibraries', resp)
106
- self.assertIn('wheelFiles', resp['customLibraries'])
107
- self.assertNotIn('dummy.whl', resp['customLibraries']['wheelFiles'])
108
- self.assertIn('staging.whl', resp['customLibraries']['wheelFiles'])
109
-
110
-
111
-
112
-
113
-
114
-