msfabricpysdkcore 0.0.13__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 (53) hide show
  1. msfabricpysdkcore/__init__.py +2 -1
  2. msfabricpysdkcore/admin_item.py +19 -45
  3. msfabricpysdkcore/admin_workspace.py +13 -60
  4. msfabricpysdkcore/adminapi.py +401 -476
  5. msfabricpysdkcore/auth.py +10 -6
  6. msfabricpysdkcore/client.py +124 -7
  7. msfabricpysdkcore/coreapi.py +2570 -822
  8. msfabricpysdkcore/deployment_pipeline.py +34 -146
  9. msfabricpysdkcore/domain.py +20 -219
  10. msfabricpysdkcore/environment.py +13 -172
  11. msfabricpysdkcore/fabric_azure_capacity.py +77 -0
  12. msfabricpysdkcore/fabric_azure_client.py +228 -0
  13. msfabricpysdkcore/item.py +55 -331
  14. msfabricpysdkcore/job_instance.py +8 -22
  15. msfabricpysdkcore/lakehouse.py +9 -118
  16. msfabricpysdkcore/long_running_operation.py +7 -37
  17. msfabricpysdkcore/onelakeshortcut.py +7 -21
  18. msfabricpysdkcore/otheritems.py +66 -91
  19. msfabricpysdkcore/spark_custom_pool.py +7 -47
  20. msfabricpysdkcore/tests/test_admin_apis.py +9 -10
  21. msfabricpysdkcore/tests/test_datapipelines.py +15 -18
  22. msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
  23. msfabricpysdkcore/tests/test_domains.py +6 -5
  24. msfabricpysdkcore/tests/test_environments.py +54 -5
  25. msfabricpysdkcore/tests/test_evenhouses.py +47 -0
  26. msfabricpysdkcore/tests/test_evenstreams.py +20 -20
  27. msfabricpysdkcore/tests/test_external_data_shares.py +3 -3
  28. msfabricpysdkcore/tests/test_fabric_azure_client.py +78 -0
  29. msfabricpysdkcore/tests/test_git.py +8 -9
  30. msfabricpysdkcore/tests/test_items.py +81 -0
  31. msfabricpysdkcore/tests/test_jobs.py +2 -2
  32. msfabricpysdkcore/tests/test_kql_queryset.py +49 -0
  33. msfabricpysdkcore/tests/test_kqldatabases.py +3 -3
  34. msfabricpysdkcore/tests/test_lakehouse.py +84 -0
  35. msfabricpysdkcore/tests/test_ml_experiments.py +47 -0
  36. msfabricpysdkcore/tests/test_ml_models.py +47 -0
  37. msfabricpysdkcore/tests/test_notebooks.py +57 -0
  38. msfabricpysdkcore/tests/test_one_lake_data_access_security.py +2 -4
  39. msfabricpysdkcore/tests/test_other_items.py +45 -0
  40. msfabricpysdkcore/tests/test_reports.py +52 -0
  41. msfabricpysdkcore/tests/test_semantic_model.py +50 -0
  42. msfabricpysdkcore/tests/test_shortcuts.py +4 -4
  43. msfabricpysdkcore/tests/test_spark.py +9 -9
  44. msfabricpysdkcore/tests/test_sparkjobdefinition.py +2 -2
  45. msfabricpysdkcore/tests/test_warehouses.py +50 -0
  46. msfabricpysdkcore/tests/test_workspaces_capacities.py +16 -13
  47. msfabricpysdkcore/workspace.py +397 -1163
  48. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.2.dist-info}/METADATA +72 -10
  49. msfabricpysdkcore-0.1.2.dist-info/RECORD +55 -0
  50. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.2.dist-info}/WHEEL +1 -1
  51. msfabricpysdkcore-0.0.13.dist-info/RECORD +0 -41
  52. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.2.dist-info}/LICENSE +0 -0
  53. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.2.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,4 @@
