msfabricpysdkcore 0.1.1__py3-none-any.whl → 0.1.2__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/__init__.py +2 -1
  2. msfabricpysdkcore/admin_item.py +1 -1
  3. msfabricpysdkcore/adminapi.py +3 -1
  4. msfabricpysdkcore/auth.py +10 -6
  5. msfabricpysdkcore/client.py +10 -7
  6. msfabricpysdkcore/coreapi.py +4 -1
  7. msfabricpysdkcore/fabric_azure_capacity.py +77 -0
  8. msfabricpysdkcore/fabric_azure_client.py +228 -0
  9. msfabricpysdkcore/tests/test_admin_apis.py +8 -9
  10. msfabricpysdkcore/tests/test_datapipelines.py +1 -1
  11. msfabricpysdkcore/tests/test_domains.py +2 -2
  12. msfabricpysdkcore/tests/test_environments.py +6 -6
  13. msfabricpysdkcore/tests/test_evenhouses.py +1 -2
  14. msfabricpysdkcore/tests/test_evenstreams.py +20 -20
  15. msfabricpysdkcore/tests/test_external_data_shares.py +3 -3
  16. msfabricpysdkcore/tests/test_fabric_azure_client.py +78 -0
  17. msfabricpysdkcore/tests/test_git.py +8 -9
  18. msfabricpysdkcore/tests/test_items.py +3 -2
  19. msfabricpysdkcore/tests/test_jobs.py +2 -2
  20. msfabricpysdkcore/tests/test_kql_queryset.py +1 -2
  21. msfabricpysdkcore/tests/test_kqldatabases.py +2 -2
  22. msfabricpysdkcore/tests/test_lakehouse.py +5 -7
  23. msfabricpysdkcore/tests/test_ml_experiments.py +1 -2
  24. msfabricpysdkcore/tests/test_ml_models.py +1 -2
  25. msfabricpysdkcore/tests/test_notebooks.py +1 -2
  26. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +2 -4
  27. msfabricpysdkcore/tests/test_other_items.py +6 -7
  28. msfabricpysdkcore/tests/test_reports.py +1 -2
  29. msfabricpysdkcore/tests/test_semantic_model.py +3 -4
  30. msfabricpysdkcore/tests/test_shortcuts.py +4 -4
  31. msfabricpysdkcore/tests/test_spark.py +2 -4
  32. msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
  33. msfabricpysdkcore/tests/test_warehouses.py +1 -2
  34. msfabricpysdkcore/tests/test_workspaces_capacities.py +9 -9
  35. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/METADATA +64 -3
  36. msfabricpysdkcore-0.1.2.dist-info/RECORD +55 -0
  37. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/WHEEL +1 -1
  38. msfabricpysdkcore-0.1.1.dist-info/RECORD +0 -52
  39. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/LICENSE +0 -0
  40. {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/top_level.txt +0 -0
@@ -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
 
@@ -16,8 +16,8 @@ class TestFabricClientCore(unittest.TestCase):
16
16
  def test_kql_database(self):
17
17
 
18
18
  fc = self.fc
19
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
20
- evenhouse_id = "14822d45-5460-4efa-9b30-8628510a9197"
19
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
20
+ evenhouse_id = "f30ba76a-92c3-40d3-ad69-36db059c113d"
21
21
 
22
22
  creation_payload = {"databaseType" : "ReadWrite",
23
23
  "parentEventhouseItemId" : evenhouse_id}
@@ -12,24 +12,23 @@ 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
19
18
  self.item_type = "Notebook"
20
19
 
21
20
  def test_lakehouse(self):
21
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
22
22
 
23
- lakehouse = self.fc.get_item(workspace_id=self.workspace_id, item_name="lakehouse1", item_type="Lakehouse")
23
+ lakehouse = self.fc.get_item(workspace_id=workspace_id, item_name="lakelhousewlabels", item_type="Lakehouse")
24
24
  self.assertIsNotNone(lakehouse.properties)
25
25
  lakehouse_id = lakehouse.id
26
- workspace_id = self.workspace_id
27
26
  date_str = datetime.now().strftime("%Y%m%d%H%M%S")
28
27
  table_name = f"table{date_str}"
29
28
 
30
29
 
31
- status_code = self.fc.load_table(workspace_id=self.workspace_id, lakehouse_id=lakehouse_id, table_name=table_name,
32
- path_type="File", relative_path="Files/folder1/titanic.csv")
30
+ status_code = self.fc.load_table(workspace_id=workspace_id, lakehouse_id=lakehouse_id, table_name=table_name,
31
+ path_type="File", relative_path="Files/to_share/titanic2.csv")
33
32
 
34
33
  self.assertEqual(status_code, 202)
35
34
 
@@ -54,13 +53,12 @@ class TestFabricClientCore(unittest.TestCase):
54
53
  job_type = "TableMaintenance", wait_for_completion = False)
