msfabricpysdkcore 0.1.1__py3-none-any.whl → 0.1.3__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 (44) hide show
  1. msfabricpysdkcore/__init__.py +4 -1
  2. msfabricpysdkcore/admin_item.py +1 -1
  3. msfabricpysdkcore/adminapi.py +13 -6
  4. msfabricpysdkcore/auth.py +31 -11
  5. msfabricpysdkcore/client.py +24 -10
  6. msfabricpysdkcore/coreapi.py +37 -19
  7. msfabricpysdkcore/deployment_pipeline.py +5 -3
  8. msfabricpysdkcore/fabric_azure_capacity.py +77 -0
  9. msfabricpysdkcore/fabric_azure_client.py +232 -0
  10. msfabricpysdkcore/long_running_operation.py +14 -5
  11. msfabricpysdkcore/tests/test_admin_apis.py +8 -9
  12. msfabricpysdkcore/tests/test_datapipelines.py +1 -1
  13. msfabricpysdkcore/tests/test_domains.py +2 -2
  14. msfabricpysdkcore/tests/test_environments.py +6 -6
  15. msfabricpysdkcore/tests/test_evenhouses.py +1 -2
  16. msfabricpysdkcore/tests/test_evenstreams.py +20 -20
  17. msfabricpysdkcore/tests/test_external_data_shares.py +3 -3
  18. msfabricpysdkcore/tests/test_fabric_azure_client.py +78 -0
  19. msfabricpysdkcore/tests/test_git.py +8 -9
  20. msfabricpysdkcore/tests/test_items.py +3 -2
  21. msfabricpysdkcore/tests/test_jobs.py +2 -2
  22. msfabricpysdkcore/tests/test_kql_queryset.py +1 -2
  23. msfabricpysdkcore/tests/test_kqldatabases.py +2 -2
  24. msfabricpysdkcore/tests/test_lakehouse.py +5 -7
  25. msfabricpysdkcore/tests/test_ml_experiments.py +1 -2
  26. msfabricpysdkcore/tests/test_ml_models.py +1 -2
  27. msfabricpysdkcore/tests/test_notebooks.py +1 -2
  28. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +2 -4
  29. msfabricpysdkcore/tests/test_other_items.py +6 -7
  30. msfabricpysdkcore/tests/test_reports.py +1 -2
  31. msfabricpysdkcore/tests/test_semantic_model.py +3 -4
  32. msfabricpysdkcore/tests/test_shortcuts.py +4 -4
  33. msfabricpysdkcore/tests/test_spark.py +2 -4
  34. msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
  35. msfabricpysdkcore/tests/test_warehouses.py +1 -2
  36. msfabricpysdkcore/tests/test_workspaces_capacities.py +9 -9
  37. msfabricpysdkcore/util/__init__.py +3 -0
  38. msfabricpysdkcore/util/logger.py +32 -0
  39. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/METADATA +80 -3
  40. msfabricpysdkcore-0.1.3.dist-info/RECORD +57 -0
  41. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/WHEEL +1 -1
  42. msfabricpysdkcore-0.1.1.dist-info/RECORD +0 -52
  43. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/LICENSE +0 -0
  44. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,232 @@