1
- import json
2
- import requests
3
- from time import sleep
4
-
5
1
  from msfabricpysdkcore.item import Item
6
- from msfabricpysdkcore.long_running_operation import check_long_running_operation
7
2
 
8
3
  class Environment(Item):
9
4
  """Class to represent a item in Microsoft Fabric"""
@@ -11,48 +6,19 @@ class Environment(Item):
11
6
  def __init__(self, id, display_name, type, workspace_id, auth, properties = None, definition=None, description=""):
12
7
  super().__init__(id, display_name, type, workspace_id, auth, properties, definition, description)
13
8
 
14
- def from_dict(item_dict, auth):
9
+ def from_dict(item_dict, core_client):
15
10
  return Environment(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
16
11
  properties=item_dict.get('properties', None),
17
12
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""),
18
- auth=auth)
13
+ auth=core_client)
19
14
 
20
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/sparkcompute
21
15
  def get_published_settings(self):
22
16
  """Get the published settings of the environment"""
23
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/sparkcompute"
24
-
25
- for _ in range(10):
26
- response = requests.get(url=url, headers=self.auth.get_headers())
27
- if response.status_code == 429:
28
- print("Too many requests, waiting 10 seconds")
29
- sleep(10)
30
- continue
31
- if response.status_code not in (200, 429):
32
- raise Exception(f"Error getting published settings: {response.status_code}, {response.text}")
33
- break
34
-
35
- resp_json = json.loads(response.text)
36
- return resp_json
17
+ return self.core_client.get_published_settings(self.workspace_id, self.id)
37
18
 
38
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/sparkcompute
39
-
40
19
  def get_staging_settings(self):
41
20
  """Get the staging settings of the environment"""
42
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/sparkcompute"
43
-
44
- for _ in range(10):
45
- response = requests.get(url=url, headers=self.auth.get_headers())
46
- if response.status_code == 429:
47
- print("Too many requests, waiting 10 seconds")
48
- sleep(10)
49
- continue
50
- if response.status_code not in (200, 429):
51
- raise Exception(f"Error getting staging settings: {response.status_code}, {response.text}")
52
- break
53
-
54
- resp_json = json.loads(response.text)
55
- return resp_json
21
+ return self.core_client.get_staging_settings(self.workspace_id, self.id)
56
22
 
57
23
 
58
24
  def update_staging_settings(self,
@@ -60,151 +26,26 @@ class Environment(Item):
60
26
  executor_cores = None, executor_memory = None, instance_pool = None,
61
27
  runtime_version = None, spark_properties = None):
62
28
  """Update the staging settings of the environment"""
63
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/sparkcompute"
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
-
83
- for _ in range(10):
84
- response = requests.patch(url=url, headers=self.auth.get_headers(), json=body)
85
- if response.status_code == 429:
86
- print("Too many requests, waiting 10 seconds")
87
- sleep(10)
88
- continue
89
- if response.status_code not in (200, 429):
90
- raise Exception(f"Error updating staging settings: {response.status_code}, {response.text}")
91
- break
92
-
93
- return json.loads(response.text)
94
-
95
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/libraries
29
+ return self.core_client.update_staging_settings(self.workspace_id, self.id, driver_cores, driver_memory,
30
+ dynamic_executor_allocation, executor_cores, executor_memory,
31
+ instance_pool, runtime_version, spark_properties)
96
32
 
97
33
  def get_published_libraries(self):
98
34
  """Get the published libraries of the environment"""
99
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/libraries"
100
-
101
- for _ in range(10):
102
- response = requests.get(url=url, headers=self.auth.get_headers())
103
- if response.status_code == 429:
104
- print("Too many requests, waiting 10 seconds")
105
- sleep(10)
106
- continue
107
- if response.status_code not in (200, 429):
108
- raise Exception(f"Error getting published libraries: {response.status_code}, {response.text}")
109
- break
110
-
111
- resp_json = json.loads(response.text)
112
- return resp_json
35
+ return self.core_client.get_published_libraries(self.workspace_id, self.id)
113
36
 