55
54
  self.assertIn(response.status_code, [200, 202])
56
55
 
57
- table_list = self.fc.list_tables(workspace_id=self.workspace_id, lakehouse_id=lakehouse_id)
56
+ table_list = self.fc.list_tables(workspace_id=workspace_id, lakehouse_id=lakehouse_id)
58
57
  table_names = [table["name"] for table in table_list]
59
58
 
60
59
  self.assertIn(table_name, table_names)
61
60
 
62
61
  fc = self.fc
63
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
64
62
 
65
63
  lakehouse = fc.create_lakehouse(workspace_id=workspace_id, display_name="lakehouse2")
66
64
  self.assertIsNotNone(lakehouse.id)
@@ -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
@@ -22,7 +21,7 @@ class TestFabricClientCore(unittest.TestCase):
22
21
  def test_ml_experiments(self):
23
22
 
24
23
  fc = self.fc
25
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
24
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
26
25
  mlexperiment_name = "mlexp" + datetime.now().strftime("%Y%m%d%H%M%S")
27
26
  mlexperiment_name2 = "mlexp2" + datetime.now().strftime("%Y%m%d%H%M%S")
28
27
 
@@ -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
@@ -22,7 +21,7 @@ class TestFabricClientCore(unittest.TestCase):
22
21
  def test_ml_models(self):
23
22
 
24
23
  fc = self.fc
25
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
24
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
26
25
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
27
26
  model_name = "mlm" + datetime_str
28
27
 
@@ -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
@@ -22,7 +21,7 @@ class TestFabricClientCore(unittest.TestCase):
22
21
  def test_notebooks(self):
23
22
 
24
23
  fc = self.fc
25
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
24
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
26
25
 
27
26
  notebook_name = "notebook" + datetime.now().strftime("%Y%m%d%H%M%S")
28
27
 
@@ -14,8 +14,8 @@ class TestFabricClientCore(unittest.TestCase):
14
14
 
15
15
  fc = self.fc
16
16
 
17
- workspace_id = "d8a5abe0-9eed-406d-ab46-343bc57ddbe5"
18
- item_id = "50368cf3-29e7-4a09-aaf0-289fb5748364"
17
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
18
+ item_id = "148ef579-4a5d-4048-8a48-0a703c5e3a1a"
19
19
 
20
20
  resp = fc.list_data_access_roles(workspace_id=workspace_id, item_id=item_id)
21
21
  self.assertEqual(len(resp), 2)
@@ -30,8 +30,6 @@ class TestFabricClientCore(unittest.TestCase):
30
30
  self.assertGreater(len(role1['members']['fabricItemMembers']), 0)
31
31
  self.assertIn('itemAccess', role1['members']['fabricItemMembers'][0])
32
32
 
33
-
34
-
35
33
  item_access = role1["members"]["fabricItemMembers"][0]['itemAccess']
36
34
  item_access_old = list(item_access)
37
35
  if 'ReadAll' in item_access:
@@ -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
@@ -22,22 +21,22 @@ class TestFabricClientCore(unittest.TestCase):
22
21
 
23
22
  fc = self.fc
24
23
 
25
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
24
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
26
25
 
27
26
  list_dashboards = fc.list_dashboards(workspace_id)
28
27
  dashboard_names = [dashboard.display_name for dashboard in list_dashboards]
29
28
  self.assertGreater(len(list_dashboards), 0)
30
29
  self.assertIn("dashboard1", dashboard_names)
31
30
 
32
- list_datamarts = fc.list_datamarts(workspace_id)
33
- datamart_names = [datamart.display_name for datamart in list_datamarts]
34
- self.assertGreater(len(list_datamarts), 0)
35
- self.assertIn("datamart1", datamart_names)
31
+ # list_datamarts = fc.list_datamarts(workspace_id)
32
+ # datamart_names = [datamart.display_name for datamart in list_datamarts]
33
+ # self.assertGreater(len(list_datamarts), 0)
34
+ # self.assertIn("datamart1", datamart_names)
36
35
 