1
+ from warnings import warn
2
+
3
+ from msfabricpysdkcore.client import FabricClient
4
+
5
+
6
+ class FabricAzureClient(FabricClient):
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/",
10
+ tenant_id = tenant_id,
11
+ client_id = client_id,
12
+ client_secret = client_secret,)
13
+
14
+ if silent is not None:
15
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
16
+
17
+
18
+ def check_name_availability(self, subscription_id, location, name, type = "Microsoft.Fabric/capacities"):
19
+ """Check name availability
20
+ Args:
21
+ subscription_id (str): The subscription ID
22
+ location (str): The location
23
+ name (str): The name
24
+ type (str): The type
25
+ Returns:
26
+ dict: The response
27
+ """
28
+
29
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Fabric/locations/{location}/checkNameAvailability?api-version=2023-11-01"
30
+
31
+ body = {
32
+ "name": name,
33
+ "type": type
34
+ }
35
+
36
+ response = self.calling_routine(url=url, operation="POST", body=body, response_codes=[200], return_format="json", error_message="Failed to check name availability")
37
+ return response
38
+
39
+ def create_or_update_capacity(self, subscription_id, resource_group_name, capacity_name, location, properties_administration, sku, tags = None):
40
+ """Create or update capacity
41
+ Args:
42
+ subscription_id (str): The subscription ID
43
+ resource_group_name (str): The resource group name
44
+ capacity_name (str): The capacity name
45
+ location (str): The location
46
+ properties_administration (dict): The administration properties
47
+ sku (dict): The sku
48
+ tags (dict): The tags
49
+ Returns:
50
+ FabricAzureCapacity: The capacity
51
+ """
52
+ from msfabricpysdkcore.fabric_azure_capacity import FabricAzureCapacity
53
+
54
+ if sku and "name" in sku:
55
+ sku = sku["name"]
56
+
57
+ body = {
58
+ "location": location,
59
+ "properties": {
60
+ "administration": properties_administration
61
+ },
62
+ "sku": {"name": sku,
63
+ "tier": "Fabric"}
64
+ }
65
+
66
+ if tags is not None:
67
+ body["tags"] = tags
68
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
69
+
70
+ response = self.calling_routine(url=url, operation="PUT", body=body, response_codes=[200, 201], return_format="json", error_message="Failed to create or update capacity")
71
+ response["subscription_id"] = subscription_id
72
+ response["resource_group_name"] = resource_group_name
73
+
74
+ return FabricAzureCapacity.from_dict(response, self)
75
+
76
+
77
+ def delete_capacity(self, subscription_id, resource_group_name, capacity_name):
78
+ """Delete capacity
79
+ Args:
80
+ subscription_id (str): The subscription ID
81
+ resource_group_name (str): The resource group name
82
+ capacity_name (str): The capacity name
83
+ Returns:
84
+ dict: The response
85
+ """
86
+
87
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
88
+
89
+ response = self.calling_routine(url=url, operation="DELETE", response_codes=[202], return_format="response", error_message="Failed to delete capacity")
90
+ return response
91
+
92
+
93
+ def get_capacity(self, subscription_id, resource_group_name, capacity_name):
94
+ """Get capacity
95
+ Args:
96
+ subscription_id (str): The subscription ID
97
+ resource_group_name (str): The resource group name
98
+ capacity_name (str): The capacity name
99
+ Returns:
100
+ FabricAzureCapacity: The capacity
101
+ """
102
+ from msfabricpysdkcore.fabric_azure_capacity import FabricAzureCapacity
103
+
104
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
105
+
106
+ response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="json", error_message="Failed to get capacity")
107
+ response["subscription_id"] = subscription_id
108
+ response["resource_group_name"] = resource_group_name
109
+
110
+ return FabricAzureCapacity.from_dict(response, self)
111
+
112
+ def list_by_resource_group(self, subscription_id, resource_group_name):
113
+ """List capacities by resource group
114
+ Args:
115
+ subscription_id (str): The subscription ID
116
+ resource_group_name (str): The resource group name
117
+ Returns:
118
+ dict: The response
119
+ """
120
+
121
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities?api-version=2023-11-01"
122
+
123
+ response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list capacities by resource group")
124
+ return response
125
+
126
+
127
+ def list_by_subscription(self, subscription_id):
128
+ """List capacities by subscription
129
+ Args:
130
+ subscription_id (str): The subscription ID
131
+ Returns:
132
+ dict: The response
133
+ """
134
+
135
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Fabric/capacities?api-version=2023-11-01"
136
+
137
+ response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list capacities by subscription")
138
+ return response
139
+
140
+ def list_skus(self, subscription_id):
141
+ """List skus
142
+ Args:
143
+ subscription_id (str): The subscription ID
144
+ Returns:
145
+ dict: The response
146
+ """
147
+
148
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Fabric/skus?api-version=2023-11-01"
149
+
150
+ response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list skus")
151
+ return response
152
+
153
+ def list_skus_for_capacity(self, subscription_id, resource_group_name, capacity_name):
154
+ """List skus for capacity
155
+ Args:
156
+ subscription_id (str): The subscription ID
157
+ resource_group_name (str): The resource group name
158
+ capacity_name (str): The capacity name
159
+ Returns:
160
+ dict: The response
161
+ """
162
+
163
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}/skus?api-version=2023-11-01"
164
+
165
+ response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list skus for capacity")
166
+ return response
167
+
168
+ def resume_capacity(self, subscription_id, resource_group_name, capacity_name):
169
+ """Resume capacity
170
+ Args:
171
+ subscription_id (str): The subscription ID
172
+ resource_group_name (str): The resource group name
173
+ capacity_name (str): The capacity name
174
+ Returns:
175
+ dict: The response
176
+ """
177
+
178
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}/resume?api-version=2023-11-01"
179
+
180
+ response = self.calling_routine(url=url, operation="POST", response_codes=[202], return_format="response", error_message="Failed to resume capacity")
181
+ return response
182
+
183
+ def suspend_capacity(self, subscription_id, resource_group_name, capacity_name):
184
+ """Suspend capacity
185
+ Args:
186
+ subscription_id (str): The subscription ID
187
+ resource_group_name (str): The resource group name
188
+ capacity_name (str): The capacity name
189
+ Returns:
190
+ dict: The response
191
+ """
192
+
193
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}/suspend?api-version=2023-11-01"
194
+
195
+ response = self.calling_routine(url=url, operation="POST", response_codes=[202], return_format="response", error_message="Failed to suspend capacity")
196
+ return response
197
+
198
+ def update_capacity(self, subscription_id, resource_group_name, capacity_name, properties_administration = None, sku = None, tags = None):
199
+ """Update capacity
200
+ Args:
201
+ subscription_id (str): The subscription ID
202
+ resource_group_name (str): The resource group name
203
+ capacity_name (str): The capacity name
204
+ body (dict): The body of the request
205
+ Returns:
206
+ FabricAzureCapacity: The capacity
207
+ """
208
+ from msfabricpysdkcore.fabric_azure_capacity import FabricAzureCapacity
209
+
210
+ body = {}
211
+ if sku and "name" in sku:
212
+ sku = sku["name"]
213
+
214
+ if properties_administration is not None:
215
+ body["properties"] = {}
216
+ body["properties"]["administration"] = properties_administration
217
+
218
+ if sku is not None:
219
+ body["sku"] = {"name": sku,
220
+ "tier": "Fabric"}
221
+
222
+ if tags is not None:
223
+ body["tags"] = tags
224
+
225
+ url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
226
+
227
+ response = self.calling_routine(url=url, operation="PATCH", body=body, response_codes=[200, 202],
228
+ return_format="json", error_message="Failed to update capacity")
229
+ response["subscription_id"] = subscription_id
230
+ response["resource_group_name"] = resource_group_name
231
+
232
+ return FabricAzureCapacity.from_dict(response, self)
@@ -1,16 +1,23 @@
1
+ import logging
1
2
  from time import sleep, time
