msfabricpysdkcore 0.0.10__tar.gz → 0.0.11__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.0.10 → msfabricpysdkcore-0.0.11}/PKG-INFO +1 -1
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/auth.py +9 -6
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/client.py +5 -4
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/coreapi.py +50 -10
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/environment.py +51 -64
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/item.py +1 -4
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/otheritems.py +32 -0
- msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_datapipelines.py +48 -0
- msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_environments.py +65 -0
- msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_evenstreams.py +44 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +28 -116
- msfabricpysdkcore-0.0.11/msfabricpysdkcore/tests/test_kqldatabases.py +48 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_workspaces_capacities.py +4 -4
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/workspace.py +82 -31
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/PKG-INFO +1 -1
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/SOURCES.txt +3 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/pyproject.toml +1 -1
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/setup.py +1 -1
- msfabricpysdkcore-0.0.10/msfabricpysdkcore/tests/test_environments.py +0 -48
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/LICENSE +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/README.md +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/__init__.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/admin_item.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/admin_workspace.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/adminapi.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/capacity.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/deployment_pipeline.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/domain.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/job_instance.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/lakehouse.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/long_running_operation.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/onelakeshortcut.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/spark_custom_pool.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/__init__.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_admin_apis.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_deployment_pipeline.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_domains.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_git.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_jobs.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_shortcuts.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore/tests/test_spark.py +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/requires.txt +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
- {msfabricpysdkcore-0.0.10 → msfabricpysdkcore-0.0.11}/setup.cfg +0 -0
@@ -26,8 +26,9 @@ class FabricAuth():
|
|
26
26
|
class FabricAuthClient(FabricAuth):
|
27
27
|
"""FabricAuthClient class to interact with Entra ID"""
|
28
28
|
|
29
|
-
def __init__(self):
|
30
|
-
|
29
|
+
def __init__(self, silent = False):
|
30
|
+
if not silent:
|
31
|
+
print("Using Azure CLI for authentication")
|
31
32
|
self.auth = AzureCliCredential()
|
32
33
|
|
33
34
|
def get_token(self):
|
@@ -38,8 +39,9 @@ class FabricAuthClient(FabricAuth):
|
|
38
39
|
class FabricServicePrincipal(FabricAuth):
|
39
40
|
"""FabricServicePrincipal class to interact with Entra ID"""
|
40
41
|
|
41
|
-
def __init__(self, tenant_id, client_id, client_secret):
|
42
|
-
|
42
|
+
def __init__(self, tenant_id, client_id, client_secret, silent = False):
|
43
|
+
if not silent:
|
44
|
+
print("Using Service Principal for authentication")
|
43
45
|
|
44
46
|
self.tenant_id = tenant_id
|
45
47
|
self.client_id = client_id
|
@@ -65,9 +67,10 @@ class FabricServicePrincipal(FabricAuth):
|
|
65
67
|
class FabricSparkUtilsAuthentication(FabricAuth):
|
66
68
|
"""FabricSparkUtilsAuthentication class to interact with Entra ID"""
|
67
69
|
|
68
|
-
def __init__(self):
|
70
|
+
def __init__(self, silent = False):
|
69
71
|
mssparkutils.credentials.getToken("pbi")
|
70
|
-
|
72
|
+
if not silent:
|
73
|
+
print("Using Synapse Spark Utils for authentication")
|
71
74
|
|
72
75
|
def get_token(self):
|
73
76
|
"""Get token from Azure AD"""
|
@@ -6,7 +6,7 @@ from msfabricpysdkcore.auth import FabricAuthClient, FabricServicePrincipal, Fab
|
|
6
6
|
class FabricClient():
|
7
7
|
"""FabricClient class to interact with Fabric API"""
|
8
8
|
|
9
|
-
def __init__(self, tenant_id = None, client_id = None, client_secret = None) -> None:
|
9
|
+
def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
|
10
10
|
"""Initialize FabricClient object"""
|
11
11
|
self.tenant_id = tenant_id if tenant_id else os.getenv("FABRIC_TENANT_ID")
|
12
12
|
self.client_id = client_id if client_id else os.getenv("FABRIC_CLIENT_ID")
|
@@ -16,10 +16,11 @@ class FabricClient():
|
|
16
16
|
|
17
17
|
if self.client_id is None or self.client_secret is None or self.tenant_id is None:
|
18
18
|
try:
|
19
|
-
self.auth = FabricSparkUtilsAuthentication()
|
19
|
+
self.auth = FabricSparkUtilsAuthentication(silent=silent)
|
20
20
|
except:
|
21
|
-
self.auth = FabricAuthClient()
|
21
|
+
self.auth = FabricAuthClient(silent=silent)
|
22
22
|
else:
|
23
23
|
self.auth = FabricServicePrincipal(tenant_id = self.tenant_id,
|
24
24
|
client_id = self.client_id,
|
25
|
-
client_secret = self.client_secret
|
25
|
+
client_secret = self.client_secret,
|
26
|
+
silent=silent)
|
@@ -11,9 +11,9 @@ from msfabricpysdkcore.workspace import Workspace
|
|
11
11
|
class FabricClientCore(FabricClient):
|
12
12
|
"""FabricClientCore class to interact with Fabric Core APIs"""
|
13
13
|
|
14
|
-
def __init__(self, tenant_id = None, client_id = None, client_secret = None) -> None:
|
14
|
+
def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
|
15
15
|
"""Initialize FabricClientCore object"""
|
16
|
-
super().__init__(tenant_id, client_id, client_secret)
|
16
|
+
super().__init__(tenant_id, client_id, client_secret, silent=silent)
|
17
17
|
|
18
18
|
|
19
19
|
def list_workspaces(self, continuationToken = None):
|
@@ -414,12 +414,20 @@ class FabricClientCore(FabricClient):
|
|
414
414
|
ws = self.get_workspace_by_id(workspace_id)
|
415
415
|
return ws.get_environment(environment_id).get_staging_settings()
|
416
416
|
|
417
|
-
def update_staging_settings(self, workspace_id, environment_id,
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
417
|
+
def update_staging_settings(self, workspace_id, environment_id,
|
418
|
+
driver_cores = None, driver_memory = None, dynamic_executor_allocation = None,
|
419
|
+
executor_cores = None, executor_memory = None, instance_pool = None,
|
420
|
+
runtime_version = None, spark_properties = None):
|
421
|
+
|
422
|
+
return self.get_environment(workspace_id, environment_id).update_staging_settings(driver_cores=driver_cores,
|
423
|
+
driver_memory=driver_memory,
|
424
|
+
dynamic_executor_allocation=dynamic_executor_allocation,
|
425
|
+
executor_cores=executor_cores,
|
426
|
+
executor_memory=executor_memory,
|
427
|
+
instance_pool=instance_pool,
|
428
|
+
runtime_version=runtime_version,
|
429
|
+
spark_properties=spark_properties)
|
430
|
+
|
423
431
|
|
424
432
|
# environmentSparkLibraries
|
425
433
|
|
@@ -433,10 +441,10 @@ class FabricClientCore(FabricClient):
|
|
433
441
|
ws = self.get_workspace_by_id(workspace_id)
|
434
442
|
return ws.get_environment(environment_id).get_staging_libraries()
|
435
443
|
|
436
|
-
def
|
444
|
+
def upload_staging_library(self, workspace_id, environment_id, file_path):
|
437
445
|
"""Update staging libraries for an environment"""
|
438
446
|
ws = self.get_workspace_by_id(workspace_id)
|
439
|
-
return ws.get_environment(environment_id).
|
447
|
+
return ws.get_environment(environment_id).upload_staging_library(file_path=file_path)
|
440
448
|
|
441
449
|
def publish_environment(self, workspace_id, environment_id):
|
442
450
|
"""Publish an environment"""
|
@@ -453,6 +461,33 @@ class FabricClientCore(FabricClient):
|
|
453
461
|
ws = self.get_workspace_by_id(workspace_id)
|
454
462
|
return ws.get_environment(environment_id).cancel_publish()
|
455
463
|
|
464
|
+
# eventhouses
|
465
|
+
|
466
|
+
def list_eventhouses(self, workspace_id):
|
467
|
+
"""List eventhouses in a workspace"""
|
468
|
+
ws = self.get_workspace_by_id(workspace_id)
|
469
|
+
return ws.list_eventhouses()
|
470
|
+
|
471
|
+
def create_eventhouse(self, workspace_id, display_name, description = None):
|
472
|
+
"""Create an eventhouse in a workspace"""
|
473
|
+
ws = self.get_workspace_by_id(workspace_id)
|
474
|
+
return ws.create_eventhouse(display_name = display_name, description = description)
|
475
|
+
|
476
|
+
def get_eventhouse(self, workspace_id, eventhouse_id = None, eventhouse_name = None):
|
477
|
+
"""Get an eventhouse from a workspace"""
|
478
|
+
ws = self.get_workspace_by_id(workspace_id)
|
479
|
+
return ws.get_eventhouse(eventhouse_id = eventhouse_id, eventhouse_name = eventhouse_name)
|
480
|
+
|
481
|
+
def delete_eventhouse(self, workspace_id, eventhouse_id):
|
482
|
+
"""Delete an eventhouse from a workspace"""
|
483
|
+
ws = self.get_workspace_by_id(workspace_id)
|
484
|
+
return ws.delete_eventhouse(eventhouse_id)
|
485
|
+
|
486
|
+
def update_eventhouse(self, workspace_id, eventhouse_id, display_name = None, description = None):
|
487
|
+
"""Update an eventhouse in a workspace"""
|
488
|
+
ws = self.get_workspace_by_id(workspace_id)
|
489
|
+
return ws.update_eventhouse(eventhouse_id, display_name = display_name, description = description)
|
490
|
+
|
456
491
|
# eventstreams
|
457
492
|
|
458
493
|
def list_eventstreams(self, workspace_id):
|
@@ -486,6 +521,11 @@ class FabricClientCore(FabricClient):
|
|
486
521
|
"""List kql databases in a workspace"""
|
487
522
|
ws = self.get_workspace_by_id(workspace_id)
|
488
523
|
return ws.list_kql_databases()
|
524
|
+
|
525
|
+
def create_kql_database(self, workspace_id, creation_payload, display_name, description = None):
|
526
|
+
"""Create a kql database in a workspace"""
|
527
|
+
ws = self.get_workspace_by_id(workspace_id)
|
528
|
+
return ws.create_kql_database(creation_payload = creation_payload, display_name = display_name, description = description)
|
489
529
|
|
490
530
|
def get_kql_database(self, workspace_id, kql_database_id = None, kql_database_name = None):
|
491
531
|
"""Get a kql database from a workspace"""
|
@@ -8,23 +8,13 @@ from msfabricpysdkcore.long_running_operation import check_long_running_operatio
|
|
8
8
|
class Environment(Item):
|
9
9
|
"""Class to represent a item in Microsoft Fabric"""
|
10
10
|
|
11
|
-
def __init__(self, id, display_name, type, workspace_id, auth, properties = None, definition=None, description=""
|
12
|
-
sparkcompute = None, staging_sparkcompute = None, libraries = None, staging_libraries = None):
|
11
|
+
def __init__(self, id, display_name, type, workspace_id, auth, properties = None, definition=None, description=""):
|
13
12
|
super().__init__(id, display_name, type, workspace_id, auth, properties, definition, description)
|
14
13
|
|
15
|
-
self.sparkcompute = sparkcompute
|
16
|
-
self.staging_sparkcompute = staging_sparkcompute
|
17
|
-
self.libraries = libraries
|
18
|
-
self.staging_libraries = staging_libraries
|
19
|
-
|
20
14
|
def from_dict(item_dict, auth):
|
21
15
|
return Environment(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
|
22
16
|
properties=item_dict.get('properties', None),
|
23
|
-
definition=item_dict.get('definition', None), description=item_dict.get('description', ""),
|
24
|
-
sparkcompute=item_dict.get('sparkcompute', None),
|
25
|
-
staging_sparkcompute=item_dict.get('staging_sparkcompute', None),
|
26
|
-
libraries=item_dict.get('libraries', None),
|
27
|
-
staging_libraries=item_dict.get('staging_libraries', None),
|
17
|
+
definition=item_dict.get('definition', None), description=item_dict.get('description', ""),
|
28
18
|
auth=auth)
|
29
19
|
|
30
20
|
# GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/sparkcompute
|
@@ -39,14 +29,10 @@ class Environment(Item):
|
|
39
29
|
sleep(10)
|
40
30
|
continue
|
41
31
|
if response.status_code not in (200, 429):
|
42
|
-
|
43
|
-
print(response.text)
|
44
|
-
print(self)
|
45
|
-
raise Exception(f"Error getting published settings: {response.text}")
|
32
|
+
raise Exception(f"Error getting published settings: {response.status_code}, {response.text}")
|
46
33
|
break
|
47
34
|
|
48
35
|
resp_json = json.loads(response.text)
|
49
|
-
self.sparkcompute = resp_json
|
50
36
|
return resp_json
|
51
37
|
|
52
38
|
# GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/sparkcompute
|
@@ -62,30 +48,38 @@ class Environment(Item):
|
|
62
48
|
sleep(10)
|
63
49
|
continue
|
64
50
|
if response.status_code not in (200, 429):
|
65
|
-
|
66
|
-
print(response.text)
|
67
|
-
print(self)
|
68
|
-
raise Exception(f"Error getting staging settings: {response.text}")
|
51
|
+
raise Exception(f"Error getting staging settings: {response.status_code}, {response.text}")
|
69
52
|
break
|
70
53
|
|
71
54
|
resp_json = json.loads(response.text)
|
72
|
-
self.staging_sparkcompute = resp_json
|
73
55
|
return resp_json
|
74
56
|
|
75
|
-
|
76
|
-
|
57
|
+
|
58
|
+
def update_staging_settings(self,
|
59
|
+
driver_cores = None, driver_memory = None, dynamic_executor_allocation = None,
|
60
|
+
executor_cores = None, executor_memory = None, instance_pool = None,
|
61
|
+
runtime_version = None, spark_properties = None):
|
77
62
|
"""Update the staging settings of the environment"""
|
78
63
|
url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/sparkcompute"
|
79
|
-
body = {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
64
|
+
body = {}
|
65
|
+
if driver_cores is not None:
|
66
|
+
body['driverCores'] = driver_cores
|
67
|
+
if driver_memory is not None:
|
68
|
+
body['driverMemory'] = driver_memory
|
69
|
+
if dynamic_executor_allocation is not None:
|
70
|
+
body['dynamicExecutorAllocation'] = dynamic_executor_allocation
|
71
|
+
if executor_cores is not None:
|
72
|
+
body['executorCores'] = executor_cores
|
73
|
+
if executor_memory is not None:
|
74
|
+
body['executorMemory'] = executor_memory
|
75
|
+
if instance_pool is not None:
|
76
|
+
body['instancePool'] = instance_pool
|
77
|
+
if runtime_version is not None:
|
78
|
+
body['runtimeVersion'] = runtime_version
|
79
|
+
if spark_properties is not None:
|
80
|
+
body['sparkProperties'] = spark_properties
|
81
|
+
|
82
|
+
|
89
83
|
for _ in range(10):
|
90
84
|
response = requests.patch(url=url, headers=self.auth.get_headers(), json=body)
|
91
85
|
if response.status_code == 429:
|
@@ -93,14 +87,10 @@ class Environment(Item):
|
|
93
87
|
sleep(10)
|
94
88
|
continue
|
95
89
|
if response.status_code not in (200, 429):
|
96
|
-
|
97
|
-
print(response.text)
|
98
|
-
print(self)
|
99
|
-
raise Exception(f"Error updating staging settings: {response.text}")
|
90
|
+
raise Exception(f"Error updating staging settings: {response.status_code}, {response.text}")
|
100
91
|
break
|
101
92
|
|
102
|
-
|
103
|
-
return body
|
93
|
+
return json.loads(response.text)
|
104
94
|
|
105
95
|
# GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/libraries
|
106
96
|
|
@@ -115,14 +105,10 @@ class Environment(Item):
|
|
115
105
|
sleep(10)
|
116
106
|
continue
|
117
107
|
if response.status_code not in (200, 429):
|
118
|
-
|
119
|
-
print(response.text)
|
120
|
-
print(self)
|
121
|
-
raise Exception(f"Error getting published libraries: {response.text}")
|
108
|
+
raise Exception(f"Error getting published libraries: {response.status_code}, {response.text}")
|
122
109
|
break
|
123
110
|
|
124
111
|
resp_json = json.loads(response.text)
|
125
|
-
self.libraries = resp_json
|
126
112
|
return resp_json
|
127
113
|
|
128
114
|
# GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries
|
@@ -138,19 +124,29 @@ class Environment(Item):
|
|
138
124
|
sleep(10)
|
139
125
|
continue
|
140
126
|
if response.status_code not in (200, 429):
|
141
|
-
|
142
|
-
print(response.text)
|
143
|
-
print(self)
|
144
|
-
raise Exception(f"Error getting staging libraries: {response.text}")
|
127
|
+
raise Exception(f"Error getting staging libraries: {response.status_code}, {response.text}")
|
145
128
|
break
|
146
129
|
|
147
130
|
resp_json = json.loads(response.text)
|
148
|
-
self.staging_libraries = resp_json
|
149
131
|
return resp_json
|
150
132
|
|
151
133
|
|
152
|
-
def
|
153
|
-
|
134
|
+
def upload_staging_library(self, file_path):
|
135
|
+
# POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries
|
136
|
+
raise NotImplementedError("Not implemented yet")
|
137
|
+
# url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries"
|
138
|
+
|
139
|
+
# for _ in range(10):
|
140
|
+
# response = requests.post(url=url, files={'file': file_path}, headers=self.auth.get_headers())
|
141
|
+
# if response.status_code == 429:
|
142
|
+
# print("Too many requests, waiting 10 seconds")
|
143
|
+
# sleep(10)
|
144
|
+
# continue
|
145
|
+
# if response.status_code not in (200, 429):
|
146
|
+
# raise Exception(f"Error uploading staging libraries: {response.status_code}, {response.text}")
|
147
|
+
# break
|
148
|
+
|
149
|
+
# return json.loads(response.text)
|
154
150
|
|
155
151
|
# DELETE https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries?libraryToDelete={libraryToDelete}
|
156
152
|
|
@@ -165,10 +161,7 @@ class Environment(Item):
|
|
165
161
|
sleep(10)
|
166
162
|
continue
|
167
163
|
if response.status_code not in (200, 429):
|
168
|
-
|
169
|
-
print(response.text)
|
170
|
-
print(self)
|
171
|
-
raise Exception(f"Error deleting staging libraries: {response.text}")
|
164
|
+
raise Exception(f"Error deleting staging libraries: {response.status_code}, {response.text}")
|
172
165
|
break
|
173
166
|
|
174
167
|
return response.text
|
@@ -189,10 +182,7 @@ class Environment(Item):
|
|
189
182
|
publish_info = check_long_running_operation(response.headers, self.auth)
|
190
183
|
return publish_info
|
191
184
|
if response.status_code not in (200, 429):
|
192
|
-
|
193
|
-
print(response.text)
|
194
|
-
print(self)
|
195
|
-
raise Exception(f"Error publishing staging: {response.text}")
|
185
|
+
raise Exception(f"Error publishing staging: {response.status_code}, {response.text}")
|
196
186
|
break
|
197
187
|
|
198
188
|
resp_dict = json.loads(response.text)
|
@@ -212,10 +202,7 @@ class Environment(Item):
|
|
212
202
|
sleep(10)
|
213
203
|
continue
|
214
204
|
if response.status_code not in (200, 429):
|
215
|
-
|
216
|
-
print(response.text)
|
217
|
-
print(self)
|
218
|
-
raise Exception(f"Error canceling publishing: {response.text}")
|
205
|
+
raise Exception(f"Error canceling publishing: {response.status_code}, {response.text}")
|
219
206
|
break
|
220
207
|
|
221
208
|
resp_dict = json.loads(response.text)
|
@@ -58,10 +58,7 @@ class Item:
|
|
58
58
|
sleep(10)
|
59
59
|
continue
|
60
60
|
if response.status_code not in (200, 429):
|
61
|
-
|
62
|
-
print(response.text)
|
63
|
-
print(self)
|
64
|
-
raise Exception(f"Error deleting item: {response.text}")
|
61
|
+
raise Exception(f"Error deleting item: {response.status_code}, {response.text}")
|
65
62
|
break
|
66
63
|
|
67
64
|
return response.status_code
|
@@ -3,6 +3,38 @@ from time import sleep
|
|
3
3
|
import requests
|
4
4
|
from msfabricpysdkcore.item import Item
|
5
5
|
|
6
|
+
|
7
|
+
class Eventhouse(Item):
|
8
|
+
"""Class to represent a eventhouse in Microsoft Fabric"""
|
9
|
+
|
10
|
+
def __init__(self, id, display_name, type, workspace_id, auth, properties = None, description=""):
|
11
|
+
super().__init__(id = id, display_name=display_name, type=type,
|
12
|
+
workspace_id=workspace_id, auth=auth, properties=properties,
|
13
|
+
description=description)
|
14
|
+
|
15
|
+
def from_dict(item_dict, auth):
|
16
|
+
if "displayName" not in item_dict:
|
17
|
+
item_dict["displayName"] = item_dict["display_name"]
|
18
|
+
if "workspaceId" not in item_dict:
|
19
|
+
item_dict["workspaceId"] = item_dict["workspace_id"]
|
20
|
+
|
21
|
+
return Eventhouse(id=item_dict['id'], display_name=item_dict['displayName'],
|
22
|
+
type=item_dict['type'], workspace_id=item_dict['workspaceId'],
|
23
|
+
properties=item_dict.get('properties', None),
|
24
|
+
description=item_dict.get('description', ""), auth=auth)
|
25
|
+
|
26
|
+
def create_kql_database(self, display_name = None, description= None):
|
27
|
+
from msfabricpysdkcore.coreapi import FabricClientCore
|
28
|
+
"""Method to create a kql database in the eventhouse"""
|
29
|
+
creation_payload = {"databaseType" : "ReadWrite",
|
30
|
+
"parentEventhouseItemId" : self.id}
|
31
|
+
|
32
|
+
fcc = FabricClientCore(silent=True)
|
33
|
+
|
34
|
+
return fcc.create_kql_database(workspace_id = self.workspace_id,
|
35
|
+
display_name = display_name, description = description,
|
36
|
+
creation_payload= creation_payload)
|
37
|
+
|
6
38
|
class SparkJobDefinition(Item):
|
7
39
|
"""Class to represent a spark job definition in Microsoft Fabric"""
|
8
40
|
|
@@ -0,0 +1,48 @@
|
|
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 = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
|
20
|
+
|
21
|
+
dps = fc.list_data_pipelines(workspace_id)
|
22
|
+
dp_names = [dp.display_name for dp in dps]
|
23
|
+
self.assertGreater(len(dps), 0)
|
24
|
+
self.assertIn("pipeline1", dp_names)
|
25
|
+
|
26
|
+
dp = fc.get_data_pipeline(workspace_id, data_pipeline_name="pipeline1")
|
27
|
+
self.assertIsNotNone(dp.id)
|
28
|
+
self.assertIsNotNone(dp.definition)
|
29
|
+
self.assertEqual(dp.display_name, "pipeline1")
|
30
|
+
|
31
|
+
dp_new = fc.create_data_pipeline(workspace_id, display_name="pipeline_new", description="asda")
|
32
|
+
dp_new.update_definition(dp.definition)
|
33
|
+
|
34
|
+
self.assertEqual(dp_new.display_name, "pipeline_new")
|
35
|
+
|
36
|
+
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name="pipeline2")
|
37
|
+
|
38
|
+
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
39
|
+
self.assertEqual(dp.display_name, "pipeline2")
|
40
|
+
self.assertEqual(dp.id, dp2.id)
|
41
|
+
|
42
|
+
dp2 = fc.update_data_pipeline(workspace_id, dp.id, display_name="pipeline1")
|
43
|
+
|
44
|
+
dp = fc.get_data_pipeline(workspace_id, data_pipeline_id=dp.id)
|
45
|
+
self.assertEqual(dp.display_name, "pipeline1")
|
46
|
+
self.assertEqual(dp.id, dp2.id)
|
47
|
+
status_code = fc.delete_data_pipeline(workspace_id, dp_new.id)
|
48
|
+
self.assertEqual(status_code, 200)
|
@@ -0,0 +1,65 @@
|
|
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 = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
|
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)
|
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 = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
|
45
|
+
environment_id = 'fae6d1a7-d671-4091-89b1-f42626deb56f'
|
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)
|
@@ -0,0 +1,44 @@
|
|
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_eventstreams(self):
|
17
|
+
|
18
|
+
fc = self.fc
|
19
|
+
workspace_id = 'd8a5abe0-9eed-406d-ab46-343bc57ddbe5'
|
20
|
+
|
21
|
+
datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
22
|
+
es_name = "es" + datetime_str
|
23
|
+
|
24
|
+
eventstream = fc.create_eventstream(workspace_id, display_name=es_name)
|
25
|
+
self.assertEqual(eventstream.display_name, es_name)
|
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)
|
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)
|
36
|
+
|
37
|
+
es2 = fc.update_eventstream(workspace_id, es.id, display_name=f"{es_name}2")
|
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)
|
42
|
+
|
43
|
+
status_code = fc.delete_eventstream(workspace_id, es.id)
|
44
|
+
self.assertEqual(status_code, 200)
|