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.
- msfabricpysdkcore/__init__.py +2 -1
- msfabricpysdkcore/admin_item.py +1 -1
- msfabricpysdkcore/adminapi.py +3 -1
- msfabricpysdkcore/auth.py +10 -6
- msfabricpysdkcore/client.py +10 -7
- msfabricpysdkcore/coreapi.py +4 -1
- msfabricpysdkcore/fabric_azure_capacity.py +77 -0
- msfabricpysdkcore/fabric_azure_client.py +228 -0
- msfabricpysdkcore/tests/test_admin_apis.py +8 -9
- msfabricpysdkcore/tests/test_datapipelines.py +1 -1
- msfabricpysdkcore/tests/test_domains.py +2 -2
- msfabricpysdkcore/tests/test_environments.py +6 -6
- msfabricpysdkcore/tests/test_evenhouses.py +1 -2
- msfabricpysdkcore/tests/test_evenstreams.py +20 -20
- msfabricpysdkcore/tests/test_external_data_shares.py +3 -3
- msfabricpysdkcore/tests/test_fabric_azure_client.py +78 -0
- msfabricpysdkcore/tests/test_git.py +8 -9
- msfabricpysdkcore/tests/test_items.py +3 -2
- msfabricpysdkcore/tests/test_jobs.py +2 -2
- msfabricpysdkcore/tests/test_kql_queryset.py +1 -2
- msfabricpysdkcore/tests/test_kqldatabases.py +2 -2
- msfabricpysdkcore/tests/test_lakehouse.py +5 -7
- msfabricpysdkcore/tests/test_ml_experiments.py +1 -2
- msfabricpysdkcore/tests/test_ml_models.py +1 -2
- msfabricpysdkcore/tests/test_notebooks.py +1 -2
- msfabricpysdkcore/tests/test_one_lake_data_access_security.py +2 -4
- msfabricpysdkcore/tests/test_other_items.py +6 -7
- msfabricpysdkcore/tests/test_reports.py +1 -2
- msfabricpysdkcore/tests/test_semantic_model.py +3 -4
- msfabricpysdkcore/tests/test_shortcuts.py +4 -4
- msfabricpysdkcore/tests/test_spark.py +2 -4
- msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
- msfabricpysdkcore/tests/test_warehouses.py +1 -2
- msfabricpysdkcore/tests/test_workspaces_capacities.py +9 -9
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/METADATA +64 -3
- msfabricpysdkcore-0.1.2.dist-info/RECORD +55 -0
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/WHEEL +1 -1
- msfabricpysdkcore-0.1.1.dist-info/RECORD +0 -52
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/LICENSE +0 -0
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.2.dist-info}/top_level.txt +0 -0
msfabricpysdkcore/__init__.py
CHANGED
msfabricpysdkcore/admin_item.py
CHANGED
@@ -74,7 +74,7 @@ class AdminItem:
|
|
74
74
|
description = item_dict.get('description', None),
|
75
75
|
last_updated_date = item_dict['lastUpdatedDate'],
|
76
76
|
capacity_id = item_dict['capacityId'],
|
77
|
-
creator_principal = item_dict
|
77
|
+
creator_principal = item_dict.get('creatorPrincipal', None),
|
78
78
|
admin_client = admin_client
|
79
79
|
)
|
80
80
|
|
msfabricpysdkcore/adminapi.py
CHANGED
@@ -10,7 +10,9 @@ class FabricClientAdmin(FabricClient):
|
|
10
10
|
|
11
11
|
def __init__(self, tenant_id = None, client_id = None, client_secret = None) -> None:
|
12
12
|
"""Initialize FabricClientAdmin object"""
|
13
|
-
super().__init__(
|
13
|
+
super().__init__(scope="https://api.fabric.microsoft.com/.default",
|
14
|
+
tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
|
15
|
+
|
14
16
|
|
15
17
|
def long_running_operation(self, response_headers):
|
16
18
|
"""Check the status of a long running operation"""
|
msfabricpysdkcore/auth.py
CHANGED
@@ -8,6 +8,9 @@ except ImportError:
|
|
8
8
|
class FabricAuth():
|
9
9
|
"""FabricAuth class to interact with Entra ID"""
|
10
10
|
|
11
|
+
def __init__(self, scope):
|
12
|
+
self.scope = scope
|
13
|
+
|
11
14
|
@abstractmethod
|
12
15
|
def get_token(self):
|
13
16
|
"""Get token from Azure AD"""
|
@@ -26,20 +29,23 @@ class FabricAuth():
|
|
26
29
|
class FabricAuthClient(FabricAuth):
|
27
30
|
"""FabricAuthClient class to interact with Entra ID"""
|
28
31
|
|
29
|
-
def __init__(self, silent = False):
|
32
|
+
def __init__(self, scope, silent = False):
|
33
|
+
super().__init__(scope)
|
30
34
|
if not silent:
|
31
35
|
print("Using Azure CLI for authentication")
|
32
36
|
self.auth = AzureCliCredential()
|
33
37
|
|
34
38
|
def get_token(self):
|
35
39
|
"""Get token from Azure AD"""
|
36
|
-
token = self.auth.get_token(
|
40
|
+
token = self.auth.get_token(self.scope)
|
37
41
|
return token.token
|
38
42
|
|
39
43
|
class FabricServicePrincipal(FabricAuth):
|
40
44
|
"""FabricServicePrincipal class to interact with Entra ID"""
|
41
45
|
|
42
|
-
def __init__(self, tenant_id, client_id, client_secret, silent = False):
|
46
|
+
def __init__(self, tenant_id, client_id, client_secret, scope, silent = False):
|
47
|
+
super().__init__(scope)
|
48
|
+
|
43
49
|
if not silent:
|
44
50
|
print("Using Service Principal for authentication")
|
45
51
|
|
@@ -47,8 +53,6 @@ class FabricServicePrincipal(FabricAuth):
|
|
47
53
|
self.client_id = client_id
|
48
54
|
self.client_secret = client_secret
|
49
55
|
|
50
|
-
self.scope = "https://api.fabric.microsoft.com/.default"
|
51
|
-
|
52
56
|
|
53
57
|
def get_token(self):
|
54
58
|
"""Get token from Azure AD"""
|
@@ -67,7 +71,7 @@ class FabricServicePrincipal(FabricAuth):
|
|
67
71
|
class FabricSparkUtilsAuthentication(FabricAuth):
|
68
72
|
"""FabricSparkUtilsAuthentication class to interact with Entra ID"""
|
69
73
|
|
70
|
-
def __init__(self, silent = False):
|
74
|
+
def __init__(self, scope, silent = False):
|
71
75
|
mssparkutils.credentials.getToken("pbi")
|
72
76
|
if not silent:
|
73
77
|
print("Using Synapse Spark Utils for authentication")
|
msfabricpysdkcore/client.py
CHANGED
@@ -9,26 +9,29 @@ from msfabricpysdkcore.auth import FabricAuthClient, FabricServicePrincipal, Fab
|
|
9
9
|
class FabricClient():
|
10
10
|
"""FabricClient class to interact with Fabric API"""
|
11
11
|
|
12
|
-
def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
|
12
|
+
def __init__(self, scope, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
|
13
13
|
"""Initialize FabricClient object"""
|
14
14
|
self.tenant_id = tenant_id if tenant_id else os.getenv("FABRIC_TENANT_ID")
|
15
15
|
self.client_id = client_id if client_id else os.getenv("FABRIC_CLIENT_ID")
|
16
16
|
self.client_secret = client_secret if client_secret else os.getenv("FABRIC_CLIENT_SECRET")
|
17
|
-
|
18
|
-
self.scope = "https://api.fabric.microsoft.com/.default"
|
17
|
+
self.scope = scope
|
18
|
+
#self.scope = "https://api.fabric.microsoft.com/.default"
|
19
19
|
|
20
20
|
if self.client_id is None or self.client_secret is None or self.tenant_id is None:
|
21
21
|
try:
|
22
|
-
self.auth = FabricSparkUtilsAuthentication(silent=silent)
|
22
|
+
self.auth = FabricSparkUtilsAuthentication(self.scope, silent=silent)
|
23
23
|
except:
|
24
|
-
self.auth = FabricAuthClient(silent=silent)
|
24
|
+
self.auth = FabricAuthClient(self.scope, silent=silent)
|
25
25
|
else:
|
26
|
-
self.auth = FabricServicePrincipal(
|
26
|
+
self.auth = FabricServicePrincipal(scope= self.scope,
|
27
|
+
tenant_id = self.tenant_id,
|
27
28
|
client_id = self.client_id,
|
28
29
|
client_secret = self.client_secret,
|
29
30
|
silent=silent)
|
30
31
|
|
31
|
-
|
32
|
+
def get_token(self):
|
33
|
+
"""Get token from Entra"""
|
34
|
+
return self.auth.get_token()
|
32
35
|
|
33
36
|
def calling_routine(self, url, operation, body = None, headers=None, file_path = None, response_codes = [200], error_message = "Error",
|
34
37
|
continue_on_error_code = False, return_format = "value_json", paging = False,
|
msfabricpysdkcore/coreapi.py
CHANGED
@@ -8,7 +8,10 @@ class FabricClientCore(FabricClient):
|
|
8
8
|
|
9
9
|
def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
|
10
10
|
"""Initialize FabricClientCore object"""
|
11
|
-
super().__init__(
|
11
|
+
super().__init__(scope="https://api.fabric.microsoft.com/.default",
|
12
|
+
tenant_id=tenant_id,
|
13
|
+
client_id=client_id,
|
14
|
+
client_secret=client_secret, silent=silent)
|
12
15
|
|
13
16
|
def long_running_operation(self, response_headers):
|
14
17
|
"""Check the status of a long running operation"""
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from msfabricpysdkcore.fabric_azure_client import FabricAzureClient
|
4
|
+
|
5
|
+
class FabricAzureCapacity:
|
6
|
+
"""Class to represent a item in Microsoft Fabric"""
|
7
|
+
|
8
|
+
def __init__(self, id, name, subscription_id, resource_group_name, type, location, properties, sku, azure_client: FabricAzureClient, tags=None) -> None:
|
9
|
+
|
10
|
+
self.id = id
|
11
|
+
self.name = name
|
12
|
+
self.subscription_id = subscription_id
|
13
|
+
self.resource_group_name = resource_group_name
|
14
|
+
self.type = type
|
15
|
+
self.location = location
|
16
|
+
self.properties = properties
|
17
|
+
self.sku = sku
|
18
|
+
self.tags = tags
|
19
|
+
|
20
|
+
self.azure_client = azure_client
|
21
|
+
|
22
|
+
def __str__(self) -> str:
|
23
|
+
"""Return a string representation of the fabric azure capacity object"""
|
24
|
+
dict_ = {
|
25
|
+
'id': self.id,
|
26
|
+
'name': self.name,
|
27
|
+
'subscription_id': self.subscription_id,
|
28
|
+
'resource_group_name': self.resource_group_name,
|
29
|
+
'type': self.type,
|
30
|
+
'location': self.location,
|
31
|
+
'properties': self.properties,
|
32
|
+
'sku': self.sku,
|
33
|
+
'tags': self.tags
|
34
|
+
}
|
35
|
+
return json.dumps(dict_, indent=2)
|
36
|
+
|
37
|
+
def __repr__(self) -> str:
|
38
|
+
return self.__str__()
|
39
|
+
|
40
|
+
def from_dict(dict, azure_client):
|
41
|
+
"""Create FabricAzureCapacity object from dictionary"""
|
42
|
+
|
43
|
+
return FabricAzureCapacity(id=dict['id'], name=dict['name'], subscription_id=dict['subscription_id'],
|
44
|
+
resource_group_name=dict['resource_group_name'],
|
45
|
+
type=dict['type'],
|
46
|
+
location=dict['location'],
|
47
|
+
properties=dict['properties'], sku=dict['sku'],
|
48
|
+
tags=dict.get('tags', None), azure_client=azure_client)
|
49
|
+
|
50
|
+
# Delete
|
51
|
+
|
52
|
+
def delete(self):
|
53
|
+
"""Delete the capacity"""
|
54
|
+
|
55
|
+
return self.azure_client.delete_capacity(self.subscription_id, self.resource_group_name, self.name)
|
56
|
+
|
57
|
+
# Resume
|
58
|
+
|
59
|
+
def resume(self):
|
60
|
+
"""Resume the capacity"""
|
61
|
+
|
62
|
+
return self.azure_client.resume_capacity(self.subscription_id, self.resource_group_name, self.name)
|
63
|
+
|
64
|
+
# Suspend
|
65
|
+
|
66
|
+
def suspend(self):
|
67
|
+
"""Suspend the capacity"""
|
68
|
+
|
69
|
+
return self.azure_client.suspend_capacity(self.subscription_id, self.resource_group_name, self.name)
|
70
|
+
|
71
|
+
# Update
|
72
|
+
|
73
|
+
def update(self, properties_administration=None, sku=None, tags=None):
|
74
|
+
"""Update the capacity"""
|
75
|
+
|
76
|
+
return self.azure_client.update_capacity(self.subscription_id, self.resource_group_name, self.name, properties_administration=properties_administration, sku=sku, tags=tags)
|
77
|
+
|
@@ -0,0 +1,228 @@
|
|
1
|
+
from msfabricpysdkcore.client import FabricClient
|
2
|
+
|
3
|
+
|
4
|
+
class FabricAzureClient(FabricClient):
|
5
|
+
|
6
|
+
def __init__(self, tenant_id=None, client_id=None, client_secret=None, silent=False) -> None:
|
7
|
+
super().__init__(scope = "https://management.azure.com/",
|
8
|
+
tenant_id = tenant_id,
|
9
|
+
client_id = client_id,
|
10
|
+
client_secret = client_secret,
|
11
|
+
silent = silent)
|
12
|
+
|
13
|
+
|
14
|
+
def check_name_availability(self, subscription_id, location, name, type = "Microsoft.Fabric/capacities"):
|
15
|
+
"""Check name availability
|
16
|
+
Args:
|
17
|
+
subscription_id (str): The subscription ID
|
18
|
+
location (str): The location
|
19
|
+
name (str): The name
|
20
|
+
type (str): The type
|
21
|
+
Returns:
|
22
|
+
dict: The response
|
23
|
+
"""
|
24
|
+
|
25
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Fabric/locations/{location}/checkNameAvailability?api-version=2023-11-01"
|
26
|
+
|
27
|
+
body = {
|
28
|
+
"name": name,
|
29
|
+
"type": type
|
30
|
+
}
|
31
|
+
|
32
|
+
response = self.calling_routine(url=url, operation="POST", body=body, response_codes=[200], return_format="json", error_message="Failed to check name availability")
|
33
|
+
return response
|
34
|
+
|
35
|
+
def create_or_update_capacity(self, subscription_id, resource_group_name, capacity_name, location, properties_administration, sku, tags = None):
|
36
|
+
"""Create or update capacity
|
37
|
+
Args:
|
38
|
+
subscription_id (str): The subscription ID
|
39
|
+
resource_group_name (str): The resource group name
|
40
|
+
capacity_name (str): The capacity name
|
41
|
+
location (str): The location
|
42
|
+
properties_administration (dict): The administration properties
|
43
|
+
sku (dict): The sku
|
44
|
+
tags (dict): The tags
|
45
|
+
Returns:
|
46
|
+
FabricAzureCapacity: The capacity
|
47
|
+
"""
|
48
|
+
from msfabricpysdkcore.fabric_azure_capacity import FabricAzureCapacity
|
49
|
+
|
50
|
+
if sku and "name" in sku:
|
51
|
+
sku = sku["name"]
|
52
|
+
|
53
|
+
body = {
|
54
|
+
"location": location,
|
55
|
+
"properties": {
|
56
|
+
"administration": properties_administration
|
57
|
+
},
|
58
|
+
"sku": {"name": sku,
|
59
|
+
"tier": "Fabric"}
|
60
|
+
}
|
61
|
+
|
62
|
+
if tags is not None:
|
63
|
+
body["tags"] = tags
|
64
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
|
65
|
+
|
66
|
+
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")
|
67
|
+
response["subscription_id"] = subscription_id
|
68
|
+
response["resource_group_name"] = resource_group_name
|
69
|
+
|
70
|
+
return FabricAzureCapacity.from_dict(response, self)
|
71
|
+
|
72
|
+
|
73
|
+
def delete_capacity(self, subscription_id, resource_group_name, capacity_name):
|
74
|
+
"""Delete capacity
|
75
|
+
Args:
|
76
|
+
subscription_id (str): The subscription ID
|
77
|
+
resource_group_name (str): The resource group name
|
78
|
+
capacity_name (str): The capacity name
|
79
|
+
Returns:
|
80
|
+
dict: The response
|
81
|
+
"""
|
82
|
+
|
83
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
|
84
|
+
|
85
|
+
response = self.calling_routine(url=url, operation="DELETE", response_codes=[202], return_format="response", error_message="Failed to delete capacity")
|
86
|
+
return response
|
87
|
+
|
88
|
+
|
89
|
+
def get_capacity(self, subscription_id, resource_group_name, capacity_name):
|
90
|
+
"""Get capacity
|
91
|
+
Args:
|
92
|
+
subscription_id (str): The subscription ID
|
93
|
+
resource_group_name (str): The resource group name
|
94
|
+
capacity_name (str): The capacity name
|
95
|
+
Returns:
|
96
|
+
FabricAzureCapacity: The capacity
|
97
|
+
"""
|
98
|
+
from msfabricpysdkcore.fabric_azure_capacity import FabricAzureCapacity
|
99
|
+
|
100
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
|
101
|
+
|
102
|
+
response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="json", error_message="Failed to get capacity")
|
103
|
+
response["subscription_id"] = subscription_id
|
104
|
+
response["resource_group_name"] = resource_group_name
|
105
|
+
|
106
|
+
return FabricAzureCapacity.from_dict(response, self)
|
107
|
+
|
108
|
+
def list_by_resource_group(self, subscription_id, resource_group_name):
|
109
|
+
"""List capacities by resource group
|
110
|
+
Args:
|
111
|
+
subscription_id (str): The subscription ID
|
112
|
+
resource_group_name (str): The resource group name
|
113
|
+
Returns:
|
114
|
+
dict: The response
|
115
|
+
"""
|
116
|
+
|
117
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities?api-version=2023-11-01"
|
118
|
+
|
119
|
+
response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list capacities by resource group")
|
120
|
+
return response
|
121
|
+
|
122
|
+
|
123
|
+
def list_by_subscription(self, subscription_id):
|
124
|
+
"""List capacities by subscription
|
125
|
+
Args:
|
126
|
+
subscription_id (str): The subscription ID
|
127
|
+
Returns:
|
128
|
+
dict: The response
|
129
|
+
"""
|
130
|
+
|
131
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Fabric/capacities?api-version=2023-11-01"
|
132
|
+
|
133
|
+
response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list capacities by subscription")
|
134
|
+
return response
|
135
|
+
|
136
|
+
def list_skus(self, subscription_id):
|
137
|
+
"""List skus
|
138
|
+
Args:
|
139
|
+
subscription_id (str): The subscription ID
|
140
|
+
Returns:
|
141
|
+
dict: The response
|
142
|
+
"""
|
143
|
+
|
144
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.Fabric/skus?api-version=2023-11-01"
|
145
|
+
|
146
|
+
response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list skus")
|
147
|
+
return response
|
148
|
+
|
149
|
+
def list_skus_for_capacity(self, subscription_id, resource_group_name, capacity_name):
|
150
|
+
"""List skus for capacity
|
151
|
+
Args:
|
152
|
+
subscription_id (str): The subscription ID
|
153
|
+
resource_group_name (str): The resource group name
|
154
|
+
capacity_name (str): The capacity name
|
155
|
+
Returns:
|
156
|
+
dict: The response
|
157
|
+
"""
|
158
|
+
|
159
|
+
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"
|
160
|
+
|
161
|
+
response = self.calling_routine(url=url, operation="GET", response_codes=[200], return_format="value_json", error_message="Failed to list skus for capacity")
|
162
|
+
return response
|
163
|
+
|
164
|
+
def resume_capacity(self, subscription_id, resource_group_name, capacity_name):
|
165
|
+
"""Resume capacity
|
166
|
+
Args:
|
167
|
+
subscription_id (str): The subscription ID
|
168
|
+
resource_group_name (str): The resource group name
|
169
|
+
capacity_name (str): The capacity name
|
170
|
+
Returns:
|
171
|
+
dict: The response
|
172
|
+
"""
|
173
|
+
|
174
|
+
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"
|
175
|
+
|
176
|
+
response = self.calling_routine(url=url, operation="POST", response_codes=[202], return_format="response", error_message="Failed to resume capacity")
|
177
|
+
return response
|
178
|
+
|
179
|
+
def suspend_capacity(self, subscription_id, resource_group_name, capacity_name):
|
180
|
+
"""Suspend capacity
|
181
|
+
Args:
|
182
|
+
subscription_id (str): The subscription ID
|
183
|
+
resource_group_name (str): The resource group name
|
184
|
+
capacity_name (str): The capacity name
|
185
|
+
Returns:
|
186
|
+
dict: The response
|
187
|
+
"""
|
188
|
+
|
189
|
+
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"
|
190
|
+
|
191
|
+
response = self.calling_routine(url=url, operation="POST", response_codes=[202], return_format="response", error_message="Failed to suspend capacity")
|
192
|
+
return response
|
193
|
+
|
194
|
+
def update_capacity(self, subscription_id, resource_group_name, capacity_name, properties_administration = None, sku = None, tags = None):
|
195
|
+
"""Update capacity
|
196
|
+
Args:
|
197
|
+
subscription_id (str): The subscription ID
|
198
|
+
resource_group_name (str): The resource group name
|
199
|
+
capacity_name (str): The capacity name
|
200
|
+
body (dict): The body of the request
|
201
|
+
Returns:
|
202
|
+
FabricAzureCapacity: The capacity
|
203
|
+
"""
|
204
|
+
from msfabricpysdkcore.fabric_azure_capacity import FabricAzureCapacity
|
205
|
+
|
206
|
+
body = {}
|
207
|
+
if sku and "name" in sku:
|
208
|
+
sku = sku["name"]
|
209
|
+
|
210
|
+
if properties_administration is not None:
|
211
|
+
body["properties"] = {}
|
212
|
+
body["properties"]["administration"] = properties_administration
|
213
|
+
|
214
|
+
if sku is not None:
|
215
|
+
body["sku"] = {"name": sku,
|
216
|
+
"tier": "Fabric"}
|
217
|
+
|
218
|
+
if tags is not None:
|
219
|
+
body["tags"] = tags
|
220
|
+
|
221
|
+
url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Fabric/capacities/{capacity_name}?api-version=2023-11-01"
|
222
|
+
|
223
|
+
response = self.calling_routine(url=url, operation="PATCH", body=body, response_codes=[200, 202],
|
224
|
+
return_format="json", error_message="Failed to update capacity")
|
225
|
+
response["subscription_id"] = subscription_id
|
226
|
+
response["resource_group_name"] = resource_group_name
|
227
|
+
|
228
|
+
return FabricAzureCapacity.from_dict(response, self)
|
@@ -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 = '
|
16
|
+
user_id = '1dc64c6e-7a10-4ea9-8488-85d0739a377d'
|
17
17
|
|
18
18
|
# List workspaces
|
19
|
-
ws = fca.list_workspaces(name="
|
19
|
+
ws = fca.list_workspaces(name="testitems")[0]
|
20
20
|
|
21
|
-
self.assertEqual(ws.name, "
|
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": "
|
75
|
-
label_id = "defa4170-0d19-0005-
|
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
|
-
|
86
|
+
ws_id = "63aa9e13-4912-4abe-9156-8a56e565b7a3"
|
87
87
|
|
88
|
-
data_shares = [d for d in data_shares if d['workspaceId'] ==
|
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'] ==
|
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 = '
|
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': '
|
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': '
|
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 = '
|
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 = '
|
45
|
-
environment_id = '
|
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 = '
|
71
|
-
environment_id = '
|
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.
|
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 = '
|
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
|
-
|
19
|
-
|
18
|
+
fc = self.fc
|
19
|
+
workspace_id = '63aa9e13-4912-4abe-9156-8a56e565b7a3'
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
datetime_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
22
|
+
es_name = "es" + datetime_str
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
eventstream = fc.create_eventstream(workspace_id, display_name=es_name)
|
25
|
+
self.assertEqual(eventstream.display_name, es_name)
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
37
|
+
es2 = fc.update_eventstream(workspace_id, es.id, display_name=f"{es_name}2", return_item=True)
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
44
|
-
|
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 = '
|
18
|
-
item_id =
|
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/
|
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)
|