2
3
  from msfabricpysdkcore.coreapi import FabricClientCore
4
+ from msfabricpysdkcore.util import logger
5
+
3
6
 
4
7
  class LongRunningOperation:
5
8
  """Class to represent a workspace in Microsoft Fabric"""
6
9
 
10
+ _logger: logging.Logger
11
+
7
12
  def __init__(self, operation_id, core_client: FabricClientCore) -> None:
13
+ """Initialize the LongRunningOperation object"""
14
+
15
+ self._logger = logger.getChild(__name__)
8
16
  self.operation_id = operation_id
9
17
  self.core_client = core_client
10
18
 
11
19
  self.state = self.get_operation_state()["status"]
12
20
 
13
-
14
21
  def get_operation_results(self):
15
22
  return self.core_client.get_operation_results(operation_id=self.operation_id)
16
23
 
@@ -26,22 +33,24 @@ class LongRunningOperation:
26
33
  if duration > 60:
27
34
 
28
35
  if self.state == "Running":
29
- print(f"Operation did not complete after {duration} seconds")
36
+ self._logger.info(f"Operation did not complete after {duration} seconds")
30
37
  return "Running"
31
- raise Exception(f"Operation did not complete after {duration} seconds")
38
+ raise TimeoutError(f"Operation did not complete after {duration} seconds")
32
39
  sleep(3)