114
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries
115
-
116
37
  def get_staging_libraries(self):
117
38
  """Get the staging libraries of the environment"""
118
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries"
119
-
120
- for _ in range(10):
121
- response = requests.get(url=url, headers=self.auth.get_headers())
122
- if response.status_code == 429:
123
- print("Too many requests, waiting 10 seconds")
124
- sleep(10)
125
- continue
126
- if response.status_code not in (200, 429):
127
- raise Exception(f"Error getting staging libraries: {response.status_code}, {response.text}")
128
- break
129
-
130
- resp_json = json.loads(response.text)
131
- return resp_json
39
+ return self.core_client.get_staging_libraries(self.workspace_id, self.id)
132
40
 
133
-
134
41
  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
- # with open(file_path, 'rb') as f:
139
- # files = {"upload_file.whl": f}
140
- # for _ in range(10):
141
- # response = requests.post(url=url, files=files, headers=self.auth.get_headers())
142
- # if response.status_code == 429:
143
- # print("Too many requests, waiting 10 seconds")
144
- # sleep(10)
145
- # continue
146
- # if response.status_code not in (200, 429):
147
- # raise Exception(f"Error uploading staging libraries: {response.status_code}, {response.text}")
148
- # break
149
-
150
- # return json.loads(response.text)
42
+ return self.core_client.upload_staging_library(self.workspace_id, self.id, file_path)
151
43
 
152
- # DELETE https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries?libraryToDelete={libraryToDelete}
153
-
154
44
  def delete_staging_library(self, library_to_delete):
155
- """Delete a library from the staging libraries of the environment"""
156
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries?libraryToDelete={library_to_delete}"
157
-
158
- for _ in range(10):
159
- response = requests.delete(url=url, headers=self.auth.get_headers())
160
- if response.status_code == 429:
161
- print("Too many requests, waiting 10 seconds")
162
- sleep(10)
163
- continue
164
- if response.status_code not in (200, 429):
165
- raise Exception(f"Error deleting staging libraries: {response.status_code}, {response.text}")
166
- break
167
-
168
- return response.text
45
+ return self.core_client.delete_staging_library(self.workspace_id, self.id, library_to_delete)
169
46
 
170
- # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/publish
171
-
172
47
  def publish_environment(self):
173
- """Publish the staging settings and libraries of the environment"""
174
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/publish"
175
-
176
- for _ in range(10):
177
- response = requests.post(url=url, headers=self.auth.get_headers())
178
- if response.status_code == 429:
179
- print("Too many requests, waiting 10 seconds")
180
- sleep(10)
181
- continue
182
- if response.status_code == 202:
183
- publish_info = check_long_running_operation(response.headers, self.auth)
184
- return publish_info
185
- if response.status_code not in (200, 429):
186
- raise Exception(f"Error publishing staging: {response.status_code}, {response.text}")
187
- break
188
-
189
- resp_dict = json.loads(response.text)
190
- return resp_dict
191
-
192
-
193
- # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/cancelPublish
48
+ return self.core_client.publish_environment(self.workspace_id, self.id)
194
49
 
195
50
  def cancel_publish(self):
196
- """Cancel the publishing of the staging settings and libraries of the environment"""
197
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/cancelPublish"
198
-
199
- for _ in range(10):
200
- response = requests.post(url=url, headers=self.auth.get_headers())
201
- if response.status_code == 429:
202
- print("Too many requests, waiting 10 seconds")
203
- sleep(10)
204
- continue
205
- if response.status_code not in (200, 429):
206
- raise Exception(f"Error canceling publishing: {response.status_code}, {response.text}")
207
- break
208
-
209
- resp_dict = json.loads(response.text)
210
- return resp_dict
51
+ return self.core_client.cancel_publish(self.workspace_id, self.id)
@@ -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)