|
60 | 60 | build_resync_replication_request,
|
61 | 61 | build_revert_relocation_request,
|
62 | 62 | build_revert_request,
|
| 63 | + build_split_clone_from_parent_request, |
63 | 64 | build_update_request,
|
64 | 65 | )
|
65 | 66 | from .._configuration import NetAppManagementClientConfiguration
|
@@ -1292,6 +1293,133 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-
|
1292 | 1293 | )
|
1293 | 1294 | return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
|
1294 | 1295 |
|
| 1296 | + async def _split_clone_from_parent_initial( |
| 1297 | + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any |
| 1298 | + ) -> AsyncIterator[bytes]: |
| 1299 | + error_map: MutableMapping = { |
| 1300 | + 401: ClientAuthenticationError, |
| 1301 | + 404: ResourceNotFoundError, |
| 1302 | + 409: ResourceExistsError, |
| 1303 | + 304: ResourceNotModifiedError, |
| 1304 | + } |
| 1305 | + error_map.update(kwargs.pop("error_map", {}) or {}) |
| 1306 | + |
| 1307 | + _headers = kwargs.pop("headers", {}) or {} |
| 1308 | + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) |
| 1309 | + |
| 1310 | + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) |
| 1311 | + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) |
| 1312 | + |
| 1313 | + _request = build_split_clone_from_parent_request( |
| 1314 | + resource_group_name=resource_group_name, |
| 1315 | + account_name=account_name, |
| 1316 | + pool_name=pool_name, |
| 1317 | + volume_name=volume_name, |
| 1318 | + subscription_id=self._config.subscription_id, |
| 1319 | + api_version=api_version, |
| 1320 | + headers=_headers, |
| 1321 | + params=_params, |
| 1322 | + ) |
| 1323 | + _request.url = self._client.format_url(_request.url) |
| 1324 | + |
| 1325 | + _decompress = kwargs.pop("decompress", True) |
| 1326 | + _stream = True |
| 1327 | + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access |
| 1328 | + _request, stream=_stream, **kwargs |
| 1329 | + ) |
| 1330 | + |
| 1331 | + response = pipeline_response.http_response |
| 1332 | + |
| 1333 | + if response.status_code not in [200, 202]: |
| 1334 | + try: |
| 1335 | + await response.read() # Load the body in memory and close the socket |
| 1336 | + except (StreamConsumedError, StreamClosedError): |
| 1337 | + pass |
| 1338 | + map_error(status_code=response.status_code, response=response, error_map=error_map) |
| 1339 | + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) |
| 1340 | + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) |
| 1341 | + |
| 1342 | + response_headers = {} |
| 1343 | + if response.status_code == 202: |
| 1344 | + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) |
| 1345 | + |
| 1346 | + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) |
| 1347 | + |
| 1348 | + if cls: |
| 1349 | + return cls(pipeline_response, deserialized, response_headers) # type: ignore |
| 1350 | + |
| 1351 | + return deserialized # type: ignore |
| 1352 | + |
| 1353 | + @distributed_trace_async |
| 1354 | + async def begin_split_clone_from_parent( |
| 1355 | + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any |
| 1356 | + ) -> AsyncLROPoller[_models.Volume]: |
| 1357 | + """Split clone from parent volume. |
| 1358 | +
|
| 1359 | + Split operation to convert clone volume to an independent volume. |
| 1360 | +
|
| 1361 | + :param resource_group_name: The name of the resource group. The name is case insensitive. |
| 1362 | + Required. |
| 1363 | + :type resource_group_name: str |
| 1364 | + :param account_name: The name of the NetApp account. Required. |
| 1365 | + :type account_name: str |
| 1366 | + :param pool_name: The name of the capacity pool. Required. |
| 1367 | + :type pool_name: str |
| 1368 | + :param volume_name: The name of the volume. Required. |
| 1369 | + :type volume_name: str |
| 1370 | + :return: An instance of AsyncLROPoller that returns either Volume or the result of |
| 1371 | + cls(response) |
| 1372 | + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] |
| 1373 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 1374 | + """ |
| 1375 | + _headers = kwargs.pop("headers", {}) or {} |
| 1376 | + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) |
| 1377 | + |
| 1378 | + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) |
| 1379 | + cls: ClsType[_models.Volume] = kwargs.pop("cls", None) |
| 1380 | + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) |
| 1381 | + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) |
| 1382 | + cont_token: Optional[str] = kwargs.pop("continuation_token", None) |
| 1383 | + if cont_token is None: |
| 1384 | + raw_result = await self._split_clone_from_parent_initial( |
| 1385 | + resource_group_name=resource_group_name, |
| 1386 | + account_name=account_name, |
| 1387 | + pool_name=pool_name, |
| 1388 | + volume_name=volume_name, |
| 1389 | + api_version=api_version, |
| 1390 | + cls=lambda x, y, z: x, |
| 1391 | + headers=_headers, |
| 1392 | + params=_params, |
| 1393 | + **kwargs |
| 1394 | + ) |
| 1395 | + await raw_result.http_response.read() # type: ignore |
| 1396 | + kwargs.pop("error_map", None) |
| 1397 | + |
| 1398 | + def get_long_running_output(pipeline_response): |
| 1399 | + deserialized = self._deserialize("Volume", pipeline_response.http_response) |
| 1400 | + if cls: |
| 1401 | + return cls(pipeline_response, deserialized, {}) # type: ignore |
| 1402 | + return deserialized |
| 1403 | + |
| 1404 | + if polling is True: |
| 1405 | + polling_method: AsyncPollingMethod = cast( |
| 1406 | + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) |
| 1407 | + ) |
| 1408 | + elif polling is False: |
| 1409 | + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) |
| 1410 | + else: |
| 1411 | + polling_method = polling |
| 1412 | + if cont_token: |
| 1413 | + return AsyncLROPoller[_models.Volume].from_continuation_token( |
| 1414 | + polling_method=polling_method, |
| 1415 | + continuation_token=cont_token, |
| 1416 | + client=self._client, |
| 1417 | + deserialization_callback=get_long_running_output, |
| 1418 | + ) |
| 1419 | + return AsyncLROPoller[_models.Volume]( |
| 1420 | + self._client, raw_result, get_long_running_output, polling_method # type: ignore |
| 1421 | + ) |
| 1422 | + |
1295 | 1423 | async def _break_file_locks_initial(
|
1296 | 1424 | self,
|
1297 | 1425 | resource_group_name: str,
|
|
0 commit comments