33
40
  return self.state
34
41
 
35
42
 
36
43
  def check_long_running_operation(headers, core_client):
37
- """Check the status of a long running operation"""
44
+ """Check the status of a long-running operation"""
38
45
  location = headers.get('Location', None)
39
46
  operation_id = headers.get('x-ms-operation-id', None)
40
47
  if location:
41
48
  operation_id = location.split("/")[-1]
42
49
 
50
+ logger_ = logger.getChild(__name__)
51
+
43
52
  if not operation_id:
44
- print("Operation initiated, no operation id found")
53
+ logger_.info("Operation initiated, no operation id found")
45
54
  return None
46
55
  lro = LongRunningOperation(operation_id=operation_id, core_client=core_client)
47
56
  lro.wait_for_completion()
@@ -13,12 +13,12 @@ class TestFabricClientCore(unittest.TestCase):
13
13
  def test_admin_api(self):
14
14
  fca = self.fca
15
15
 
16
- user_id = 'b4f4e299-e6e1-4667-886c-57e4a8dde1c2'
16
+ user_id = '1dc64c6e-7a10-4ea9-8488-85d0739a377d'
17
17
 
18
18
  # List workspaces
19
- ws = fca.list_workspaces(name="testworkspace")[0]
19
+ ws = fca.list_workspaces(name="testitems")[0]
20
20
 
21
- self.assertEqual(ws.name, "testworkspace")
21
+ self.assertEqual(ws.name, "testitems")
22
22
 
23
23
  # Get workspace
24
24
  ws_clone = fca.get_workspace(workspace_id=ws.id)
@@ -71,8 +71,8 @@ class TestFabricClientCore(unittest.TestCase):
71
71
 
72
72
  fca = self.fca
73
73
 
74
- items = [{"id": "d417b834-d381-454c-9cf0-c491f69508de", "type": "Lakehouse"}]
75
- label_id = "defa4170-0d19-0005-000a-bc88714345d2"
74
+ items = [{"id": "9cdd3192-bcd0-4cbe-b945-29f5964e7ab7", "type": "Lakehouse"}]
75
+ label_id = "defa4170-0d19-0005-0007-bc88714345d2"
76
76
  resp = fca.bulk_set_labels(items=items, label_id=label_id)
77
77
  self.assertEqual(resp["itemsChangeLabelStatus"][0]["status"], "Succeeded")
78
78
  resp = fca.bulk_remove_labels(items=items)
@@ -83,17 +83,16 @@ class TestFabricClientCore(unittest.TestCase):
83
83
  fca = self.fca
84
84
 
85
85
  data_shares = fca.list_external_data_shares()
86
- ws = fca.list_workspaces(name="testworkspace")[0]
86
+ ws_id = "63aa9e13-4912-4abe-9156-8a56e565b7a3"
87
87
 
88
- data_shares = [d for d in data_shares if d['workspaceId'] == ws.id]
88
+ data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
89
89
 
90
90
  self.assertGreater(len(data_shares), 0)
91
91
  fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
92
92
  item_id = data_shares[0]['itemId'],
93
93
  workspace_id = data_shares[0]['workspaceId'])