37
36
  list_sql_endpoints = fc.list_sql_endpoints(workspace_id)
38
37
  sqlendpoint_names = [sqlendpoint.display_name for sqlendpoint in list_sql_endpoints]
39
38
  self.assertGreater(len(list_sql_endpoints), 0)
40
- self.assertIn("sqlendpointlakehouse", sqlendpoint_names)
39
+ self.assertIn("lakelhousewlabels", sqlendpoint_names)
41
40
 
42
41
  # list_mirrored_warehouses = fc.list_mirrored_warehouses(self.workspace_id)
43
42
  # self.assertGreater(len(list_mirrored_warehouses), 0)
@@ -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
@@ -22,7 +21,7 @@ class TestFabricClientCore(unittest.TestCase):
22
21
  def test_reports(self):
23
22
 
24
23
  fc = self.fc
25
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
24
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
26
25
 
27
26
  report_name = "report1234"
28
27
 
@@ -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,9 +20,9 @@ class TestFabricClientCore(unittest.TestCase):
21
20
  def test_semantic_models(self):
22
21
 
23
22
  fc = self.fc
24
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
25
-
26
- semantic_model_name = "semanticmodel1234"
23
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
24
+ datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
25
+ semantic_model_name = "semanticmodel" + datetime_str
27
26
 
28
27
  semantic_model_w_content = fc.get_semantic_model(workspace_id, semantic_model_name="Table")
29
28
 
@@ -11,14 +11,14 @@ 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"
14
+ self.workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
15
15
 
16
- self.lakehouse_target = "cb4ca0b5-b53b-4879-b206-a53c35cbff55"
17
- self.lakehouse_shortcut = "e2c09c89-bf97-4f71-bdeb-36338795ec36"
16
+ self.lakehouse_target = "148ef579-4a5d-4048-8a48-0a703c5e3a1a"
17
+ self.lakehouse_shortcut = "9d1e8b07-2fea-4fc5-872c-fb586d085149"
18
18
 
19
19
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
20
20
  self.shortcutname = "shortcut" + datetime_str
21
- self.path_target = "Files/folder1"
21
+ self.path_target = "Files/to_share"
22
22
  self.path_shortcut = "Files/shortcutfolder"
23
23
 
24
24
  self.target = {'oneLake': {'itemId': self.lakehouse_target,
@@ -12,13 +12,11 @@ class TestFabricClientCore(unittest.TestCase):
12
12
  super(TestFabricClientCore, self).__init__(*args, **kwargs)
13
13
  #load_dotenv()
14
14
  self.fc = FabricClientCore()
15
- ws = self.fc.get_workspace_by_name(name="testitems")
16
- self.workspace_id = ws.id
17
15
 
18
16
 
19
17
  def test_spark_workspace_custom_pools(self):
20
18
  fc = self.fc
21
- workspace_id = self.workspace_id
19
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
22
20
  pool_name = "pool" + datetime.now().strftime("%Y%m%d%H%M%S")
23
21
  # List
24
22
 
@@ -65,7 +63,7 @@ class TestFabricClientCore(unittest.TestCase):
65
63
 
66
64
  def test_workspace_settings(self):
67
65
  fc = self.fc
68
- workspace_id = self.workspace_id
66
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
69
67
 
70
68
  # Get
71
69
 
@@ -14,7 +14,7 @@ class TestFabricClientCore(unittest.TestCase):
14
14
  def test_spark_job_definitions(self):
15
15
 
16
16
  fc = self.fc
17
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
17
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
18
18
 
19
19
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
20
20
  spark_job_definition_name = f"sjd{datetime_str}"
@@ -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
@@ -22,7 +21,7 @@ class TestFabricClientCore(unittest.TestCase):
22
21
  def test_warehouses(self):
23
22
 
24
23
  fc = self.fc
25
- workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
24
+ workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
26
25
 
27
26
  datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
28
27
  warehouse1 = f"wh{datetime_str}"
@@ -32,7 +32,7 @@ class TestFabricClientCore(unittest.TestCase):
32
32
  # def test_assign_to_capacity(self):
33
33
 
34
34
  result_status_code = fc.assign_to_capacity(workspace_id=ws.id,
35
- capacity_id="41cb829c-c231-4e9f-b4fc-f9042a6f9840")
35
+ capacity_id="840a6c1e-5289-4094-bbc8-716daabaeeba")
36
36
  self.assertEqual(result_status_code, 202)
37
37
 
38
38
 
@@ -44,7 +44,7 @@ class TestFabricClientCore(unittest.TestCase):
44
44
 
45
45
  for ws in result:
46
46
  if ws.display_name == display_name:
47
- self.assertEqual(ws.capacity_id, "41cb829c-c231-4e9f-b4fc-f9042a6f9840")
47
+ self.assertEqual(ws.capacity_id, "840a6c1e-5289-4094-bbc8-716daabaeeba")
48
48
 
49
49
 
50
50
  # def test_get_workspace_by_name(self):
@@ -64,7 +64,7 @@ class TestFabricClientCore(unittest.TestCase):
64
64
 
65
65
  # def test_add_role_assignment(self):
66
66
  result_status = fc.add_workspace_role_assignment(workspace_id = ws.id,
67
- principal = {"id" : "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69",
67
+ principal = {"id" : "755f273c-98f8-408c-a886-691794938bd8",
68
68
  "type" : "ServicePrincipal"},
69
69
  role = 'Member')
70
70
 
@@ -80,7 +80,7 @@ class TestFabricClientCore(unittest.TestCase):
80
80
  # Get get_workspace_role_assignment
81
81
 
82
82
  result = fc.get_workspace_role_assignment(workspace_id = ws.id,
83
- workspace_role_assignment_id = "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69")
83
+ workspace_role_assignment_id = "755f273c-98f8-408c-a886-691794938bd8")
84
84
 
85
85
  self.assertEqual(result["role"], "Member")
86
86
 
@@ -88,7 +88,7 @@ class TestFabricClientCore(unittest.TestCase):
88
88
 
89
89
  result_status_code = fc.update_workspace_role_assignment(workspace_id = ws.id,
90
90
  role = "Contributor",
91
- workspace_role_assignment_id= "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69")
91
+ workspace_role_assignment_id= "755f273c-98f8-408c-a886-691794938bd8")
92
92
 
