|
22 | 22 |
|
23 | 23 | from ... import models as _models
|
24 | 24 | from ..._vendor import _convert_request
|
25 |
| -from ...operations._snapshots_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial |
| 25 | +from ...operations._snapshots_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_restore_files_request_initial, build_update_request_initial |
26 | 26 | T = TypeVar('T')
|
27 | 27 | ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
|
28 | 28 |
|
@@ -589,3 +589,131 @@ def get_long_running_output(pipeline_response):
|
589 | 589 | return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
|
590 | 590 |
|
591 | 591 | begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}'} # type: ignore
|
| 592 | + |
| 593 | + async def _restore_files_initial( |
| 594 | + self, |
| 595 | + resource_group_name: str, |
| 596 | + account_name: str, |
| 597 | + pool_name: str, |
| 598 | + volume_name: str, |
| 599 | + snapshot_name: str, |
| 600 | + body: "_models.SnapshotRestoreFiles", |
| 601 | + **kwargs: Any |
| 602 | + ) -> None: |
| 603 | + cls = kwargs.pop('cls', None) # type: ClsType[None] |
| 604 | + error_map = { |
| 605 | + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError |
| 606 | + } |
| 607 | + error_map.update(kwargs.pop('error_map', {})) |
| 608 | + |
| 609 | + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] |
| 610 | + |
| 611 | + _json = self._serialize.body(body, 'SnapshotRestoreFiles') |
| 612 | + |
| 613 | + request = build_restore_files_request_initial( |
| 614 | + subscription_id=self._config.subscription_id, |
| 615 | + resource_group_name=resource_group_name, |
| 616 | + account_name=account_name, |
| 617 | + pool_name=pool_name, |
| 618 | + volume_name=volume_name, |
| 619 | + snapshot_name=snapshot_name, |
| 620 | + content_type=content_type, |
| 621 | + json=_json, |
| 622 | + template_url=self._restore_files_initial.metadata['url'], |
| 623 | + ) |
| 624 | + request = _convert_request(request) |
| 625 | + request.url = self._client.format_url(request.url) |
| 626 | + |
| 627 | + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) |
| 628 | + response = pipeline_response.http_response |
| 629 | + |
| 630 | + if response.status_code not in [200, 202]: |
| 631 | + map_error(status_code=response.status_code, response=response, error_map=error_map) |
| 632 | + raise HttpResponseError(response=response, error_format=ARMErrorFormat) |
| 633 | + |
| 634 | + if cls: |
| 635 | + return cls(pipeline_response, None, {}) |
| 636 | + |
| 637 | + _restore_files_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}/restoreFiles'} # type: ignore |
| 638 | + |
| 639 | + |
| 640 | + @distributed_trace_async |
| 641 | + async def begin_restore_files( |
| 642 | + self, |
| 643 | + resource_group_name: str, |
| 644 | + account_name: str, |
| 645 | + pool_name: str, |
| 646 | + volume_name: str, |
| 647 | + snapshot_name: str, |
| 648 | + body: "_models.SnapshotRestoreFiles", |
| 649 | + **kwargs: Any |
| 650 | + ) -> AsyncLROPoller[None]: |
| 651 | + """Create a new Snapshot Restore Files request. |
| 652 | +
|
| 653 | + Restore the specified files from the specified snapshot to the active filesystem. |
| 654 | +
|
| 655 | + :param resource_group_name: The name of the resource group. |
| 656 | + :type resource_group_name: str |
| 657 | + :param account_name: The name of the NetApp account. |
| 658 | + :type account_name: str |
| 659 | + :param pool_name: The name of the capacity pool. |
| 660 | + :type pool_name: str |
| 661 | + :param volume_name: The name of the volume. |
| 662 | + :type volume_name: str |
| 663 | + :param snapshot_name: The name of the snapshot. |
| 664 | + :type snapshot_name: str |
| 665 | + :param body: Restore payload supplied in the body of the operation. |
| 666 | + :type body: ~azure.mgmt.netapp.models.SnapshotRestoreFiles |
| 667 | + :keyword callable cls: A custom type or function that will be passed the direct response |
| 668 | + :keyword str continuation_token: A continuation token to restart a poller from a saved state. |
| 669 | + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for |
| 670 | + this operation to not poll, or pass in your own initialized polling object for a personal |
| 671 | + polling strategy. |
| 672 | + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod |
| 673 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 674 | + Retry-After header is present. |
| 675 | + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) |
| 676 | + :rtype: ~azure.core.polling.AsyncLROPoller[None] |
| 677 | + :raises: ~azure.core.exceptions.HttpResponseError |
| 678 | + """ |
| 679 | + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] |
| 680 | + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] |
| 681 | + cls = kwargs.pop('cls', None) # type: ClsType[None] |
| 682 | + lro_delay = kwargs.pop( |
| 683 | + 'polling_interval', |
| 684 | + self._config.polling_interval |
| 685 | + ) |
| 686 | + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] |
| 687 | + if cont_token is None: |
| 688 | + raw_result = await self._restore_files_initial( |
| 689 | + resource_group_name=resource_group_name, |
| 690 | + account_name=account_name, |
| 691 | + pool_name=pool_name, |
| 692 | + volume_name=volume_name, |
| 693 | + snapshot_name=snapshot_name, |
| 694 | + body=body, |
| 695 | + content_type=content_type, |
| 696 | + cls=lambda x,y,z: x, |
| 697 | + **kwargs |
| 698 | + ) |
| 699 | + kwargs.pop('error_map', None) |
| 700 | + |
| 701 | + def get_long_running_output(pipeline_response): |
| 702 | + if cls: |
| 703 | + return cls(pipeline_response, None, {}) |
| 704 | + |
| 705 | + |
| 706 | + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) |
| 707 | + elif polling is False: polling_method = AsyncNoPolling() |
| 708 | + else: polling_method = polling |
| 709 | + if cont_token: |
| 710 | + return AsyncLROPoller.from_continuation_token( |
| 711 | + polling_method=polling_method, |
| 712 | + continuation_token=cont_token, |
| 713 | + client=self._client, |
| 714 | + deserialization_callback=get_long_running_output |
| 715 | + ) |
| 716 | + else: |
| 717 | + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) |
| 718 | + |
| 719 | + begin_restore_files.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}/restoreFiles'} # type: ignore |
0 commit comments