94
94
  data_shares = fca.list_external_data_shares()
95
- ws = fca.list_workspaces(name="testworkspace")[0]
96
95
 
97
- data_shares = [d for d in data_shares if d['workspaceId'] == ws.id]
96
+ data_shares = [d for d in data_shares if d['workspaceId'] == ws_id]
98
97
 
99
98
  self.assertEqual(data_shares[0]['status'], 'Revoked')
@@ -16,7 +16,7 @@ class TestFabricClientCore(unittest.TestCase):
16
16
  def test_data_pipelines(self):
17
17
 
18
18
  fc = self.fc
19
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
19
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
20
20
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
21
21
  pipeline_name = f"pipeline_{datetime_str}"
22
22
 
@@ -18,7 +18,7 @@ class TestFabricClientCore(unittest.TestCase):
18
18
 
19
19
  ws = fcc.get_workspace_by_name("sdktestdomains")
20
20
  cap = fcc.get_capacity(capacity_id=ws.capacity_id)
21
- principal = {'id': 'b4f4e299-e6e1-4667-886c-57e4a8dde1c2', 'type': 'User'}
21
+ principal = {'id': '1dc64c6e-7a10-4ea9-8488-85d0739a377d', 'type': 'User'}
22
22
 
23
23
  # Delete if exists
24
24
  try:
@@ -104,7 +104,7 @@ class TestFabricClientCore(unittest.TestCase):
104
104
 
105
105
  # Role assignments bulk assign
106
106
 
107
- principal_2 = {'id': '6edbc444-16cd-43f4-ae48-cbe734b89657', 'type': 'User'}
107
+ principal_2 = {'id': 'e0505016-ef55-4ca7-b106-e085cc201823', 'type': 'User'}
108
108
  principals = [principal, principal_2]
109
109
 
110
110
  status_code = fca.role_assignments_bulk_assign(domain.id, "Contributors", principals)
@@ -14,7 +14,7 @@ class TestFabricClientCore(unittest.TestCase):
14
14
 
15
15
  def test_environments_crudl(self):
16
16
  fc = self.fc
17
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
17
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
18
18
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
19
19
 
20
20
  env_name = "env" + datetime_str
@@ -41,8 +41,8 @@ class TestFabricClientCore(unittest.TestCase):
41
41
 
42
42
  def test_environment_details(self):
43
43
  fc = FabricClientCore()
44
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
45
- environment_id = 'fae6d1a7-d671-4091-89b1-f42626deb56f'
44
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
45
+ environment_id = '5648be67-28fa-48b6-9d1f-3c87c3704d3c'
46
46
  published_settings = fc.get_published_settings(workspace_id=workspace_id, environment_id=environment_id)
47
47
  self.assertIsNotNone(published_settings)
48
48
  self.assertIn("instancePool", published_settings)
@@ -67,13 +67,13 @@ class TestFabricClientCore(unittest.TestCase):
67
67
 
68
68
  def test_environment_spark_libraries(self):
69
69
  fc = self.fc
70
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
71
- environment_id = 'fae6d1a7-d671-4091-89b1-f42626deb56f'
70
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
71
+ environment_id = '5648be67-28fa-48b6-9d1f-3c87c3704d3c'
72
72
 
73
73
  resp = fc.get_published_libraries(workspace_id, environment_id)
74
74
  self.assertIn('customLibraries', resp)
75
75
  self.assertIn('wheelFiles', resp['customLibraries'])
76
- self.assertIn('msfabricpysdkcore-0.0.13-py3-none-any.whl', resp['customLibraries']['wheelFiles'])
76
+ self.assertIn('msfabricpysdkcore-0.1.1-py3-none-any.whl', resp['customLibraries']['wheelFiles'])
77
77
 
78
78
  resp = fc.upload_staging_library(workspace_id, environment_id, 'dummy.whl')
79
79
  self.assertEqual(resp.status_code, 200)