93
93
  self.assertEqual(result_status_code, 200)
94
94
 
@@ -100,7 +100,7 @@ class TestFabricClientCore(unittest.TestCase):
100
100
 
101
101
  # def test_delete_role_assignment(self):
102
102
  result_status_code = fc.delete_workspace_role_assignment(workspace_id = ws.id,
103
- workspace_role_assignment_id = "fe9dee5d-d244-4c93-8ea1-d5e6a2225c69")
103
+ workspace_role_assignment_id = "755f273c-98f8-408c-a886-691794938bd8")
104
104
  self.assertEqual(result_status_code, 200)
105
105
 
106
106
  # def test_get_workspace_role_assignments(self):
@@ -141,11 +141,11 @@ class TestFabricClientCore(unittest.TestCase):
141
141
  result = self.fc.list_capacities()
142
142
  self.assertTrue(len(result) > 0)
143
143
  cap_ids = [cap.id for cap in result]
144
- self.assertIn("41cb829c-c231-4e9f-b4fc-f9042a6f9840", cap_ids)
144
+ self.assertIn("c861242b-c4ac-4e3a-9a21-13f65d9b17b2", cap_ids)
145
145
 
146
146
  def test_get_capacity(self):
147
- capacity = self.fc.get_capacity(capacity_id = "41cb829c-c231-4e9f-b4fc-f9042a6f9840")
148
- self.assertEqual(capacity.id, "41cb829c-c231-4e9f-b4fc-f9042a6f9840")
147
+ capacity = self.fc.get_capacity(capacity_id = "c861242b-c4ac-4e3a-9a21-13f65d9b17b2")
148
+ self.assertEqual(capacity.id, "c861242b-c4ac-4e3a-9a21-13f65d9b17b2")
149
149
 
150
150
  cap = self.fc.get_capacity(capacity_name= capacity.display_name)
151
151
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msfabricpysdkcore
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -15,11 +15,12 @@ Requires-Dist: azure-identity >=1.15.0
15
15
 
16
16
  # Python SDK for Microsoft Fabric
17
17
 
18
- This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs (v1) of Fabric*.
18
+ This is a Python SDK for Microsoft Fabric. It is a wrapper around the REST APIs (v1) of Fabric*. It supports all Fabric REST APIs as well as Azure Resource Management APIs for Fabric (as of July 23, 2024).
19
19
 
