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.
- msfabricpysdkcore/__init__.py +4 -1
- msfabricpysdkcore/admin_item.py +1 -1
- msfabricpysdkcore/adminapi.py +13 -6
- msfabricpysdkcore/auth.py +31 -11
- msfabricpysdkcore/client.py +24 -10
- msfabricpysdkcore/coreapi.py +37 -19
- msfabricpysdkcore/deployment_pipeline.py +5 -3
- msfabricpysdkcore/fabric_azure_capacity.py +77 -0
- msfabricpysdkcore/fabric_azure_client.py +232 -0
- msfabricpysdkcore/long_running_operation.py +14 -5
- 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/util/__init__.py +3 -0
- msfabricpysdkcore/util/logger.py +32 -0
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/METADATA +80 -3
- msfabricpysdkcore-0.1.3.dist-info/RECORD +57 -0
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/WHEEL +1 -1
- msfabricpysdkcore-0.1.1.dist-info/RECORD +0 -52
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.dist-info}/LICENSE +0 -0
- {msfabricpysdkcore-0.1.1.dist-info → msfabricpysdkcore-0.1.3.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
@@ -2,6 +2,7 @@ import requests
|
|
2
2
|
import json
|
3
3
|
import os
|
4
4
|
from time import sleep
|
5
|
+
from warnings import warn
|
5
6
|
|
6
7
|
from msfabricpysdkcore.client import FabricClient
|
7
8
|
|
@@ -10,12 +11,14 @@ class FabricClientAdmin(FabricClient):
|
|
10
11
|
|
11
12
|
def __init__(self, tenant_id = None, client_id = None, client_secret = None) -> None:
|
12
13
|
"""Initialize FabricClientAdmin object"""
|
13
|
-
super().__init__(
|
14
|
+
super().__init__(scope="https://api.fabric.microsoft.com/.default",
|
15
|
+
tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
|
16
|
+
|
14
17
|
|
15
18
|
def long_running_operation(self, response_headers):
|
16
19
|
"""Check the status of a long running operation"""
|
17
20
|
from msfabricpysdkcore.coreapi import FabricClientCore
|
18
|
-
fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret
|
21
|
+
fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret)
|
19
22
|
|
20
23
|
return fc.long_running_operation(response_headers)
|
21
24
|
|
@@ -169,7 +172,7 @@ class FabricClientAdmin(FabricClient):
|
|
169
172
|
|
170
173
|
if workspace_objects:
|
171
174
|
from msfabricpysdkcore import FabricClientCore
|
172
|
-
fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret
|
175
|
+
fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret)
|
173
176
|
workspaces = [fc.get_workspace_by_id(workspace["id"]) for workspace in workspaces]
|
174
177
|
|
175
178
|
return workspaces
|
@@ -298,9 +301,13 @@ class FabricClientAdmin(FabricClient):
|
|
298
301
|
return_format="json")
|
299
302
|
|
300
303
|
if return_item == "Default":
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
+
warn(
|
305
|
+
message="Updating a domain currently will make invoke an additional API call to get the domain "
|
306
|
+
"object. This default behaviour will change in newer versions of the SDK. To keep this "
|
307
|
+
"behaviour, set return_item=True in the function call.",
|
308
|
+
category=FutureWarning,
|
309
|
+
stacklevel=2
|
310
|
+
)
|
304
311
|
if return_item:
|
305
312
|
return self.get_domain_by_id(domain_id)
|
306
313
|
return response_json
|
msfabricpysdkcore/auth.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
from warnings import warn
|
2
|
+
|
1
3
|
import requests
|
2
4
|
from abc import abstractmethod
|
3
5
|
from azure.identity import AzureCliCredential
|
6
|
+
from msfabricpysdkcore.util import logger
|
7
|
+
import logging
|
4
8
|
try:
|
5
9
|
from notebookutils import mssparkutils
|
6
10
|
except ImportError:
|
@@ -8,6 +12,13 @@ except ImportError:
|
|
8
12
|
class FabricAuth():
|
9
13
|
"""FabricAuth class to interact with Entra ID"""
|
10
14
|
|
15
|
+
_logger: logging.Logger
|
16
|
+
|
17
|
+
def __init__(self, scope):
|
18
|
+
"""Initialize FabricAuth object"""
|
19
|
+
self._logger = logger.getChild(__name__)
|
20
|
+
self.scope = scope
|
21
|
+
|
11
22
|
@abstractmethod
|
12
23
|
def get_token(self):
|
13
24
|
"""Get token from Azure AD"""
|
@@ -26,28 +37,33 @@ class FabricAuth():
|
|
26
37
|
class FabricAuthClient(FabricAuth):
|
27
38
|
"""FabricAuthClient class to interact with Entra ID"""
|
28
39
|
|
29
|
-
def __init__(self, silent =
|
30
|
-
|
31
|
-
|
40
|
+
def __init__(self, scope, silent = None):
|
41
|
+
super().__init__(scope)
|
42
|
+
self._logger.info("Using Azure CLI for authentication")
|
32
43
|
self.auth = AzureCliCredential()
|
33
44
|
|
45
|
+
if silent is not None:
|
46
|
+
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
47
|
+
|
34
48
|
def get_token(self):
|
35
49
|
"""Get token from Azure AD"""
|
36
|
-
token = self.auth.get_token(
|
50
|
+
token = self.auth.get_token(self.scope)
|
37
51
|
return token.token
|
38
52
|
|
39
53
|
class FabricServicePrincipal(FabricAuth):
|
40
54
|
"""FabricServicePrincipal class to interact with Entra ID"""
|
41
55
|
|
42
|
-
def __init__(self, tenant_id, client_id, client_secret, silent =
|
43
|
-
|
44
|
-
|
56
|
+
def __init__(self, tenant_id, client_id, client_secret, scope, silent = None):
|
57
|
+
super().__init__(scope)
|
58
|
+
|
59
|
+
self._logger.info("Using Service Principal for authentication")
|
45
60
|
|
46
61
|
self.tenant_id = tenant_id
|
47
62
|
self.client_id = client_id
|
48
63
|
self.client_secret = client_secret
|
49
64
|
|
50
|
-
|
65
|
+
if silent is not None:
|
66
|
+
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
51
67
|
|
52
68
|
|
53
69
|
def get_token(self):
|
@@ -67,10 +83,14 @@ class FabricServicePrincipal(FabricAuth):
|
|
67
83
|
class FabricSparkUtilsAuthentication(FabricAuth):
|
68
84
|
"""FabricSparkUtilsAuthentication class to interact with Entra ID"""
|
69
85
|
|
70
|
-
def __init__(self, silent
|
86
|
+
def __init__(self, scope, silent=None):
|
87
|
+
# super().__init__(scope)
|
88
|
+
|
71
89
|
mssparkutils.credentials.getToken("pbi")
|
72
|
-
|
73
|
-
|
90
|
+
self._logger.info("Using Synapse Spark Utils for authentication")
|
91
|
+
|
92
|
+
if silent is not None:
|
93
|
+
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
74
94
|
|
75
95
|
def get_token(self):
|
76
96
|
"""Get token from Azure AD"""
|
msfabricpysdkcore/client.py
CHANGED
@@ -1,34 +1,48 @@
|
|
1
|
+
import logging
|
1
2
|
from abc import abstractmethod
|
2
3
|
import os
|
4
|
+
from warnings import warn
|
3
5
|
from time import sleep
|
4
6
|
import requests
|
5
7
|
import json
|
6
8
|
|
7
9
|
from msfabricpysdkcore.auth import FabricAuthClient, FabricServicePrincipal, FabricSparkUtilsAuthentication
|
10
|
+
from msfabricpysdkcore.util import logger
|
8
11
|
|
9
12
|
class FabricClient():
|
10
13
|
"""FabricClient class to interact with Fabric API"""
|
11
14
|
|
12
|
-
|
15
|
+
_logger: logging.Logger
|
16
|
+
|
17
|
+
def __init__(self, scope, tenant_id = None, client_id = None, client_secret = None, silent=None) -> None:
|
13
18
|
"""Initialize FabricClient object"""
|
19
|
+
|
20
|
+
self._logger = logger.getChild(__name__)
|
21
|
+
|
14
22
|
self.tenant_id = tenant_id if tenant_id else os.getenv("FABRIC_TENANT_ID")
|
15
23
|
self.client_id = client_id if client_id else os.getenv("FABRIC_CLIENT_ID")
|
16
24
|
self.client_secret = client_secret if client_secret else os.getenv("FABRIC_CLIENT_SECRET")
|
17
|
-
|
18
|
-
self.scope = "https://api.fabric.microsoft.com/.default"
|
25
|
+
self.scope = scope
|
26
|
+
#self.scope = "https://api.fabric.microsoft.com/.default"
|
19
27
|
|
20
28
|
if self.client_id is None or self.client_secret is None or self.tenant_id is None:
|
21
29
|
try:
|
22
|
-
self.auth = FabricSparkUtilsAuthentication(
|
30
|
+
self.auth = FabricSparkUtilsAuthentication(self.scope)
|
23
31
|
except:
|
24
|
-
self.auth = FabricAuthClient(
|
32
|
+
self.auth = FabricAuthClient(self.scope)
|
25
33
|
else:
|
26
|
-
self.auth = FabricServicePrincipal(
|
34
|
+
self.auth = FabricServicePrincipal(scope= self.scope,
|
35
|
+
tenant_id = self.tenant_id,
|
27
36
|
client_id = self.client_id,
|
28
|
-
client_secret = self.client_secret
|
29
|
-
|
30
|
-
|
37
|
+
client_secret = self.client_secret)
|
38
|
+
|
39
|
+
if silent is not None:
|
40
|
+
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
31
41
|
|
42
|
+
|
43
|
+
def get_token(self):
|
44
|
+
"""Get token from Entra"""
|
45
|
+
return self.auth.get_token()
|
32
46
|
|
33
47
|
def calling_routine(self, url, operation, body = None, headers=None, file_path = None, response_codes = [200], error_message = "Error",
|
34
48
|
continue_on_error_code = False, return_format = "value_json", paging = False,
|
@@ -88,7 +102,7 @@ class FabricClient():
|
|
88
102
|
else:
|
89
103
|
raise ValueError("Invalid operation")
|
90
104
|
if response.status_code == 429:
|
91
|
-
|
105
|
+
self._logger.info("Too many requests, waiting 10 seconds")
|
92
106
|
sleep(10)
|
93
107
|
continue
|
94
108
|
elif response.status_code == 202:
|
msfabricpysdkcore/coreapi.py
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
import json
|
2
2
|
from time import sleep
|
3
|
+
from warnings import warn
|
3
4
|
|
4
5
|
from msfabricpysdkcore.client import FabricClient
|
6
|
+
from msfabricpysdkcore.util import logger
|
7
|
+
|
5
8
|
|
6
9
|
class FabricClientCore(FabricClient):
|
7
10
|
"""FabricClientCore class to interact with Fabric Core APIs"""
|
8
11
|
|
9
|
-
def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=
|
12
|
+
def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=None) -> None:
|
10
13
|
"""Initialize FabricClientCore object"""
|
11
|
-
super().__init__(
|
14
|
+
super().__init__(scope="https://api.fabric.microsoft.com/.default",
|
15
|
+
tenant_id=tenant_id,
|
16
|
+
client_id=client_id,
|
17
|
+
client_secret=client_secret)
|
18
|
+
if silent is not None:
|
19
|
+
warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
|
12
20
|
|
13
21
|
def long_running_operation(self, response_headers):
|
14
22
|
"""Check the status of a long running operation"""
|
@@ -107,7 +115,7 @@ class FabricClientCore(FabricClient):
|
|
107
115
|
return DeploymentPipeline.from_dict(result_json, self)
|
108
116
|
|
109
117
|
def get_deployment_pipeline_stages_items(self, pipeline_id, stage_id = None, stage_name = None):
|
110
|
-
|
118
|
+
warn("DEPRECATED: get_deployment_pipeline_stages_items. get_deployment_pipeline_stages_items. Use list_deployment_pipeline_stages_items instead", DeprecationWarning, stacklevel=2)
|
111
119
|
return self.list_deployment_pipeline_stages_items(pipeline_id, stage_id, stage_name)
|
112
120
|
|
113
121
|
def list_deployment_pipeline_stages_items(self, deployment_pipeline_id, stage_id = None, stage_name = None):
|
@@ -136,7 +144,7 @@ class FabricClientCore(FabricClient):
|
|
136
144
|
error_message="Error getting deployment pipeline stage items", return_format="value_json", paging=True)
|
137
145
|
|
138
146
|
return items
|
139
|
-
|
147
|
+
|
140
148
|
def get_deployment_pipeline_stages(self, pipeline_id):
|
141
149
|
"""Get the stages of a deployment pipeline
|
142
150
|
Args:
|
@@ -144,9 +152,9 @@ class FabricClientCore(FabricClient):
|
|
144
152
|
Returns:
|
145
153
|
list: List of DeploymentPipelineStage objects
|
146
154
|
"""
|
147
|
-
|
155
|
+
warn("DEPRECATED: get_deployment_pipeline_stages. Use list_deployment_pipeline_stages instead", DeprecationWarning, stacklevel=2)
|
148
156
|
return self.list_deployment_pipeline_stages(pipeline_id)
|
149
|
-
|
157
|
+
|
150
158
|
def list_deployment_pipeline_stages(self, deployment_pipeline_id):
|
151
159
|
"""Get the stages of a deployment pipeline
|
152
160
|
Args:
|
@@ -525,7 +533,7 @@ class FabricClientCore(FabricClient):
|
|
525
533
|
|
526
534
|
|
527
535
|
if item_dict is None or "no_operation_result" in item_dict:
|
528
|
-
|
536
|
+
self._logger.debug("Item not returned by API, trying to get it by name")
|
529
537
|
item = None
|
530
538
|
i = 0
|
531
539
|
|
@@ -550,11 +558,11 @@ class FabricClientCore(FabricClient):
|
|
550
558
|
item = self.get_item_by_name(workspace_id, display_name, type)
|
551
559
|
if item is not None:
|
552
560
|
return item
|
553
|
-
|
561
|
+
self._logger.debug("Item not found, waiting 5 seconds")
|
554
562
|
sleep(5)
|
555
563
|
i += 1
|
556
564
|
|
557
|
-
|
565
|
+
self._logger.info("Item not found after 1 minute, returning None")
|
558
566
|
return None
|
559
567
|
|
560
568
|
return self.get_item_specific(workspace_id, item_dict)
|
@@ -706,9 +714,13 @@ class FabricClientCore(FabricClient):
|
|
706
714
|
response_codes=[200, 429], error_message="Error updating item",
|
707
715
|
return_format="json")
|
708
716
|
if return_item == "Default":
|
709
|
-
|
710
|
-
|
711
|
-
|
717
|
+
warn(
|
718
|
+
message="Updating an item currently will make invoke an additional API call to get the item object. "
|
719
|
+
"The default behaviour of returning the item object will change in newer versions of the SDK. "
|
720
|
+
"To keep this behaviour, set return_item=True in the function call.",
|
721
|
+
category=FutureWarning,
|
722
|
+
stacklevel=2
|
723
|
+
)
|
712
724
|
if return_item:
|
713
725
|
return self.get_item_specific(workspace_id, resp_dict)
|
714
726
|
return resp_dict
|
@@ -2010,16 +2022,18 @@ class FabricClientCore(FabricClient):
|
|
2010
2022
|
response = self.calling_routine(url, operation="POST", body=body, response_codes=[202, 429],
|
2011
2023
|
error_message="Error loading table", return_format="response",
|
2012
2024
|
wait_for_completion=False)
|
2013
|
-
|
2025
|
+
|
2014
2026
|
if wait_for_completion:
|
2015
2027
|
success = self.check_if_table_is_created(workspace_id = workspace_id,
|
2016
2028
|
lakehouse_id = lakehouse_id,
|
2017
2029
|
table_name = table_name)
|
2018
|
-
|
2030
|
+
else:
|
2031
|
+
success = None
|
2032
|
+
|
2019
2033
|
if not success:
|
2020
|
-
|
2034
|
+
self._logger.warning("Table not created after 3 minutes")
|
2021
2035
|
else:
|
2022
|
-
|
2036
|
+
self._logger.info("Table created")
|
2023
2037
|
return response.status_code
|
2024
2038
|
|
2025
2039
|
# mlExperiments
|
@@ -2558,9 +2572,13 @@ class FabricClientCore(FabricClient):
|
|
2558
2572
|
error_message="Error updating workspace custom pool", return_format="json")
|
2559
2573
|
|
2560
2574
|
if return_item == "Default":
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2575
|
+
warn(
|
2576
|
+
message="Warning: Updating an item currently will make invoke an additional API call to get the item "
|
2577
|
+
"object. This default behaviour will change in newer versions of the SDK. To keep this "
|
2578
|
+
"behaviour, set return_item=True in the function call.",
|
2579
|
+
category=FutureWarning,
|
2580
|
+
stacklevel=2
|
2581
|
+
)
|
2564
2582
|
if return_item:
|
2565
2583
|
return self.get_workspace_custom_pool(workspace_id, pool_id)
|
2566
2584
|
return response_json
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import json
|
2
|
+
from warnings import warn
|
2
3
|
|
3
4
|
from msfabricpysdkcore.coreapi import FabricClientCore
|
4
5
|
|
@@ -46,7 +47,7 @@ class DeploymentPipeline:
|
|
46
47
|
|
47
48
|
|
48
49
|
def get_stages(self):
|
49
|
-
|
50
|
+
warn("DEPRECATED: Use list_stages() instead", DeprecationWarning, stacklevel=2)
|
50
51
|
return self.list_stages(self)
|
51
52
|
|
52
53
|
def list_stages(self):
|
@@ -54,13 +55,14 @@ class DeploymentPipeline:
|
|
54
55
|
|
55
56
|
|
56
57
|
def get_deployment_pipeline_stages_items(self, stage_id = None, stage_name = None):
|
57
|
-
|
58
|
+
warn("DEPRECATED: get_deployment_pipeline_stages_items. Use list_deployment_pipeline_stages_items() instead", DeprecationWarning, stacklevel=2)
|
58
59
|
return self.list_deployment_pipeline_stages_items(stage_id=stage_id, stage_name=stage_name)
|
59
60
|
|
60
61
|
|
61
62
|
def list_deployment_pipeline_stages_items(self, stage_id = None, stage_name = None):
|
62
63
|
return self.core_client.list_deployment_pipeline_stages_items(deployment_pipeline_id=self.id, stage_id=stage_id, stage_name=stage_name)
|
63
64
|
|
65
|
+
|
64
66
|
class Deployment_Pipeline_Stage():
|
65
67
|
|
66
68
|
"""Class to represent a deployment pipeline stage in Microsoft Fabric"""
|
@@ -120,7 +122,7 @@ class Deployment_Pipeline_Stage():
|
|
120
122
|
return self.__str__()
|
121
123
|
|
122
124
|
def get_items(self):
|
123
|
-
|
125
|
+
warn("DEPRECATED: get_items. Use list_items() instead", DeprecationWarning, stacklevel=2)
|
124
126
|
return self.list_items()
|
125
127
|
|
126
128
|
def list_items(self):
|
@@ -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
|
+
|