@@ -12,7 +12,6 @@ class TestFabricClientCore(unittest.TestCase):
12
12
  super(TestFabricClientCore, self).__init__(*args, **kwargs)
13
13
  #load_dotenv()
14
14
  self.fc = FabricClientCore()
15
- self.workspace_id = "c3352d34-0b54-40f0-b204-cc964b1beb8d"
16
15
 
17
16
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
18
17
  self.item_name = "testitem" + datetime_str
@@ -23,7 +22,7 @@ class TestFabricClientCore(unittest.TestCase):
23
22
  def test_eventhouses(self):
24
23
 
25
24
  fc = self.fc
26
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
25
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
27
26
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
28
27
  eventhouse_name = "evh" + datetime_str
29
28
  eventhouse1 = fc.create_eventhouse(workspace_id, display_name=eventhouse_name)
@@ -15,30 +15,30 @@ class TestFabricClientCore(unittest.TestCase):
15
15
 
16
16
  def test_eventstreams(self):
17
17
 
18
- fc = self.fc
19
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
18
+ fc = self.fc
19
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
20
20
 
21
- datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
22
- es_name = "es" + datetime_str
21
+ datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
22
+ es_name = "es" + datetime_str
23
23
 
24
- eventstream = fc.create_eventstream(workspace_id, display_name=es_name)
25
- self.assertEqual(eventstream.display_name, es_name)
24
+ eventstream = fc.create_eventstream(workspace_id, display_name=es_name)
25
+ self.assertEqual(eventstream.display_name, es_name)
26
26
 
27
- eventstreams = fc.list_eventstreams(workspace_id)
28
- eventstream_names = [es.display_name for es in eventstreams]
29
- self.assertGreater(len(eventstreams), 0)
30
- self.assertIn(es_name, eventstream_names)
27
+ eventstreams = fc.list_eventstreams(workspace_id)
28
+ eventstream_names = [es.display_name for es in eventstreams]
29
+ self.assertGreater(len(eventstreams), 0)
30
+ self.assertIn(es_name, eventstream_names)
31
31
 
32
-
33
- es = fc.get_eventstream(workspace_id, eventstream_name=es_name)
34
- self.assertIsNotNone(es.id)
35
- self.assertEqual(es.display_name, es_name)
32
+
33
+ es = fc.get_eventstream(workspace_id, eventstream_name=es_name)
34
+ self.assertIsNotNone(es.id)
35
+ self.assertEqual(es.display_name, es_name)
36
36
 
37
- es2 = fc.update_eventstream(workspace_id, es.id, display_name=f"{es_name}2", return_item=True)
37
+ es2 = fc.update_eventstream(workspace_id, es.id, display_name=f"{es_name}2", return_item=True)
38
38
 
39
- es = fc.get_eventstream(workspace_id, eventstream_id=es.id)
40
- self.assertEqual(es.display_name, f"{es_name}2")
41
- self.assertEqual(es.id, es2.id)
39
+ es = fc.get_eventstream(workspace_id, eventstream_id=es.id)
40
+ self.assertEqual(es.display_name, f"{es_name}2")
41
+ self.assertEqual(es.id, es2.id)
42
42
 
43
- status_code = fc.delete_eventstream(workspace_id, es.id)
44
- self.assertEqual(status_code, 200)
43
+ status_code = fc.delete_eventstream(workspace_id, es.id)
44
+ self.assertEqual(status_code, 200)
@@ -14,13 +14,13 @@ class TestFabricClientCore(unittest.TestCase):
14
14
 
15
15
  fc = self.fc
16
16
 
17
- workspace_id = 'c3352d34-0b54-40f0-b204-cc964b1beb8d'
18
- item_id = 'e2c09c89-bf97-4f71-bdeb-36338795ec36'
17
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
18
+ item_id = "148ef579-4a5d-4048-8a48-0a703c5e3a1a"
19
19
 