20
20
  ![Python hugging a F](assets/fabricpythontransparent.png)
21
21
 
22
22
  The Microsoft Fabric REST APIs are documented [here](https://docs.microsoft.com/en-us/rest/api/fabric/).
23
+ The Azure Resoure Management APIs for Fabric are documented [here](https://learn.microsoft.com/en-us/rest/api/microsoftfabric/fabric-capacities?view=rest-microsoftfabric-2023-11-01).
23
24
  They are designed to automate your Fabric processes.
24
25
 
25
26
  This SDK helps to interact with the Fabric APIs in a more Pythonic way.
@@ -34,7 +35,7 @@ Additionally it brings some extra features like:
34
35
 
35
36
  See the latest release notes [here](releasenotes/release_notes.md).
36
37
 
37
- Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other item specific CRUD APIs, i.e.:
38
+ Currently it supports all Core APIs, Admin APIs, all item specific CRUD APIs and Azure Resource Management APIs for Fabric capacities, i.e.:
38
39
  - Core APIs
39
40
  - [Capacities](#working-with-capacities)
40
41
  - [Deployment Pipelines](#deployment-pipelines)
@@ -58,6 +59,7 @@ Currently it supports all Core APIs, Admin APIs, Lakehouse APIs and all other it
58
59
  - List, create, update, delete warehouses, notebooks, semantic models, kql databases,.....
59
60
  - Lakehouse operations (Load table, list tables, run table maintenance)
60
61
  - Spark Pool operations
62
+ - [Azure Resource Management APIs for Fabric capacities](#azure-resource-management-apis-for-fabric-capacities)
61
63
 
62
64
  It is planned to support also new APIs which are not released yet.
63
65
  Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
@@ -100,7 +102,12 @@ fc = FabricClientCore(tenant_id = "tenant_id",
100
102
 
101
103
 
102
104
  ```
105
+ ### Getting a token
106
+ ```python
107
+ # Getting a token
103
108
 
109
+ token = fc.get_token()
110
+ ```
104
111
  ### Working with workspaces
105
112
 
106
113
  ```python
@@ -716,3 +723,57 @@ fca.revoke_external_data_share(external_data_share_id = data_shares[0]['id'],
716
723
 
717
724
  Note: This SDK is not an official SDK from Microsoft. It is a community project and not supported by Microsoft. Use it at your own risk.
718
725
  Also the API is still in preview and might change. This SDK is not yet feature complete and might not cover all APIs yet. Feel free to contribute to this project to make it better.
726
+
727
+
728
+ ### Azure Resource Management APIs for Fabric capacities
729
+
730
+ ```python
731
+ from msfabricpysdkcore import FabricAzureClient
732
+
733
+ fac = FabricAzureClient()
734
+
735
+ subscription_id = "fsdgdfgds"
736
+ resource_group_name = "fabricdemo"
737
+ capacity_name = "rgsdfgsdfgsd"
738
+ capacity_name_new = "dsfgsdfgsdfg" + datetime.now().strftime("%Y%m%d%H%M%S")
739
+
740
+ # Check name availability
741
+
742
+ resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_new)
743
+
744
+ # Create or update capacity
745
+ resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
746
+ location="westeurope",
747
+ properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
748
+ sku = "F2")
749
+
750
+ # Get capacity
751
+ resp = fac.get_capacity(subscription_id, resource_group_name, capacity_name_new)
752
+ sku = resp.sku['name']
753
+
754
+ # Delete capacity
755
+ resp = fac.delete_capacity(subscription_id, resource_group_name, capacity_name_new)
756
+
757
+ # List capacities by resource group
758
+ resp = fac.list_by_resource_group(subscription_id, resource_group_name)
759
+ cap_names = [cap["name"] for cap in resp]
760
+
761
+ # List capacities by subscription
762
+ resp = fac.list_by_subscription(subscription_id)
763
+ cap_names = [cap["name"] for cap in resp]
764
+
765
+ # List SKUs
766
+ resp = fac.list_skus(subscription_id)
767
+
768
+ # List SKUs for capacity
769
+ resp = fac.list_skus_for_capacity(subscription_id, resource_group_name, capacity_name)
770
+
771
+ # Resume capacity
772
+ resp = fac.resume_capacity(subscription_id, resource_group_name, capacity_name)
773
+
774
+ # Suspend capacity
775
+ resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
776
+
777
+ # Update capacity
778
+ resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
779
+ ```