20
20
  recipient = {
21
21
  "userPrincipalName": "lisa4@fabrikam.com"
22
22
  }
23
- paths=["Files/external"]
23
+ paths=["Files/to_share"]
24
24
 
25
25
  resp = fc.create_external_data_share(workspace_id, item_id, paths, recipient)
26
26
  self.assertIsNotNone(resp)
@@ -0,0 +1,78 @@
1
+ import unittest
2
+ from dotenv import load_dotenv
3
+ from datetime import datetime
4
+ from time import sleep
5
+ from msfabricpysdkcore import FabricAzureClient
6
+
7
+ load_dotenv()
8
+
9
+
10
+ class TestFabricClientCore(unittest.TestCase):
11
+
12
+ def __init__(self, *args, **kwargs):
13
+ super(TestFabricClientCore, self).__init__(*args, **kwargs)
14
+ #load_dotenv()
15
+ self.fac = FabricAzureClient()
16
+
17
+ def test_azure_capacity(self):
18
+
19
+ fac = self.fac
20
+
21
+ subscription_id = "c77cc8fc-43bb-4d44-bdc5-6e20511ed2a8"
22
+ resource_group_name = "fabricdemo"
23
+ capacity_name = "westeuropeajrederer"
24
+ capacity_name_new = "westeuropeajrederer" + datetime.now().strftime("%Y%m%d%H%M%S")
25
+
26
+ resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_new)
27
+ self.assertIn('nameAvailable', resp)
28
+ self.assertEqual(resp['nameAvailable'], True)
29
+
30
+ resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
31
+ location="westeurope",
32
+ properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
33
+ sku = "F2")
34
+ self.assertIsNotNone(resp.name)
35
+ self.assertEqual(resp.name, capacity_name_new)
36
+
37
+ resp = fac.get_capacity(subscription_id, resource_group_name, capacity_name_new)
38
+ self.assertIsNotNone(resp.name)
39
+ self.assertEqual(resp.name, capacity_name_new)
40
+
41
+ sku = resp.sku['name']
42
+
43
+ resp = fac.delete_capacity(subscription_id, resource_group_name, capacity_name_new)
44
+ self.assertEqual(resp.status_code, 202)
45
+
46
+
47
+ resp = fac.list_by_resource_group(subscription_id, resource_group_name)
48
+ cap_names = [cap["name"] for cap in resp]
49
+ self.assertIn(capacity_name, cap_names)
50
+
51
+
52
+
53
+ resp = fac.list_by_subscription(subscription_id)
54
+ cap_names = [cap["name"] for cap in resp]
55
+ self.assertIn(capacity_name, cap_names)
56
+
57
+
58
+ resp = fac.list_skus(subscription_id)
59
+ self.assertGreater(len(resp), 0, msg=f"No SKUs found: {resp}")
60
+
61
+
62
+ resp = fac.list_skus_for_capacity(subscription_id, resource_group_name, capacity_name)
63
+ self.assertGreater(len(resp), 0, msg=f"No SKUs found: {resp}")
64
+
65
+ resp = fac.resume_capacity(subscription_id, resource_group_name, capacity_name)
66
+ self.assertEqual(resp.status_code, 202)
67
+
68
+ sleep(30)
69
+ resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
70
+ self.assertEqual(resp.status_code, 202)
71
+ sleep(30)
72
+
73
+ if sku != "F4":
74
+ resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
75
+ self.assertEqual(resp.sku["name"], "F4")
76
+ else:
77
+ resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F2")
78
+ self.assertEqual(resp.sku["name"], "F2")
@@ -11,7 +11,6 @@ class TestFabricClientCore(unittest.TestCase):
11
11
  super(TestFabricClientCore, self).__init__(*args, **kwargs)
12
12
  #load_dotenv()
13
13
  self.fc = FabricClientCore()
14
- self.workspace_id = "fd3ba978-0b94-43e2-9f23-f65761e9ff34"
15
14
 
16
15
  def test_git(self):
17
16
 
@@ -19,14 +18,14 @@ class TestFabricClientCore(unittest.TestCase):
19
18
  ws2_name = "git" + datetime_str
20
19
  self.fc.create_workspace(display_name=ws2_name)
21
20
  ws2 = self.fc.get_workspace_by_name(name=ws2_name)
22
- self.fc.assign_to_capacity(workspace_id=ws2.id, capacity_id="a089a991-221c-49be-a41e-9020198cf7af")
23
-
24
- git_provider_details = {'organizationName': 'dasenf1860',
25
- 'projectName': 'fabrictest',
26
- 'gitProviderType': 'AzureDevOps',
27
- 'repositoryName': 'fabrictest',
28
- 'branchName': 'main',
29
- 'directoryName': '/folder1'}
21
+ self.fc.assign_to_capacity(workspace_id=ws2.id, capacity_id="840a6c1e-5289-4094-bbc8-716daabaeeba")
22
+
23
+ git_provider_details = {'organizationName': 'MngEnvMCAP065039',
24
+ 'projectName': 'fabricdevops',
25
+ 'gitProviderType': 'AzureDevOps',
26
+ 'repositoryName': 'fabricdevops',
27
+ 'branchName': 'main',
28
+ 'directoryName': '/sdkdemoRTI'}
30
29
 
31
30
  status_code = self.fc.git_connect(workspace_id=ws2.id, git_provider_details=git_provider_details)
32
31
 
@@ -12,7 +12,8 @@ class TestFabricClientCore(unittest.TestCase):
12
12
  super(TestFabricClientCore, self).__init__(*args, **kwargs)
13
13
  #load_dotenv()
14
14
  self.fc = FabricClientCore()
15
- self.workspace_id = "c3352d34-0b54-40f0-b204-cc964b1beb8d"
15
+ self.workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
16
+
16
17
 
17
18
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
18
19
  self.item_name = "testitem" + datetime_str
@@ -51,7 +52,7 @@ class TestFabricClientCore(unittest.TestCase):
51
52
 
52
53
  def test_item_definition(self):
53
54
 
54
- sjd = self.fc.get_item(workspace_id=self.workspace_id, item_name="blubb", item_type="SparkJobDefinition")
55
+ sjd = self.fc.get_item(workspace_id=self.workspace_id, item_name="helloworld", item_type="SparkJobDefinition")
55
56
  self.assertIsNotNone(sjd.definition)
56
57
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
57
58
  blubb2 = "blubb2" + datetime_str
@@ -11,8 +11,8 @@ class TestFabricClientCore(unittest.TestCase):
11
11
  super(TestFabricClientCore, self).__init__(*args, **kwargs)
12
12
  #load_dotenv()
13
13
  self.fc = FabricClientCore()
14
- self.workspace_id = "c3352d34-0b54-40f0-b204-cc964b1beb8d"
15
- self.item_id = "7e38f344-81df-4805-83b6-b9cc16830500"
14
+ self.workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
15
+ self.item_id = "38a1c15f-8a9e-49c5-8d05-a27cf9ce8b18"
16
16
 
17
17
 
18
18
  def test_jobs_end_to_end(self):
@@ -12,7 +12,6 @@ class TestFabricClientCore(unittest.TestCase):
12
12
  super(TestFabricClientCore, self).__init__(*args, **kwargs)
13
13
  #load_dotenv()
14
14
  self.fc = FabricClientCore()
15
- self.workspace_id = "c3352d34-0b54-40f0-b204-cc964b1beb8d"
16
15
 
17
16
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
18
17
  self.item_name = "testitem" + datetime_str
@@ -21,7 +20,7 @@ class TestFabricClientCore(unittest.TestCase):
21
20
  def test_kql_querysets(self):
22
21
 
23
22
  fc = self.fc
24
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
23
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
25
24
 
26
25
  kql_queryset_name = "kqlqueryset1"
27
26