diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json b/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json index ec7cc250ecc3..99d78b8ea503 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json +++ b/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@6.1.9", + "@autorest/modelerfour@4.24.3" ], - "commit": "8d0a1bce1741e7b181746bcce6ad25dad31a3b11", + "commit": "0fc6ed4db447e7571208ad90a9f39287c5b992cc", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/dataprotection/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/dataprotection/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.9 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/dataprotection/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/__init__.py index 9dfda54e0346..9ffe357babbb 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/__init__.py @@ -10,10 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['DataProtectionClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["DataProtectionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py index d38b045a587e..aab2a807afea 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py @@ -6,66 +6,64 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class DataProtectionClientConfiguration(Configuration): +class DataProtectionClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataProtectionClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription Id. + :param subscription_id: The subscription Id. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataProtectionClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(DataProtectionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-dataprotection/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-dataprotection/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_client.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_client.py index 85019b92c77f..396ee5728644 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_client.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_client.py @@ -6,37 +6,43 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models +from ._configuration import DataProtectionClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + BackupInstancesExtensionRoutingOperations, + BackupInstancesOperations, + BackupPoliciesOperations, + BackupVaultOperationResultsOperations, + BackupVaultsOperations, + DataProtectionOperations, + DataProtectionOperationsOperations, + DeletedBackupInstancesOperations, + DppResourceGuardProxyOperations, + ExportJobsOperationResultOperations, + ExportJobsOperations, + JobsOperations, + OperationResultOperations, + OperationStatusBackupVaultContextOperations, + OperationStatusOperations, + OperationStatusResourceGroupContextOperations, + RecoveryPointsOperations, + ResourceGuardsOperations, + RestorableTimeRangesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import DataProtectionClientConfiguration -from .operations import BackupVaultsOperations -from .operations import OperationResultOperations -from .operations import OperationStatusOperations -from .operations import BackupVaultOperationResultsOperations -from .operations import DataProtectionOperations -from .operations import DataProtectionOperationsOperations -from .operations import BackupPoliciesOperations -from .operations import BackupInstancesOperations -from .operations import RecoveryPointsOperations -from .operations import JobsOperations -from .operations import RestorableTimeRangesOperations -from .operations import ExportJobsOperations -from .operations import ExportJobsOperationResultOperations -from .operations import ResourceGuardsOperations -from . import models -class DataProtectionClient(object): +class DataProtectionClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Open API 2.0 Specs for Azure Data Protection service. :ivar backup_vaults: BackupVaultsOperations operations @@ -45,100 +51,143 @@ class DataProtectionClient(object): :vartype operation_result: azure.mgmt.dataprotection.operations.OperationResultOperations :ivar operation_status: OperationStatusOperations operations :vartype operation_status: azure.mgmt.dataprotection.operations.OperationStatusOperations + :ivar operation_status_backup_vault_context: OperationStatusBackupVaultContextOperations + operations + :vartype operation_status_backup_vault_context: + azure.mgmt.dataprotection.operations.OperationStatusBackupVaultContextOperations + :ivar operation_status_resource_group_context: OperationStatusResourceGroupContextOperations + operations + :vartype operation_status_resource_group_context: + azure.mgmt.dataprotection.operations.OperationStatusResourceGroupContextOperations :ivar backup_vault_operation_results: BackupVaultOperationResultsOperations operations - :vartype backup_vault_operation_results: azure.mgmt.dataprotection.operations.BackupVaultOperationResultsOperations + :vartype backup_vault_operation_results: + azure.mgmt.dataprotection.operations.BackupVaultOperationResultsOperations :ivar data_protection: DataProtectionOperations operations :vartype data_protection: azure.mgmt.dataprotection.operations.DataProtectionOperations :ivar data_protection_operations: DataProtectionOperationsOperations operations - :vartype data_protection_operations: azure.mgmt.dataprotection.operations.DataProtectionOperationsOperations + :vartype data_protection_operations: + azure.mgmt.dataprotection.operations.DataProtectionOperationsOperations :ivar backup_policies: BackupPoliciesOperations operations :vartype backup_policies: azure.mgmt.dataprotection.operations.BackupPoliciesOperations :ivar backup_instances: BackupInstancesOperations operations :vartype backup_instances: azure.mgmt.dataprotection.operations.BackupInstancesOperations + :ivar backup_instances_extension_routing: BackupInstancesExtensionRoutingOperations operations + :vartype backup_instances_extension_routing: + azure.mgmt.dataprotection.operations.BackupInstancesExtensionRoutingOperations :ivar recovery_points: RecoveryPointsOperations operations :vartype recovery_points: azure.mgmt.dataprotection.operations.RecoveryPointsOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.dataprotection.operations.JobsOperations :ivar restorable_time_ranges: RestorableTimeRangesOperations operations - :vartype restorable_time_ranges: azure.mgmt.dataprotection.operations.RestorableTimeRangesOperations + :vartype restorable_time_ranges: + azure.mgmt.dataprotection.operations.RestorableTimeRangesOperations :ivar export_jobs: ExportJobsOperations operations :vartype export_jobs: azure.mgmt.dataprotection.operations.ExportJobsOperations :ivar export_jobs_operation_result: ExportJobsOperationResultOperations operations - :vartype export_jobs_operation_result: azure.mgmt.dataprotection.operations.ExportJobsOperationResultOperations + :vartype export_jobs_operation_result: + azure.mgmt.dataprotection.operations.ExportJobsOperationResultOperations + :ivar deleted_backup_instances: DeletedBackupInstancesOperations operations + :vartype deleted_backup_instances: + azure.mgmt.dataprotection.operations.DeletedBackupInstancesOperations :ivar resource_guards: ResourceGuardsOperations operations :vartype resource_guards: azure.mgmt.dataprotection.operations.ResourceGuardsOperations - :param credential: Credential needed for the client to connect to Azure. + :ivar dpp_resource_guard_proxy: DppResourceGuardProxyOperations operations + :vartype dpp_resource_guard_proxy: + azure.mgmt.dataprotection.operations.DppResourceGuardProxyOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription Id. + :param subscription_id: The subscription Id. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataProtectionClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataProtectionClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.backup_vaults = BackupVaultsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.backup_vaults = BackupVaultsOperations(self._client, self._config, self._serialize, self._deserialize) self.operation_result = OperationResultOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operation_status = OperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_status_backup_vault_context = OperationStatusBackupVaultContextOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_status_resource_group_context = OperationStatusResourceGroupContextOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.backup_vault_operation_results = BackupVaultOperationResultsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_protection = DataProtectionOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.data_protection = DataProtectionOperations(self._client, self._config, self._serialize, self._deserialize) self.data_protection_operations = DataProtectionOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.backup_policies = BackupPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.backup_policies = BackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.backup_instances = BackupInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.recovery_points = RecoveryPointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.backup_instances_extension_routing = BackupInstancesExtensionRoutingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.recovery_points = RecoveryPointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.restorable_time_ranges = RestorableTimeRangesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.export_jobs = ExportJobsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.export_jobs = ExportJobsOperations(self._client, self._config, self._serialize, self._deserialize) self.export_jobs_operation_result = ExportJobsOperationResultOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_guards = ResourceGuardsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_backup_instances = DeletedBackupInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_guards = ResourceGuardsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dpp_resource_guard_proxy = DppResourceGuardProxyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_metadata.json b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_metadata.json deleted file mode 100644 index 8360a7bf7cd9..000000000000 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_metadata.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "chosen_version": "2021-07-01", - "total_api_version_list": ["2021-07-01"], - "client": { - "name": "DataProtectionClient", - "filename": "_data_protection_client", - "description": "Open API 2.0 Specs for Azure Data Protection service.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataProtectionClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataProtectionClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription Id.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription Id.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "backup_vaults": "BackupVaultsOperations", - "operation_result": "OperationResultOperations", - "operation_status": "OperationStatusOperations", - "backup_vault_operation_results": "BackupVaultOperationResultsOperations", - "data_protection": "DataProtectionOperations", - "data_protection_operations": "DataProtectionOperationsOperations", - "backup_policies": "BackupPoliciesOperations", - "backup_instances": "BackupInstancesOperations", - "recovery_points": "RecoveryPointsOperations", - "jobs": "JobsOperations", - "restorable_time_ranges": "RestorableTimeRangesOperations", - "export_jobs": "ExportJobsOperations", - "export_jobs_operation_result": "ExportJobsOperationResultOperations", - "resource_guards": "ResourceGuardsOperations" - } -} \ No newline at end of file diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_patch.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_serialization.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_vendor.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/__init__.py index d1235b93a84d..169eab7dbe21 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/__init__.py @@ -7,4 +7,15 @@ # -------------------------------------------------------------------------- from ._data_protection_client import DataProtectionClient -__all__ = ['DataProtectionClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["DataProtectionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py index 9fcfed8d9fab..d04a341320d8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,49 +19,48 @@ from azure.core.credentials_async import AsyncTokenCredential -class DataProtectionClientConfiguration(Configuration): +class DataProtectionClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataProtectionClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription Id. + :param subscription_id: The subscription Id. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataProtectionClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(DataProtectionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-dataprotection/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-dataprotection/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_client.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_client.py index f4ae7f1b520c..4ea500245666 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_client.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_client.py @@ -6,35 +6,43 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models +from .._serialization import Deserializer, Serializer +from ._configuration import DataProtectionClientConfiguration +from .operations import ( + BackupInstancesExtensionRoutingOperations, + BackupInstancesOperations, + BackupPoliciesOperations, + BackupVaultOperationResultsOperations, + BackupVaultsOperations, + DataProtectionOperations, + DataProtectionOperationsOperations, + DeletedBackupInstancesOperations, + DppResourceGuardProxyOperations, + ExportJobsOperationResultOperations, + ExportJobsOperations, + JobsOperations, + OperationResultOperations, + OperationStatusBackupVaultContextOperations, + OperationStatusOperations, + OperationStatusResourceGroupContextOperations, + RecoveryPointsOperations, + ResourceGuardsOperations, + RestorableTimeRangesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataProtectionClientConfiguration -from .operations import BackupVaultsOperations -from .operations import OperationResultOperations -from .operations import OperationStatusOperations -from .operations import BackupVaultOperationResultsOperations -from .operations import DataProtectionOperations -from .operations import DataProtectionOperationsOperations -from .operations import BackupPoliciesOperations -from .operations import BackupInstancesOperations -from .operations import RecoveryPointsOperations -from .operations import JobsOperations -from .operations import RestorableTimeRangesOperations -from .operations import ExportJobsOperations -from .operations import ExportJobsOperationResultOperations -from .operations import ResourceGuardsOperations -from .. import models - -class DataProtectionClient(object): +class DataProtectionClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Open API 2.0 Specs for Azure Data Protection service. :ivar backup_vaults: BackupVaultsOperations operations @@ -43,98 +51,143 @@ class DataProtectionClient(object): :vartype operation_result: azure.mgmt.dataprotection.aio.operations.OperationResultOperations :ivar operation_status: OperationStatusOperations operations :vartype operation_status: azure.mgmt.dataprotection.aio.operations.OperationStatusOperations + :ivar operation_status_backup_vault_context: OperationStatusBackupVaultContextOperations + operations + :vartype operation_status_backup_vault_context: + azure.mgmt.dataprotection.aio.operations.OperationStatusBackupVaultContextOperations + :ivar operation_status_resource_group_context: OperationStatusResourceGroupContextOperations + operations + :vartype operation_status_resource_group_context: + azure.mgmt.dataprotection.aio.operations.OperationStatusResourceGroupContextOperations :ivar backup_vault_operation_results: BackupVaultOperationResultsOperations operations - :vartype backup_vault_operation_results: azure.mgmt.dataprotection.aio.operations.BackupVaultOperationResultsOperations + :vartype backup_vault_operation_results: + azure.mgmt.dataprotection.aio.operations.BackupVaultOperationResultsOperations :ivar data_protection: DataProtectionOperations operations :vartype data_protection: azure.mgmt.dataprotection.aio.operations.DataProtectionOperations :ivar data_protection_operations: DataProtectionOperationsOperations operations - :vartype data_protection_operations: azure.mgmt.dataprotection.aio.operations.DataProtectionOperationsOperations + :vartype data_protection_operations: + azure.mgmt.dataprotection.aio.operations.DataProtectionOperationsOperations :ivar backup_policies: BackupPoliciesOperations operations :vartype backup_policies: azure.mgmt.dataprotection.aio.operations.BackupPoliciesOperations :ivar backup_instances: BackupInstancesOperations operations :vartype backup_instances: azure.mgmt.dataprotection.aio.operations.BackupInstancesOperations + :ivar backup_instances_extension_routing: BackupInstancesExtensionRoutingOperations operations + :vartype backup_instances_extension_routing: + azure.mgmt.dataprotection.aio.operations.BackupInstancesExtensionRoutingOperations :ivar recovery_points: RecoveryPointsOperations operations :vartype recovery_points: azure.mgmt.dataprotection.aio.operations.RecoveryPointsOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.dataprotection.aio.operations.JobsOperations :ivar restorable_time_ranges: RestorableTimeRangesOperations operations - :vartype restorable_time_ranges: azure.mgmt.dataprotection.aio.operations.RestorableTimeRangesOperations + :vartype restorable_time_ranges: + azure.mgmt.dataprotection.aio.operations.RestorableTimeRangesOperations :ivar export_jobs: ExportJobsOperations operations :vartype export_jobs: azure.mgmt.dataprotection.aio.operations.ExportJobsOperations :ivar export_jobs_operation_result: ExportJobsOperationResultOperations operations - :vartype export_jobs_operation_result: azure.mgmt.dataprotection.aio.operations.ExportJobsOperationResultOperations + :vartype export_jobs_operation_result: + azure.mgmt.dataprotection.aio.operations.ExportJobsOperationResultOperations + :ivar deleted_backup_instances: DeletedBackupInstancesOperations operations + :vartype deleted_backup_instances: + azure.mgmt.dataprotection.aio.operations.DeletedBackupInstancesOperations :ivar resource_guards: ResourceGuardsOperations operations :vartype resource_guards: azure.mgmt.dataprotection.aio.operations.ResourceGuardsOperations - :param credential: Credential needed for the client to connect to Azure. + :ivar dpp_resource_guard_proxy: DppResourceGuardProxyOperations operations + :vartype dpp_resource_guard_proxy: + azure.mgmt.dataprotection.aio.operations.DppResourceGuardProxyOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription Id. + :param subscription_id: The subscription Id. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataProtectionClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataProtectionClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.backup_vaults = BackupVaultsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.backup_vaults = BackupVaultsOperations(self._client, self._config, self._serialize, self._deserialize) self.operation_result = OperationResultOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operation_status = OperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_status_backup_vault_context = OperationStatusBackupVaultContextOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_status_resource_group_context = OperationStatusResourceGroupContextOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.backup_vault_operation_results = BackupVaultOperationResultsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_protection = DataProtectionOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.data_protection = DataProtectionOperations(self._client, self._config, self._serialize, self._deserialize) self.data_protection_operations = DataProtectionOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.backup_policies = BackupPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.backup_policies = BackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.backup_instances = BackupInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.recovery_points = RecoveryPointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.backup_instances_extension_routing = BackupInstancesExtensionRoutingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.recovery_points = RecoveryPointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.restorable_time_ranges = RestorableTimeRangesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.export_jobs = ExportJobsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.export_jobs = ExportJobsOperations(self._client, self._config, self._serialize, self._deserialize) self.export_jobs_operation_result = ExportJobsOperationResultOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_guards = ResourceGuardsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_backup_instances = DeletedBackupInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_guards = ResourceGuardsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dpp_resource_guard_proxy = DppResourceGuardProxyOperations( + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_patch.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py index f9c765bb82a0..0685deeec279 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py @@ -9,31 +9,47 @@ from ._backup_vaults_operations import BackupVaultsOperations from ._operation_result_operations import OperationResultOperations from ._operation_status_operations import OperationStatusOperations +from ._operation_status_backup_vault_context_operations import OperationStatusBackupVaultContextOperations +from ._operation_status_resource_group_context_operations import OperationStatusResourceGroupContextOperations from ._backup_vault_operation_results_operations import BackupVaultOperationResultsOperations from ._data_protection_operations import DataProtectionOperations from ._data_protection_operations_operations import DataProtectionOperationsOperations from ._backup_policies_operations import BackupPoliciesOperations from ._backup_instances_operations import BackupInstancesOperations +from ._backup_instances_extension_routing_operations import BackupInstancesExtensionRoutingOperations from ._recovery_points_operations import RecoveryPointsOperations from ._jobs_operations import JobsOperations from ._restorable_time_ranges_operations import RestorableTimeRangesOperations from ._export_jobs_operations import ExportJobsOperations from ._export_jobs_operation_result_operations import ExportJobsOperationResultOperations +from ._deleted_backup_instances_operations import DeletedBackupInstancesOperations from ._resource_guards_operations import ResourceGuardsOperations +from ._dpp_resource_guard_proxy_operations import DppResourceGuardProxyOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'BackupVaultsOperations', - 'OperationResultOperations', - 'OperationStatusOperations', - 'BackupVaultOperationResultsOperations', - 'DataProtectionOperations', - 'DataProtectionOperationsOperations', - 'BackupPoliciesOperations', - 'BackupInstancesOperations', - 'RecoveryPointsOperations', - 'JobsOperations', - 'RestorableTimeRangesOperations', - 'ExportJobsOperations', - 'ExportJobsOperationResultOperations', - 'ResourceGuardsOperations', + "BackupVaultsOperations", + "OperationResultOperations", + "OperationStatusOperations", + "OperationStatusBackupVaultContextOperations", + "OperationStatusResourceGroupContextOperations", + "BackupVaultOperationResultsOperations", + "DataProtectionOperations", + "DataProtectionOperationsOperations", + "BackupPoliciesOperations", + "BackupInstancesOperations", + "BackupInstancesExtensionRoutingOperations", + "RecoveryPointsOperations", + "JobsOperations", + "RestorableTimeRangesOperations", + "ExportJobsOperations", + "ExportJobsOperationResultOperations", + "DeletedBackupInstancesOperations", + "ResourceGuardsOperations", + "DppResourceGuardProxyOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_extension_routing_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_extension_routing_operations.py new file mode 100644 index 000000000000..55e89e6c0543 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_extension_routing_operations.py @@ -0,0 +1,130 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._backup_instances_extension_routing_operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BackupInstancesExtensionRoutingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`backup_instances_extension_routing` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_id: str, **kwargs: Any) -> AsyncIterable["_models.BackupInstanceResource"]: + """Gets a list backup instances associated with a tracked resource. + + :param resource_id: ARM path of the resource to be protected using Microsoft.DataProtection. + Required. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BackupInstanceResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResourceList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceId}/providers/Microsoft.DataProtection/backupInstances"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py index ff56d2bc2e8d..17d4fb3cf7c4 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._backup_instances_operations import ( + build_adhoc_backup_request, + build_create_or_update_request, + build_delete_request, + build_get_backup_instance_operation_result_request, + build_get_request, + build_list_request, + build_resume_backups_request, + build_resume_protection_request, + build_stop_protection_request, + build_suspend_backups_request, + build_sync_backup_instance_request, + build_trigger_rehydrate_request, + build_trigger_restore_request, + build_validate_for_backup_request, + build_validate_for_restore_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BackupInstancesOperations: - """BackupInstancesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackupInstancesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`backup_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( - self, - vault_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BackupInstanceResourceList"]: + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BackupInstanceResource"]: """Gets a backup instances belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupInstanceResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupInstanceResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BackupInstanceResourceList', pipeline_response) + deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,7 +139,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,243 +150,350 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances"} # type: ignore + + @distributed_trace_async async def get( - self, - vault_name: str, - resource_group_name: str, - backup_instance_name: str, - **kwargs: Any - ) -> "_models.BackupInstanceResource": + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> _models.BackupInstanceResource: """Gets a backup instance with name in a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupInstanceResource, or the result of cls(response) + :return: BackupInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore async def _create_or_update_initial( self, - vault_name: str, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.BackupInstanceResource", + parameters: Union[_models.BackupInstanceResource, IO], **kwargs: Any - ) -> "_models.BackupInstanceResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResource"] + ) -> Optional[_models.BackupInstanceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupInstanceResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInstanceResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackupInstanceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + + @overload async def begin_create_or_update( self, + resource_group_name: str, vault_name: str, + backup_instance_name: str, + parameters: _models.BackupInstanceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInstanceResource]: + """Create or update a backup instance in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.BackupInstanceResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BackupInstanceResource"]: + ) -> AsyncLROPoller[_models.BackupInstanceResource]: """Create or update a backup instance in a backup vault. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.BackupInstanceResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInstanceResource]: + """Create or update a backup instance in a backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( - vault_name=vault_name, + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) - + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - vault_name: str, - resource_group_name: str, - backup_instance_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -357,527 +502,1619 @@ async def _delete_initial( response_headers = {} if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, None, response_headers) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - vault_name: str, - resource_group_name: str, - backup_instance_name: str, - **kwargs: Any + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a backup instance in a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( - vault_name=vault_name, + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore async def _adhoc_backup_initial( self, - vault_name: str, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.TriggerBackupRequest", + parameters: Union[_models.TriggerBackupRequest, IO], **kwargs: Any - ) -> Optional["_models.OperationJobExtendedInfo"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + ) -> Optional[_models.OperationJobExtendedInfo]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._adhoc_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TriggerBackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TriggerBackupRequest") + + request = build_adhoc_backup_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._adhoc_backup_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _adhoc_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup'} # type: ignore + _adhoc_backup_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup"} # type: ignore + + @overload async def begin_adhoc_backup( self, + resource_group_name: str, vault_name: str, + backup_instance_name: str, + parameters: _models.TriggerBackupRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Trigger adhoc backup. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_adhoc_backup( + self, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.TriggerBackupRequest", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.OperationJobExtendedInfo"]: + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Trigger adhoc backup. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_adhoc_backup( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.TriggerBackupRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Trigger adhoc backup. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._adhoc_backup_initial( - vault_name=vault_name, + raw_result = await self._adhoc_backup_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_adhoc_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_adhoc_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup"} # type: ignore async def _validate_for_backup_initial( self, - vault_name: str, resource_group_name: str, - parameters: "_models.ValidateForBackupRequest", + vault_name: str, + parameters: Union[_models.ValidateForBackupRequest, IO], **kwargs: Any - ) -> Optional["_models.OperationJobExtendedInfo"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + ) -> Optional[_models.OperationJobExtendedInfo]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_for_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ValidateForBackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ValidateForBackupRequest") + + request = build_validate_for_backup_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_for_backup_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _validate_for_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup'} # type: ignore + _validate_for_backup_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup"} # type: ignore + + @overload async def begin_validate_for_backup( self, + resource_group_name: str, vault_name: str, + parameters: _models.ValidateForBackupRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Validate whether adhoc backup will be successful or not. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_for_backup( + self, resource_group_name: str, - parameters: "_models.ValidateForBackupRequest", + vault_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.OperationJobExtendedInfo"]: + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Validate whether adhoc backup will be successful or not. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_for_backup( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.ValidateForBackupRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Validate whether adhoc backup will be successful or not. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_for_backup_initial( - vault_name=vault_name, + raw_result = await self._validate_for_backup_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_for_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _trigger_rehydrate_initial( - self, - resource_group_name: str, - vault_name: str, - backup_instance_name: str, - parameters: "_models.AzureBackupRehydrationRequest", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_rehydrate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureBackupRehydrationRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + begin_validate_for_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup"} # type: ignore - if response.status_code not in [202, 204]: + @distributed_trace_async + async def get_backup_instance_operation_result( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.BackupInstanceResource]: + """Get result of backup instance creation operation. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param operation_id: Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BackupInstanceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInstanceResource]] + + request = build_get_backup_instance_operation_result_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_backup_instance_operation_result.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_backup_instance_operation_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/operationResults/{operationId}"} # type: ignore + + async def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRehydrationRequest, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureBackupRehydrationRequest") + + request = build_trigger_rehydrate_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._trigger_rehydrate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _trigger_rehydrate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate"} # type: ignore + + @overload + async def begin_trigger_rehydrate( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.AzureBackupRehydrationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """rehydrate recovery point for restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_trigger_rehydrate( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """rehydrate recovery point for restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_trigger_rehydrate( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRehydrationRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """rehydrate recovery point for restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._trigger_rehydrate_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_trigger_rehydrate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate"} # type: ignore + + async def _trigger_restore_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRestoreRequest, IO], + **kwargs: Any + ) -> Optional[_models.OperationJobExtendedInfo]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureBackupRestoreRequest") + + request = build_trigger_restore_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._trigger_restore_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _trigger_restore_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore"} # type: ignore + + @overload + async def begin_trigger_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.AzureBackupRestoreRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Triggers restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_trigger_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Triggers restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_trigger_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRestoreRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Triggers restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._trigger_restore_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_trigger_restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore"} # type: ignore + + async def _resume_backups_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resume_backups_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._resume_backups_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _resume_backups_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups"} # type: ignore + + @distributed_trace_async + async def begin_resume_backups( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will resume backups for backup instance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._resume_backups_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_resume_backups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups"} # type: ignore + + async def _resume_protection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resume_protection_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._resume_protection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _resume_protection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection"} # type: ignore + + @distributed_trace_async + async def begin_resume_protection( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will resume protection for a stopped backup instance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._resume_protection_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_resume_protection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection"} # type: ignore + + async def _stop_protection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_protection_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_protection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, None, response_headers) - _trigger_rehydrate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate'} # type: ignore + _stop_protection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection"} # type: ignore - async def begin_trigger_rehydrate( - self, - resource_group_name: str, - vault_name: str, - backup_instance_name: str, - parameters: "_models.AzureBackupRehydrationRequest", - **kwargs: Any + @distributed_trace_async + async def begin_stop_protection( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """rehydrate recovery point for restore for a BackupInstance. + """This operation will stop protection of a backup instance and data will be held forever. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str - :param backup_instance_name: + :param backup_instance_name: Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._trigger_rehydrate_initial( + raw_result = await self._stop_protection_initial( # type: ignore resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, - parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop_protection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection"} # type: ignore + + async def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_suspend_backups_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._suspend_backups_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _suspend_backups_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups"} # type: ignore + + @distributed_trace_async + async def begin_suspend_backups( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will stop backup for a backup instance and retains the backup data as per the + policy (except latest Recovery point, which will be retained forever). + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._suspend_backups_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_trigger_rehydrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _trigger_restore_initial( + begin_suspend_backups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups"} # type: ignore + + async def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statements self, - vault_name: str, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.AzureBackupRestoreRequest", + parameters: Union[_models.SyncBackupInstanceRequest, IO], **kwargs: Any - ) -> Optional["_models.OperationJobExtendedInfo"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureBackupRestoreRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncBackupInstanceRequest") + + request = build_sync_backup_instance_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._sync_backup_instance_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -885,232 +2122,413 @@ async def _trigger_restore_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, None, response_headers) - return deserialized - _trigger_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore'} # type: ignore + _sync_backup_instance_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync"} # type: ignore - async def begin_trigger_restore( + @overload + async def begin_sync_backup_instance( self, + resource_group_name: str, vault_name: str, + backup_instance_name: str, + parameters: _models.SyncBackupInstanceRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Sync backup instance again in case of failure + This action will retry last failed operation and will bring backup instance to valid state. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_sync_backup_instance( + self, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.AzureBackupRestoreRequest", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.OperationJobExtendedInfo"]: - """Triggers restore for a BackupInstance. + ) -> AsyncLROPoller[None]: + """Sync backup instance again in case of failure + This action will retry last failed operation and will bring backup instance to valid state. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_sync_backup_instance( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.SyncBackupInstanceRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Sync backup instance again in case of failure + This action will retry last failed operation and will bring backup instance to valid state. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._trigger_restore_initial( - vault_name=vault_name, + raw_result = await self._sync_backup_instance_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } + return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_trigger_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_sync_backup_instance.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync"} # type: ignore async def _validate_for_restore_initial( self, - vault_name: str, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.ValidateRestoreRequestObject", + parameters: Union[_models.ValidateRestoreRequestObject, IO], **kwargs: Any - ) -> Optional["_models.OperationJobExtendedInfo"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + ) -> Optional[_models.OperationJobExtendedInfo]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_for_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ValidateRestoreRequestObject') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ValidateRestoreRequestObject") + + request = build_validate_for_restore_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_for_restore_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _validate_for_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore'} # type: ignore + _validate_for_restore_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore"} # type: ignore + + @overload async def begin_validate_for_restore( self, + resource_group_name: str, vault_name: str, + backup_instance_name: str, + parameters: _models.ValidateRestoreRequestObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Validates if Restore can be triggered for a DataSource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_for_restore( + self, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.ValidateRestoreRequestObject", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.OperationJobExtendedInfo"]: + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Validates if Restore can be triggered for a DataSource. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_for_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.ValidateRestoreRequestObject, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: + """Validates if Restore can be triggered for a DataSource. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_for_restore_initial( - vault_name=vault_name, + raw_result = await self._validate_for_restore_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_for_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_validate_for_restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py index 3b220c4d6253..04ce481b481a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._backup_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BackupPoliciesOperations: - """BackupPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackupPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`backup_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( - self, - vault_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BaseBackupPolicyResourceList"]: + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BaseBackupPolicyResource"]: """Returns list of backup policies belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BaseBackupPolicyResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BaseBackupPolicyResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BaseBackupPolicyResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BaseBackupPolicyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaseBackupPolicyResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BaseBackupPolicyResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BaseBackupPolicyResourceList', pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +126,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,197 +137,281 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies"} # type: ignore + + @distributed_trace_async async def get( - self, - vault_name: str, - resource_group_name: str, - backup_policy_name: str, - **kwargs: Any - ) -> "_models.BaseBackupPolicyResource": + self, resource_group_name: str, vault_name: str, backup_policy_name: str, **kwargs: Any + ) -> _models.BaseBackupPolicyResource: """Gets a backup policy belonging to a backup vault. Gets a backup policy belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_policy_name: + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Required. :type backup_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaseBackupPolicyResource, or the result of cls(response) + :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaseBackupPolicyResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupPolicyName': self._serialize.url("backup_policy_name", backup_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BaseBackupPolicyResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_policy_name=backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BaseBackupPolicyResource', pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}"} # type: ignore + + @overload async def create_or_update( self, + resource_group_name: str, vault_name: str, + backup_policy_name: str, + parameters: _models.BaseBackupPolicyResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BaseBackupPolicyResource: + """Creates or Updates a backup policy belonging to a backup vault. + + Creates or Updates a backup policy belonging to a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Name of the policy. Required. + :type backup_policy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BaseBackupPolicyResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, + vault_name: str, backup_policy_name: str, - parameters: "_models.BaseBackupPolicyResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.BaseBackupPolicyResource": + ) -> _models.BaseBackupPolicyResource: """Creates or Updates a backup policy belonging to a backup vault. Creates or Updates a backup policy belonging to a backup vault. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_policy_name: Name of the policy. Required. + :type backup_policy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BaseBackupPolicyResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_policy_name: str, + parameters: Union[_models.BaseBackupPolicyResource, IO], + **kwargs: Any + ) -> _models.BaseBackupPolicyResource: + """Creates or Updates a backup policy belonging to a backup vault. + + Creates or Updates a backup policy belonging to a backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_policy_name: Name of the policy. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Name of the policy. Required. :type backup_policy_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaseBackupPolicyResource, or the result of cls(response) + :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaseBackupPolicyResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupPolicyName': self._serialize.url("backup_policy_name", backup_policy_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BaseBackupPolicyResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BaseBackupPolicyResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BaseBackupPolicyResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_policy_name=backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BaseBackupPolicyResource', pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}'} # type: ignore - async def delete( - self, - vault_name: str, - resource_group_name: str, - backup_policy_name: str, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_policy_name: str, **kwargs: Any ) -> None: """Deletes a backup policy belonging to a backup vault. Deletes a backup policy belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_policy_name: + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Required. :type backup_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupPolicyName': self._serialize.url("backup_policy_name", backup_policy_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_policy_name=backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -310,4 +421,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py index 22c61b0cc12b..ab042b8a4e43 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,120 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._backup_vault_operation_results_operations import build_get_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BackupVaultOperationResultsOperations: - """BackupVaultOperationResultsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackupVaultOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`backup_vault_operation_results` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - vault_name: str, - resource_group_name: str, - operation_id: str, - **kwargs: Any - ) -> Optional["_models.BackupVaultResource"]: + self, resource_group_name: str, vault_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.BackupVaultResource]: """get. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param operation_id: + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param operation_id: Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupVaultResource, or the result of cls(response) + :return: BackupVaultResource or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupVaultResource"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupVaultResource]] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py index d0bc61275c7b..05c2c6c3b702 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._backup_vaults_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_in_resource_group_request, + build_get_in_subscription_request, + build_get_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BackupVaultsOperations: - """BackupVaultsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackupVaultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`backup_vaults` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get_in_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.BackupVaultResourceList"]: + @distributed_trace + def get_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupVaultResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupVaultResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_in_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BackupVaultResourceList', pipeline_response) + deserialized = self._deserialize("BackupVaultResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,7 +121,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,59 +132,66 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults"} # type: ignore + + @distributed_trace def get_in_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BackupVaultResourceList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupVaultResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupVaultResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_in_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_in_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BackupVaultResourceList', pipeline_response) + deserialized = self._deserialize("BackupVaultResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -165,7 +200,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,108 +211,118 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_in_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - vault_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.BackupVaultResource": + get_in_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.BackupVaultResource: """Returns a resource belonging to a resource group. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupVaultResource, or the result of cls(response) + :return: BackupVaultResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore async def _create_or_update_initial( self, - vault_name: str, resource_group_name: str, - parameters: "_models.BackupVaultResource", + vault_name: str, + parameters: Union[_models.BackupVaultResource, IO], **kwargs: Any - ) -> "_models.BackupVaultResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] + ) -> _models.BackupVaultResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupVaultResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackupVaultResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -283,132 +330,218 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @overload async def begin_create_or_update( self, + resource_group_name: str, vault_name: str, + parameters: _models.BackupVaultResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVaultResource]: + """Creates or updates a BackupVault resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, resource_group_name: str, - parameters: "_models.BackupVaultResource", + vault_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BackupVaultResource"]: + ) -> AsyncLROPoller[_models.BackupVaultResource]: """Creates or updates a BackupVault resource belonging to a resource group. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.BackupVaultResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVaultResource]: + """Creates or updates a BackupVault resource belonging to a resource group. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( - vault_name=vault_name, + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupVaultResource', pipeline_response) - + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def delete( - self, - vault_name: str, - resource_group_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, **kwargs: Any ) -> None: """Deletes a BackupVault resource from the resource group. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -418,47 +551,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore async def _update_initial( self, - vault_name: str, resource_group_name: str, - parameters: "_models.PatchResourceRequestInput", + vault_name: str, + parameters: Union[_models.PatchResourceRequestInput, IO], **kwargs: Any - ) -> Optional["_models.BackupVaultResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupVaultResource"]] + ) -> Optional[_models.BackupVaultResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PatchResourceRequestInput') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupVaultResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PatchResourceRequestInput") + + request = build_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -467,150 +610,313 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @overload async def begin_update( self, + resource_group_name: str, vault_name: str, + parameters: _models.PatchResourceRequestInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVaultResource]: + """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a + resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, resource_group_name: str, - parameters: "_models.PatchResourceRequestInput", + vault_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.BackupVaultResource"]: + ) -> AsyncLROPoller[_models.BackupVaultResource]: """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a resource. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.PatchResourceRequestInput, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVaultResource]: + """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a + resource. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( - vault_name=vault_name, + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupVaultResource', pipeline_response) - + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + @overload async def check_name_availability( self, resource_group_name: str, location: str, - parameters: "_models.CheckNameAvailabilityRequest", + parameters: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """API to check for resource name availability. API to check for resource name availability. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param location: The location in which uniqueness will be verified. + :param location: The location in which uniqueness will be verified. Required. :type location: str - :param parameters: Check name availability request. + :param parameters: Check name availability request. Required. :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + location: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """API to check for resource name availability. + + API to check for resource name availability. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param parameters: Check name availability request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + location: str, + parameters: Union[_models.CheckNameAvailabilityRequest, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """API to check for resource name availability. + + API to check for resource name availability. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param parameters: Check name availability request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailabilityRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability'} # type: ignore + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py index 4f4c02a41fbf..38bde5b9ee5f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._data_protection_operations import build_check_feature_support_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataProtectionOperations: - """DataProtectionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataProtectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`data_protection` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload async def check_feature_support( self, location: str, - parameters: "_models.FeatureValidationRequestBase", + parameters: _models.FeatureValidationRequestBase, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.FeatureValidationResponseBase": + ) -> _models.FeatureValidationResponseBase: """Validates if a feature is supported. Validates if a feature is supported. - :param location: + :param location: Required. :type location: str - :param parameters: Feature support request object. + :param parameters: Feature support request object. Required. :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureValidationResponseBase or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_feature_support( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FeatureValidationResponseBase: + """Validates if a feature is supported. + + Validates if a feature is supported. + + :param location: Required. + :type location: str + :param parameters: Feature support request object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureValidationResponseBase, or the result of cls(response) + :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_feature_support( + self, location: str, parameters: Union[_models.FeatureValidationRequestBase, IO], **kwargs: Any + ) -> _models.FeatureValidationResponseBase: + """Validates if a feature is supported. + + Validates if a feature is supported. + + :param location: Required. + :type location: str + :param parameters: Feature support request object. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureValidationResponseBase or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureValidationResponseBase"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_feature_support.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FeatureValidationRequestBase') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureValidationResponseBase] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FeatureValidationRequestBase") + + request = build_check_feature_support_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_feature_support.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureValidationResponseBase', pipeline_response) + deserialized = self._deserialize("FeatureValidationResponseBase", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_feature_support.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport'} # type: ignore + + check_feature_support.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py index c214a878307e..5588ce577985 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,102 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._data_protection_operations_operations import build_list_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataProtectionOperationsOperations: - """DataProtectionOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataProtectionOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`data_protection_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ClientDiscoveryResponse"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ClientDiscoveryValueForSingleApi"]: """Returns the list of available operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClientDiscoveryResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ClientDiscoveryResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClientDiscoveryValueForSingleApi or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ClientDiscoveryValueForSingleApi] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientDiscoveryResponse"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientDiscoveryResponse] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClientDiscoveryResponse', pipeline_response) + deserialized = self._deserialize("ClientDiscoveryResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,7 +110,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +121,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataProtection/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataProtection/operations"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_operations.py new file mode 100644 index 000000000000..8da09e291363 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_operations.py @@ -0,0 +1,319 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deleted_backup_instances_operations import ( + build_get_request, + build_list_request, + build_undelete_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeletedBackupInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`deleted_backup_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DeletedBackupInstanceResource"]: + """Gets deleted backup instances belonging to a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedBackupInstanceResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedBackupInstanceResourceList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedBackupInstanceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> _models.DeletedBackupInstanceResource: + """Gets a deleted backup instance with name in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the deleted backup instance. Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedBackupInstanceResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedBackupInstanceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedBackupInstanceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}"} # type: ignore + + async def _undelete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_undelete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._undelete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _undelete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete"} # type: ignore + + @distributed_trace_async + async def begin_undelete( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """undelete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the deleted backup instance. Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._undelete_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_undelete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py new file mode 100644 index 000000000000..b000cbbc4ca5 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py @@ -0,0 +1,563 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dpp_resource_guard_proxy_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, + build_unlock_delete_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DppResourceGuardProxyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`dpp_resource_guard_proxy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGuardProxyBaseResource"]: + """list. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceGuardProxyBaseResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardProxyBaseResourceList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceGuardProxyBaseResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """get. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardProxyBaseResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"} # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.ResourceGuardProxyBaseResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """put. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """put. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.ResourceGuardProxyBaseResource, IO], + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """put. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardProxyBaseResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGuardProxyBaseResource") + + request = build_put_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> None: + """delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"} # type: ignore + + @overload + async def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.UnlockDeleteRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """unlock_delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """unlock_delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.UnlockDeleteRequest, IO], + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """unlock_delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UnlockDeleteResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UnlockDeleteRequest") + + request = build_unlock_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.unlock_delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + unlock_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py index 5229fa069641..f3a308739818 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._export_jobs_operation_result_operations import build_get_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportJobsOperationResultOperations: - """ExportJobsOperationResultOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportJobsOperationResultOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`export_jobs_operation_result` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - resource_group_name: str, - vault_name: str, - operation_id: str, - **kwargs: Any - ) -> Optional["_models.ExportJobsResult"]: + self, resource_group_name: str, vault_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.ExportJobsResult]: """Gets the operation result of operation triggered by Export Jobs API. If the operation is successful, then it also contains URL of a Blob and a SAS key to access the same. The blob contains exported jobs in JSON serialized format. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str - :param operation_id: OperationID which represents the export job. + :param operation_id: OperationID which represents the export job. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportJobsResult, or the result of cls(response) + :return: ExportJobsResult or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ExportJobsResult or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExportJobsResult"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExportJobsResult]] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -98,10 +109,11 @@ async def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ExportJobsResult', pipeline_response) + deserialized = self._deserialize("ExportJobsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py index 9e54054ad0ea..db6efb04f85b 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,76 +6,85 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request +from ...operations._export_jobs_operations import build_trigger_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportJobsOperations: - """ExportJobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportJobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`export_jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def _trigger_initial( - self, - resource_group_name: str, - vault_name: str, - **kwargs: Any + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _trigger_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._trigger_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_trigger_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._trigger_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -83,74 +93,74 @@ async def _trigger_initial( response_headers = {} if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, None, response_headers) - _trigger_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs'} # type: ignore + _trigger_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs"} # type: ignore - async def begin_trigger( - self, - resource_group_name: str, - vault_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Triggers export of jobs and returns an OperationID to track. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._trigger_initial( + raw_result = await self._trigger_initial( # type: ignore resource_group_name=resource_group_name, vault_name=vault_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_trigger.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py index 8cce9e55bcfc..d2e8949cd392 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request, build_list_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( - self, - resource_group_name: str, - vault_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AzureBackupJobResourceList"]: + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureBackupJobResource"]: """Returns list of jobs belonging to a backup vault. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBackupJobResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureBackupJobResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupJobResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupJobResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBackupJobResourceList', pipeline_response) + deserialized = self._deserialize("AzureBackupJobResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +121,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,70 +132,71 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - vault_name: str, - job_id: str, - **kwargs: Any - ) -> "_models.AzureBackupJobResource": + self, resource_group_name: str, vault_name: str, job_id: str, **kwargs: Any + ) -> _models.AzureBackupJobResource: """Gets a job with id in a backup vault. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str :param job_id: The Job ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureBackupJobResource, or the result of cls(response) + :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupJobResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupJobResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureBackupJobResource', pipeline_response) + deserialized = self._deserialize("AzureBackupJobResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py index 4793f47b4c57..7c6b68873ae1 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operation_result_operations import build_get_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationResultOperations: - """OperationResultOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationResultOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`operation_result` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - operation_id: str, - location: str, - **kwargs: Any - ) -> Optional["_models.OperationJobExtendedInfo"]: + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional[_models.OperationJobExtendedInfo]: """Gets the operation status for a resource. Gets the operation result for a resource. - :param operation_id: + :param operation_id: Required. :type operation_id: str - :param location: + :param location: Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationJobExtendedInfo, or the result of cls(response) + :return: OperationJobExtendedInfo or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationJobExtendedInfo or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + request = build_get_request( + operation_id=operation_id, + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_operations.py new file mode 100644 index 000000000000..b52b3bc25940 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_operations.py @@ -0,0 +1,117 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operation_status_backup_vault_context_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OperationStatusBackupVaultContextOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`operation_status_backup_vault_context` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, operation_id: str, **kwargs: Any + ) -> _models.OperationResource: + """Gets the operation status for an operation over a BackupVault's context. + + Gets the operation status for an operation over a BackupVault's context. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param operation_id: Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.OperationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationStatus/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py index cd20c682149d..02f56b65bd62 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operation_status_operations import build_get_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationStatusOperations: - """OperationStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - location: str, - operation_id: str, - **kwargs: Any - ) -> "_models.OperationResource": + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationResource: """Gets the operation status for a resource. Gets the operation status for a resource. - :param location: + :param location: Required. :type location: str - :param operation_id: + :param operation_id: Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResource, or the result of cls(response) + :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResource] + + request = build_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationResource', pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_operations.py new file mode 100644 index 000000000000..ee81a9579659 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_operations.py @@ -0,0 +1,112 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operation_status_resource_group_context_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OperationStatusResourceGroupContextOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`operation_status_resource_group_context` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _models.OperationResource: + """Gets the operation status for an operation over a ResourceGroup's context. + + Gets the operation status for an operation over a ResourceGroup's context. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param operation_id: Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.OperationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResource] + + request = build_get_request( + resource_group_name=resource_group_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/operationStatus/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_patch.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py index efb6fbeb9455..f629ed0b5771 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._recovery_points_operations import build_get_request, build_list_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RecoveryPointsOperations: - """RecoveryPointsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RecoveryPointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`recovery_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, - vault_name: str, resource_group_name: str, + vault_name: str, backup_instance_name: str, filter: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AzureBackupRecoveryPointResourceList"]: + ) -> AsyncIterable["_models.AzureBackupRecoveryPointResource"]: """Returns a list of Recovery Points for a DataSource in a vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param filter: OData filter options. + :param filter: OData filter options. Default value is None. :type filter: str - :param skip_token: skipToken Filter. + :param skip_token: skipToken Filter. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBackupRecoveryPointResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupRecoveryPointResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupRecoveryPointResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + skip_token=skip_token, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBackupRecoveryPointResourceList', pipeline_response) + deserialized = self._deserialize("AzureBackupRecoveryPointResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,7 +136,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -124,73 +147,78 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints"} # type: ignore + @distributed_trace_async async def get( self, - vault_name: str, resource_group_name: str, + vault_name: str, backup_instance_name: str, recovery_point_id: str, **kwargs: Any - ) -> "_models.AzureBackupRecoveryPointResource": + ) -> _models.AzureBackupRecoveryPointResource: """Gets a Recovery Point using recoveryPointId for a Datasource. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param recovery_point_id: + :param recovery_point_id: Required. :type recovery_point_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureBackupRecoveryPointResource, or the result of cls(response) + :return: AzureBackupRecoveryPointResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupRecoveryPointResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - 'recoveryPointId': self._serialize.url("recovery_point_id", recovery_point_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupRecoveryPointResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + recovery_point_id=recovery_point_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureBackupRecoveryPointResource', pipeline_response) + deserialized = self._deserialize("AzureBackupRecoveryPointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py index 0f9b1f08b6b6..bf0aa57dab1e 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,125 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._resource_guards_operations import ( + build_delete_request, + build_get_backup_security_pin_requests_objects_request, + build_get_default_backup_security_pin_requests_object_request, + build_get_default_delete_protected_item_requests_object_request, + build_get_default_delete_resource_guard_proxy_requests_object_request, + build_get_default_disable_soft_delete_requests_object_request, + build_get_default_update_protected_item_requests_object_request, + build_get_default_update_protection_policy_requests_object_request, + build_get_delete_protected_item_requests_objects_request, + build_get_delete_resource_guard_proxy_requests_objects_request, + build_get_disable_soft_delete_requests_objects_request, + build_get_request, + build_get_resources_in_resource_group_request, + build_get_resources_in_subscription_request, + build_get_update_protected_item_requests_objects_request, + build_get_update_protection_policy_requests_objects_request, + build_patch_request, + build_put_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceGuardsOperations: - """ResourceGuardsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGuardsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`resource_guards` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get_resources_in_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGuardResourceList"]: + @distributed_trace + def get_resources_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ResourceGuardResource"]: """Returns ResourceGuards collection belonging to a subscription. Returns ResourceGuards collection belonging to a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGuardResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceGuardResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_resources_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_resources_in_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resources_in_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceGuardResourceList', pipeline_response) + deserialized = self._deserialize("ResourceGuardResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,7 +133,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,61 +144,69 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_resources_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_resources_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards"} # type: ignore + + @distributed_trace def get_resources_in_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGuardResourceList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGuardResource"]: """Returns ResourceGuards collection belonging to a ResourceGroup. Returns ResourceGuards collection belonging to a ResourceGroup. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGuardResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceGuardResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_resources_in_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_resources_in_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resources_in_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceGuardResourceList', pipeline_response) + deserialized = self._deserialize("ResourceGuardResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -167,7 +215,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,185 +226,265 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_resources_in_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_resources_in_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards"} # type: ignore + + @overload async def put( self, resource_group_name: str, resource_guards_name: str, - parameters: "_models.ResourceGuardResource", + parameters: _models.ResourceGuardResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGuardResource": + ) -> _models.ResourceGuardResource: """Creates or updates a ResourceGuard resource belonging to a resource group. Creates or updates a ResourceGuard resource belonging to a resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGuardResource, or the result of cls(response) + :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Creates or updates a ResourceGuard resource belonging to a resource group. + + Creates or updates a ResourceGuard resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: Union[_models.ResourceGuardResource, IO], + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Creates or updates a ResourceGuard resource belonging to a resource group. + + Creates or updates a ResourceGuard resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGuardResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGuardResource") + + request = build_put_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGuardResource', pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> "_models.ResourceGuardResource": + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> _models.ResourceGuardResource: """Returns a ResourceGuard belonging to a resource group. Returns a ResourceGuard belonging to a resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGuardResource, or the result of cls(response) + :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResource] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGuardResource', pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> None: """Deletes a ResourceGuard resource from the resource group. Deletes a ResourceGuard resource from the resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -364,132 +494,221 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + @overload async def patch( self, resource_group_name: str, resource_guards_name: str, - parameters: "_models.PatchResourceRequestInput", + parameters: _models.PatchResourceRequestInput, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGuardResource": - """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for a resource. + ) -> _models.ResourceGuardResource: + """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for a resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGuardResource, or the result of cls(response) + :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: Union[_models.PatchResourceRequestInput, IO], + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PatchResourceRequestInput') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PatchResourceRequestInput") + + request = build_patch_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGuardResource', pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + + @distributed_trace def get_disable_soft_delete_requests_objects( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DppBaseResourceList"]: - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_disable_soft_delete_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_disable_soft_delete_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_disable_soft_delete_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -498,7 +717,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -507,66 +728,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_disable_soft_delete_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_disable_soft_delete_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests"} # type: ignore + + @distributed_trace def get_delete_resource_guard_proxy_requests_objects( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DppBaseResourceList"]: - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_delete_resource_guard_proxy_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_delete_resource_guard_proxy_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_delete_resource_guard_proxy_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -575,7 +803,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -584,66 +814,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_delete_resource_guard_proxy_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_delete_resource_guard_proxy_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests"} # type: ignore + + @distributed_trace def get_backup_security_pin_requests_objects( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DppBaseResourceList"]: - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_backup_security_pin_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_backup_security_pin_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_backup_security_pin_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -652,7 +889,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -661,66 +900,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_backup_security_pin_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_backup_security_pin_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests"} # type: ignore + + @distributed_trace def get_delete_protected_item_requests_objects( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DppBaseResourceList"]: - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_delete_protected_item_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_delete_protected_item_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_delete_protected_item_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,7 +975,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,66 +986,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_delete_protected_item_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_delete_protected_item_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests"} # type: ignore + + @distributed_trace def get_update_protection_policy_requests_objects( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DppBaseResourceList"]: - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_update_protection_policy_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_update_protection_policy_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_protection_policy_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -806,7 +1061,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -815,66 +1072,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_update_protection_policy_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + get_update_protection_policy_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests"} # type: ignore + + @distributed_trace def get_update_protected_item_requests_objects( - self, - resource_group_name: str, - resource_guards_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DppBaseResourceList"]: - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_update_protected_item_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_update_protected_item_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_protected_item_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -883,7 +1147,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -892,397 +1158,414 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - get_update_protected_item_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + get_update_protected_item_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests"} # type: ignore + @distributed_trace_async async def get_default_disable_soft_delete_requests_object( - self, - resource_group_name: str, - resource_guards_name: str, - request_name: str, - **kwargs: Any - ) -> "_models.DppBaseResource": - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_disable_soft_delete_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_disable_soft_delete_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_disable_soft_delete_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_disable_soft_delete_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}'} # type: ignore + get_default_disable_soft_delete_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}"} # type: ignore + + @distributed_trace_async async def get_default_delete_resource_guard_proxy_requests_object( - self, - resource_group_name: str, - resource_guards_name: str, - request_name: str, - **kwargs: Any - ) -> "_models.DppBaseResource": - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_delete_resource_guard_proxy_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_delete_resource_guard_proxy_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_delete_resource_guard_proxy_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_delete_resource_guard_proxy_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}'} # type: ignore + get_default_delete_resource_guard_proxy_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}"} # type: ignore + + @distributed_trace_async async def get_default_backup_security_pin_requests_object( - self, - resource_group_name: str, - resource_guards_name: str, - request_name: str, - **kwargs: Any - ) -> "_models.DppBaseResource": - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_backup_security_pin_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_backup_security_pin_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_backup_security_pin_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_backup_security_pin_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}'} # type: ignore + get_default_backup_security_pin_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}"} # type: ignore + + @distributed_trace_async async def get_default_delete_protected_item_requests_object( - self, - resource_group_name: str, - resource_guards_name: str, - request_name: str, - **kwargs: Any - ) -> "_models.DppBaseResource": - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_delete_protected_item_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_delete_protected_item_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_delete_protected_item_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_delete_protected_item_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}'} # type: ignore + get_default_delete_protected_item_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}"} # type: ignore + + @distributed_trace_async async def get_default_update_protection_policy_requests_object( - self, - resource_group_name: str, - resource_guards_name: str, - request_name: str, - **kwargs: Any - ) -> "_models.DppBaseResource": - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_update_protection_policy_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_update_protection_policy_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_update_protection_policy_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_update_protection_policy_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}'} # type: ignore + get_default_update_protection_policy_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}"} # type: ignore + + @distributed_trace_async async def get_default_update_protected_item_requests_object( - self, - resource_group_name: str, - resource_guards_name: str, - request_name: str, - **kwargs: Any - ) -> "_models.DppBaseResource": - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_update_protected_item_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_update_protected_item_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_update_protected_item_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_update_protected_item_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}'} # type: ignore + + get_default_update_protected_item_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py index 73ec6d0bed24..83724b98ace5 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,195 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._vendor import _convert_request +from ...operations._restorable_time_ranges_operations import build_find_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RestorableTimeRangesOperations: - """RestorableTimeRangesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorableTimeRangesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionClient`'s + :attr:`restorable_time_ranges` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload async def find( self, + resource_group_name: str, vault_name: str, + backup_instance_name: str, + parameters: _models.AzureBackupFindRestorableTimeRangesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: + """find. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def find( + self, resource_group_name: str, + vault_name: str, backup_instance_name: str, - parameters: "_models.AzureBackupFindRestorableTimeRangesRequest", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.AzureBackupFindRestorableTimeRangesResponseResource": + ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: """find. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def find( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupFindRestorableTimeRangesRequest, IO], + **kwargs: Any + ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: + """find. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureBackupFindRestorableTimeRangesResponseResource, or the result of cls(response) + :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupFindRestorableTimeRangesResponseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.find.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureBackupFindRestorableTimeRangesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupFindRestorableTimeRangesResponseResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureBackupFindRestorableTimeRangesRequest") + + request = build_find_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.find.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureBackupFindRestorableTimeRangesResponseResource', pipeline_response) + deserialized = self._deserialize("AzureBackupFindRestorableTimeRangesResponseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - find.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges'} # type: ignore + + find.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py index 1d823e9b0535..5b69d18ca804 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py @@ -6,398 +6,336 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AbsoluteDeleteOption - from ._models_py3 import AdHocBackupRuleOptions - from ._models_py3 import AdhocBackupTriggerOption - from ._models_py3 import AdhocBasedTaggingCriteria - from ._models_py3 import AdhocBasedTriggerContext - from ._models_py3 import AuthCredentials - from ._models_py3 import AzureBackupDiscreteRecoveryPoint - from ._models_py3 import AzureBackupFindRestorableTimeRangesRequest - from ._models_py3 import AzureBackupFindRestorableTimeRangesRequestResource - from ._models_py3 import AzureBackupFindRestorableTimeRangesResponse - from ._models_py3 import AzureBackupFindRestorableTimeRangesResponseResource - from ._models_py3 import AzureBackupJob - from ._models_py3 import AzureBackupJobResource - from ._models_py3 import AzureBackupJobResourceList - from ._models_py3 import AzureBackupParams - from ._models_py3 import AzureBackupRecoveryPoint - from ._models_py3 import AzureBackupRecoveryPointBasedRestoreRequest - from ._models_py3 import AzureBackupRecoveryPointResource - from ._models_py3 import AzureBackupRecoveryPointResourceList - from ._models_py3 import AzureBackupRecoveryTimeBasedRestoreRequest - from ._models_py3 import AzureBackupRehydrationRequest - from ._models_py3 import AzureBackupRestoreRequest - from ._models_py3 import AzureBackupRestoreWithRehydrationRequest - from ._models_py3 import AzureBackupRule - from ._models_py3 import AzureOperationalStoreParameters - from ._models_py3 import AzureRetentionRule - from ._models_py3 import BackupCriteria - from ._models_py3 import BackupInstance - from ._models_py3 import BackupInstanceResource - from ._models_py3 import BackupInstanceResourceList - from ._models_py3 import BackupParameters - from ._models_py3 import BackupPolicy - from ._models_py3 import BackupSchedule - from ._models_py3 import BackupVault - from ._models_py3 import BackupVaultResource - from ._models_py3 import BackupVaultResourceList - from ._models_py3 import BaseBackupPolicy - from ._models_py3 import BaseBackupPolicyResource - from ._models_py3 import BaseBackupPolicyResourceList - from ._models_py3 import BasePolicyRule - from ._models_py3 import CheckNameAvailabilityRequest - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import ClientDiscoveryDisplay - from ._models_py3 import ClientDiscoveryForLogSpecification - from ._models_py3 import ClientDiscoveryForProperties - from ._models_py3 import ClientDiscoveryForServiceSpecification - from ._models_py3 import ClientDiscoveryResponse - from ._models_py3 import ClientDiscoveryValueForSingleApi - from ._models_py3 import CopyOnExpiryOption - from ._models_py3 import CopyOption - from ._models_py3 import CustomCopyOption - from ._models_py3 import DataStoreInfoBase - from ._models_py3 import DataStoreParameters - from ._models_py3 import Datasource - from ._models_py3 import DatasourceSet - from ._models_py3 import Day - from ._models_py3 import DeleteOption - from ._models_py3 import DppBaseResource - from ._models_py3 import DppBaseResourceList - from ._models_py3 import DppIdentityDetails - from ._models_py3 import DppResource - from ._models_py3 import DppResourceList - from ._models_py3 import DppTrackedResource - from ._models_py3 import DppTrackedResourceList - from ._models_py3 import DppWorkerRequest - from ._models_py3 import Error - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ExportJobsResult - from ._models_py3 import FeatureValidationRequest - from ._models_py3 import FeatureValidationRequestBase - from ._models_py3 import FeatureValidationResponse - from ._models_py3 import FeatureValidationResponseBase - from ._models_py3 import ImmediateCopyOption - from ._models_py3 import InnerError - from ._models_py3 import ItemLevelRestoreCriteria - from ._models_py3 import ItemLevelRestoreTargetInfo - from ._models_py3 import JobExtendedInfo - from ._models_py3 import JobSubTask - from ._models_py3 import OperationExtendedInfo - from ._models_py3 import OperationJobExtendedInfo - from ._models_py3 import OperationResource - from ._models_py3 import PatchResourceRequestInput - from ._models_py3 import PolicyInfo - from ._models_py3 import PolicyParameters - from ._models_py3 import ProtectionStatusDetails - from ._models_py3 import RangeBasedItemLevelRestoreCriteria - from ._models_py3 import RecoveryPointDataStoreDetails - from ._models_py3 import RecoveryPointsFilters - from ._models_py3 import ResourceGuard - from ._models_py3 import ResourceGuardOperation - from ._models_py3 import ResourceGuardResource - from ._models_py3 import ResourceGuardResourceList - from ._models_py3 import ResourceMoveDetails - from ._models_py3 import RestorableTimeRange - from ._models_py3 import RestoreFilesTargetInfo - from ._models_py3 import RestoreJobRecoveryPointDetails - from ._models_py3 import RestoreTargetInfo - from ._models_py3 import RestoreTargetInfoBase - from ._models_py3 import RetentionTag - from ._models_py3 import ScheduleBasedBackupCriteria - from ._models_py3 import ScheduleBasedTriggerContext - from ._models_py3 import SecretStoreBasedAuthCredentials - from ._models_py3 import SecretStoreResource - from ._models_py3 import SourceLifeCycle - from ._models_py3 import StorageSetting - from ._models_py3 import SupportedFeature - from ._models_py3 import SystemData - from ._models_py3 import TaggingCriteria - from ._models_py3 import TargetCopySetting - from ._models_py3 import TargetDetails - from ._models_py3 import TriggerBackupRequest - from ._models_py3 import TriggerContext - from ._models_py3 import UserFacingError - from ._models_py3 import ValidateForBackupRequest - from ._models_py3 import ValidateRestoreRequestObject -except (SyntaxError, ImportError): - from ._models import AbsoluteDeleteOption # type: ignore - from ._models import AdHocBackupRuleOptions # type: ignore - from ._models import AdhocBackupTriggerOption # type: ignore - from ._models import AdhocBasedTaggingCriteria # type: ignore - from ._models import AdhocBasedTriggerContext # type: ignore - from ._models import AuthCredentials # type: ignore - from ._models import AzureBackupDiscreteRecoveryPoint # type: ignore - from ._models import AzureBackupFindRestorableTimeRangesRequest # type: ignore - from ._models import AzureBackupFindRestorableTimeRangesRequestResource # type: ignore - from ._models import AzureBackupFindRestorableTimeRangesResponse # type: ignore - from ._models import AzureBackupFindRestorableTimeRangesResponseResource # type: ignore - from ._models import AzureBackupJob # type: ignore - from ._models import AzureBackupJobResource # type: ignore - from ._models import AzureBackupJobResourceList # type: ignore - from ._models import AzureBackupParams # type: ignore - from ._models import AzureBackupRecoveryPoint # type: ignore - from ._models import AzureBackupRecoveryPointBasedRestoreRequest # type: ignore - from ._models import AzureBackupRecoveryPointResource # type: ignore - from ._models import AzureBackupRecoveryPointResourceList # type: ignore - from ._models import AzureBackupRecoveryTimeBasedRestoreRequest # type: ignore - from ._models import AzureBackupRehydrationRequest # type: ignore - from ._models import AzureBackupRestoreRequest # type: ignore - from ._models import AzureBackupRestoreWithRehydrationRequest # type: ignore - from ._models import AzureBackupRule # type: ignore - from ._models import AzureOperationalStoreParameters # type: ignore - from ._models import AzureRetentionRule # type: ignore - from ._models import BackupCriteria # type: ignore - from ._models import BackupInstance # type: ignore - from ._models import BackupInstanceResource # type: ignore - from ._models import BackupInstanceResourceList # type: ignore - from ._models import BackupParameters # type: ignore - from ._models import BackupPolicy # type: ignore - from ._models import BackupSchedule # type: ignore - from ._models import BackupVault # type: ignore - from ._models import BackupVaultResource # type: ignore - from ._models import BackupVaultResourceList # type: ignore - from ._models import BaseBackupPolicy # type: ignore - from ._models import BaseBackupPolicyResource # type: ignore - from ._models import BaseBackupPolicyResourceList # type: ignore - from ._models import BasePolicyRule # type: ignore - from ._models import CheckNameAvailabilityRequest # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import ClientDiscoveryDisplay # type: ignore - from ._models import ClientDiscoveryForLogSpecification # type: ignore - from ._models import ClientDiscoveryForProperties # type: ignore - from ._models import ClientDiscoveryForServiceSpecification # type: ignore - from ._models import ClientDiscoveryResponse # type: ignore - from ._models import ClientDiscoveryValueForSingleApi # type: ignore - from ._models import CopyOnExpiryOption # type: ignore - from ._models import CopyOption # type: ignore - from ._models import CustomCopyOption # type: ignore - from ._models import DataStoreInfoBase # type: ignore - from ._models import DataStoreParameters # type: ignore - from ._models import Datasource # type: ignore - from ._models import DatasourceSet # type: ignore - from ._models import Day # type: ignore - from ._models import DeleteOption # type: ignore - from ._models import DppBaseResource # type: ignore - from ._models import DppBaseResourceList # type: ignore - from ._models import DppIdentityDetails # type: ignore - from ._models import DppResource # type: ignore - from ._models import DppResourceList # type: ignore - from ._models import DppTrackedResource # type: ignore - from ._models import DppTrackedResourceList # type: ignore - from ._models import DppWorkerRequest # type: ignore - from ._models import Error # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ExportJobsResult # type: ignore - from ._models import FeatureValidationRequest # type: ignore - from ._models import FeatureValidationRequestBase # type: ignore - from ._models import FeatureValidationResponse # type: ignore - from ._models import FeatureValidationResponseBase # type: ignore - from ._models import ImmediateCopyOption # type: ignore - from ._models import InnerError # type: ignore - from ._models import ItemLevelRestoreCriteria # type: ignore - from ._models import ItemLevelRestoreTargetInfo # type: ignore - from ._models import JobExtendedInfo # type: ignore - from ._models import JobSubTask # type: ignore - from ._models import OperationExtendedInfo # type: ignore - from ._models import OperationJobExtendedInfo # type: ignore - from ._models import OperationResource # type: ignore - from ._models import PatchResourceRequestInput # type: ignore - from ._models import PolicyInfo # type: ignore - from ._models import PolicyParameters # type: ignore - from ._models import ProtectionStatusDetails # type: ignore - from ._models import RangeBasedItemLevelRestoreCriteria # type: ignore - from ._models import RecoveryPointDataStoreDetails # type: ignore - from ._models import RecoveryPointsFilters # type: ignore - from ._models import ResourceGuard # type: ignore - from ._models import ResourceGuardOperation # type: ignore - from ._models import ResourceGuardResource # type: ignore - from ._models import ResourceGuardResourceList # type: ignore - from ._models import ResourceMoveDetails # type: ignore - from ._models import RestorableTimeRange # type: ignore - from ._models import RestoreFilesTargetInfo # type: ignore - from ._models import RestoreJobRecoveryPointDetails # type: ignore - from ._models import RestoreTargetInfo # type: ignore - from ._models import RestoreTargetInfoBase # type: ignore - from ._models import RetentionTag # type: ignore - from ._models import ScheduleBasedBackupCriteria # type: ignore - from ._models import ScheduleBasedTriggerContext # type: ignore - from ._models import SecretStoreBasedAuthCredentials # type: ignore - from ._models import SecretStoreResource # type: ignore - from ._models import SourceLifeCycle # type: ignore - from ._models import StorageSetting # type: ignore - from ._models import SupportedFeature # type: ignore - from ._models import SystemData # type: ignore - from ._models import TaggingCriteria # type: ignore - from ._models import TargetCopySetting # type: ignore - from ._models import TargetDetails # type: ignore - from ._models import TriggerBackupRequest # type: ignore - from ._models import TriggerContext # type: ignore - from ._models import UserFacingError # type: ignore - from ._models import ValidateForBackupRequest # type: ignore - from ._models import ValidateRestoreRequestObject # type: ignore +from ._models_py3 import AbsoluteDeleteOption +from ._models_py3 import AdHocBackupRuleOptions +from ._models_py3 import AdhocBackupTriggerOption +from ._models_py3 import AdhocBasedTaggingCriteria +from ._models_py3 import AdhocBasedTriggerContext +from ._models_py3 import AuthCredentials +from ._models_py3 import AzureBackupDiscreteRecoveryPoint +from ._models_py3 import AzureBackupFindRestorableTimeRangesRequest +from ._models_py3 import AzureBackupFindRestorableTimeRangesRequestResource +from ._models_py3 import AzureBackupFindRestorableTimeRangesResponse +from ._models_py3 import AzureBackupFindRestorableTimeRangesResponseResource +from ._models_py3 import AzureBackupJob +from ._models_py3 import AzureBackupJobResource +from ._models_py3 import AzureBackupJobResourceList +from ._models_py3 import AzureBackupParams +from ._models_py3 import AzureBackupRecoveryPoint +from ._models_py3 import AzureBackupRecoveryPointBasedRestoreRequest +from ._models_py3 import AzureBackupRecoveryPointResource +from ._models_py3 import AzureBackupRecoveryPointResourceList +from ._models_py3 import AzureBackupRecoveryTimeBasedRestoreRequest +from ._models_py3 import AzureBackupRehydrationRequest +from ._models_py3 import AzureBackupRestoreRequest +from ._models_py3 import AzureBackupRestoreWithRehydrationRequest +from ._models_py3 import AzureBackupRule +from ._models_py3 import AzureMonitorAlertSettings +from ._models_py3 import AzureOperationalStoreParameters +from ._models_py3 import AzureRetentionRule +from ._models_py3 import BackupCriteria +from ._models_py3 import BackupInstance +from ._models_py3 import BackupInstanceResource +from ._models_py3 import BackupInstanceResourceList +from ._models_py3 import BackupParameters +from ._models_py3 import BackupPolicy +from ._models_py3 import BackupSchedule +from ._models_py3 import BackupVault +from ._models_py3 import BackupVaultResource +from ._models_py3 import BackupVaultResourceList +from ._models_py3 import BaseBackupPolicy +from ._models_py3 import BaseBackupPolicyResource +from ._models_py3 import BaseBackupPolicyResourceList +from ._models_py3 import BasePolicyRule +from ._models_py3 import CheckNameAvailabilityRequest +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ClientDiscoveryDisplay +from ._models_py3 import ClientDiscoveryForLogSpecification +from ._models_py3 import ClientDiscoveryForProperties +from ._models_py3 import ClientDiscoveryForServiceSpecification +from ._models_py3 import ClientDiscoveryResponse +from ._models_py3 import ClientDiscoveryValueForSingleApi +from ._models_py3 import CopyOnExpiryOption +from ._models_py3 import CopyOption +from ._models_py3 import CustomCopyOption +from ._models_py3 import DataStoreInfoBase +from ._models_py3 import DataStoreParameters +from ._models_py3 import Datasource +from ._models_py3 import DatasourceSet +from ._models_py3 import Day +from ._models_py3 import DeleteOption +from ._models_py3 import DeletedBackupInstance +from ._models_py3 import DeletedBackupInstanceResource +from ._models_py3 import DeletedBackupInstanceResourceList +from ._models_py3 import DeletionInfo +from ._models_py3 import DppBaseResource +from ._models_py3 import DppBaseResourceList +from ._models_py3 import DppIdentityDetails +from ._models_py3 import DppProxyResource +from ._models_py3 import DppResource +from ._models_py3 import DppResourceList +from ._models_py3 import DppTrackedResource +from ._models_py3 import DppTrackedResourceList +from ._models_py3 import DppWorkerRequest +from ._models_py3 import Error +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ExportJobsResult +from ._models_py3 import FeatureValidationRequest +from ._models_py3 import FeatureValidationRequestBase +from ._models_py3 import FeatureValidationResponse +from ._models_py3 import FeatureValidationResponseBase +from ._models_py3 import ImmediateCopyOption +from ._models_py3 import ImmutabilitySettings +from ._models_py3 import InnerError +from ._models_py3 import ItemLevelRestoreCriteria +from ._models_py3 import ItemLevelRestoreTargetInfo +from ._models_py3 import JobExtendedInfo +from ._models_py3 import JobSubTask +from ._models_py3 import KubernetesPVRestoreCriteria +from ._models_py3 import KubernetesStorageClassRestoreCriteria +from ._models_py3 import MonitoringSettings +from ._models_py3 import OperationExtendedInfo +from ._models_py3 import OperationJobExtendedInfo +from ._models_py3 import OperationResource +from ._models_py3 import PatchBackupVaultInput +from ._models_py3 import PatchResourceRequestInput +from ._models_py3 import PolicyInfo +from ._models_py3 import PolicyParameters +from ._models_py3 import ProtectionStatusDetails +from ._models_py3 import RangeBasedItemLevelRestoreCriteria +from ._models_py3 import RecoveryPointDataStoreDetails +from ._models_py3 import RecoveryPointsFilters +from ._models_py3 import ResourceGuard +from ._models_py3 import ResourceGuardOperation +from ._models_py3 import ResourceGuardOperationDetail +from ._models_py3 import ResourceGuardProxyBase +from ._models_py3 import ResourceGuardProxyBaseResource +from ._models_py3 import ResourceGuardProxyBaseResourceList +from ._models_py3 import ResourceGuardResource +from ._models_py3 import ResourceGuardResourceList +from ._models_py3 import ResourceMoveDetails +from ._models_py3 import RestorableTimeRange +from ._models_py3 import RestoreFilesTargetInfo +from ._models_py3 import RestoreJobRecoveryPointDetails +from ._models_py3 import RestoreTargetInfo +from ._models_py3 import RestoreTargetInfoBase +from ._models_py3 import RetentionTag +from ._models_py3 import ScheduleBasedBackupCriteria +from ._models_py3 import ScheduleBasedTriggerContext +from ._models_py3 import SecretStoreBasedAuthCredentials +from ._models_py3 import SecretStoreResource +from ._models_py3 import SecuritySettings +from ._models_py3 import SoftDeleteSettings +from ._models_py3 import SourceLifeCycle +from ._models_py3 import StorageSetting +from ._models_py3 import SupportedFeature +from ._models_py3 import SyncBackupInstanceRequest +from ._models_py3 import SystemData +from ._models_py3 import TaggingCriteria +from ._models_py3 import TargetCopySetting +from ._models_py3 import TargetDetails +from ._models_py3 import TriggerBackupRequest +from ._models_py3 import TriggerContext +from ._models_py3 import UnlockDeleteRequest +from ._models_py3 import UnlockDeleteResponse +from ._models_py3 import UserFacingError +from ._models_py3 import ValidateForBackupRequest +from ._models_py3 import ValidateRestoreRequestObject -from ._data_protection_client_enums import ( - AbsoluteMarker, - CreatedByType, - CurrentProtectionState, - DataStoreTypes, - DayOfWeek, - FeatureSupportStatus, - FeatureType, - Month, - ProvisioningState, - RecoveryOption, - RehydrationPriority, - RehydrationStatus, - ResourceMoveState, - RestoreSourceDataStoreType, - RestoreTargetLocationType, - SecretStoreType, - SourceDataStoreType, - Status, - StorageSettingStoreTypes, - StorageSettingTypes, - WeekNumber, -) +from ._data_protection_client_enums import AbsoluteMarker +from ._data_protection_client_enums import AlertsState +from ._data_protection_client_enums import CreatedByType +from ._data_protection_client_enums import CurrentProtectionState +from ._data_protection_client_enums import DataStoreTypes +from ._data_protection_client_enums import DayOfWeek +from ._data_protection_client_enums import FeatureSupportStatus +from ._data_protection_client_enums import FeatureType +from ._data_protection_client_enums import ImmutabilityState +from ._data_protection_client_enums import Month +from ._data_protection_client_enums import ProvisioningState +from ._data_protection_client_enums import RecoveryOption +from ._data_protection_client_enums import RehydrationPriority +from ._data_protection_client_enums import RehydrationStatus +from ._data_protection_client_enums import ResourceGuardProvisioningState +from ._data_protection_client_enums import ResourceMoveState +from ._data_protection_client_enums import RestoreSourceDataStoreType +from ._data_protection_client_enums import RestoreTargetLocationType +from ._data_protection_client_enums import SecretStoreType +from ._data_protection_client_enums import SoftDeleteState +from ._data_protection_client_enums import SourceDataStoreType +from ._data_protection_client_enums import Status +from ._data_protection_client_enums import StorageSettingStoreTypes +from ._data_protection_client_enums import StorageSettingTypes +from ._data_protection_client_enums import SyncType +from ._data_protection_client_enums import ValidationType +from ._data_protection_client_enums import WeekNumber +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AbsoluteDeleteOption', - 'AdHocBackupRuleOptions', - 'AdhocBackupTriggerOption', - 'AdhocBasedTaggingCriteria', - 'AdhocBasedTriggerContext', - 'AuthCredentials', - 'AzureBackupDiscreteRecoveryPoint', - 'AzureBackupFindRestorableTimeRangesRequest', - 'AzureBackupFindRestorableTimeRangesRequestResource', - 'AzureBackupFindRestorableTimeRangesResponse', - 'AzureBackupFindRestorableTimeRangesResponseResource', - 'AzureBackupJob', - 'AzureBackupJobResource', - 'AzureBackupJobResourceList', - 'AzureBackupParams', - 'AzureBackupRecoveryPoint', - 'AzureBackupRecoveryPointBasedRestoreRequest', - 'AzureBackupRecoveryPointResource', - 'AzureBackupRecoveryPointResourceList', - 'AzureBackupRecoveryTimeBasedRestoreRequest', - 'AzureBackupRehydrationRequest', - 'AzureBackupRestoreRequest', - 'AzureBackupRestoreWithRehydrationRequest', - 'AzureBackupRule', - 'AzureOperationalStoreParameters', - 'AzureRetentionRule', - 'BackupCriteria', - 'BackupInstance', - 'BackupInstanceResource', - 'BackupInstanceResourceList', - 'BackupParameters', - 'BackupPolicy', - 'BackupSchedule', - 'BackupVault', - 'BackupVaultResource', - 'BackupVaultResourceList', - 'BaseBackupPolicy', - 'BaseBackupPolicyResource', - 'BaseBackupPolicyResourceList', - 'BasePolicyRule', - 'CheckNameAvailabilityRequest', - 'CheckNameAvailabilityResult', - 'ClientDiscoveryDisplay', - 'ClientDiscoveryForLogSpecification', - 'ClientDiscoveryForProperties', - 'ClientDiscoveryForServiceSpecification', - 'ClientDiscoveryResponse', - 'ClientDiscoveryValueForSingleApi', - 'CopyOnExpiryOption', - 'CopyOption', - 'CustomCopyOption', - 'DataStoreInfoBase', - 'DataStoreParameters', - 'Datasource', - 'DatasourceSet', - 'Day', - 'DeleteOption', - 'DppBaseResource', - 'DppBaseResourceList', - 'DppIdentityDetails', - 'DppResource', - 'DppResourceList', - 'DppTrackedResource', - 'DppTrackedResourceList', - 'DppWorkerRequest', - 'Error', - 'ErrorAdditionalInfo', - 'ExportJobsResult', - 'FeatureValidationRequest', - 'FeatureValidationRequestBase', - 'FeatureValidationResponse', - 'FeatureValidationResponseBase', - 'ImmediateCopyOption', - 'InnerError', - 'ItemLevelRestoreCriteria', - 'ItemLevelRestoreTargetInfo', - 'JobExtendedInfo', - 'JobSubTask', - 'OperationExtendedInfo', - 'OperationJobExtendedInfo', - 'OperationResource', - 'PatchResourceRequestInput', - 'PolicyInfo', - 'PolicyParameters', - 'ProtectionStatusDetails', - 'RangeBasedItemLevelRestoreCriteria', - 'RecoveryPointDataStoreDetails', - 'RecoveryPointsFilters', - 'ResourceGuard', - 'ResourceGuardOperation', - 'ResourceGuardResource', - 'ResourceGuardResourceList', - 'ResourceMoveDetails', - 'RestorableTimeRange', - 'RestoreFilesTargetInfo', - 'RestoreJobRecoveryPointDetails', - 'RestoreTargetInfo', - 'RestoreTargetInfoBase', - 'RetentionTag', - 'ScheduleBasedBackupCriteria', - 'ScheduleBasedTriggerContext', - 'SecretStoreBasedAuthCredentials', - 'SecretStoreResource', - 'SourceLifeCycle', - 'StorageSetting', - 'SupportedFeature', - 'SystemData', - 'TaggingCriteria', - 'TargetCopySetting', - 'TargetDetails', - 'TriggerBackupRequest', - 'TriggerContext', - 'UserFacingError', - 'ValidateForBackupRequest', - 'ValidateRestoreRequestObject', - 'AbsoluteMarker', - 'CreatedByType', - 'CurrentProtectionState', - 'DataStoreTypes', - 'DayOfWeek', - 'FeatureSupportStatus', - 'FeatureType', - 'Month', - 'ProvisioningState', - 'RecoveryOption', - 'RehydrationPriority', - 'RehydrationStatus', - 'ResourceMoveState', - 'RestoreSourceDataStoreType', - 'RestoreTargetLocationType', - 'SecretStoreType', - 'SourceDataStoreType', - 'Status', - 'StorageSettingStoreTypes', - 'StorageSettingTypes', - 'WeekNumber', + "AbsoluteDeleteOption", + "AdHocBackupRuleOptions", + "AdhocBackupTriggerOption", + "AdhocBasedTaggingCriteria", + "AdhocBasedTriggerContext", + "AuthCredentials", + "AzureBackupDiscreteRecoveryPoint", + "AzureBackupFindRestorableTimeRangesRequest", + "AzureBackupFindRestorableTimeRangesRequestResource", + "AzureBackupFindRestorableTimeRangesResponse", + "AzureBackupFindRestorableTimeRangesResponseResource", + "AzureBackupJob", + "AzureBackupJobResource", + "AzureBackupJobResourceList", + "AzureBackupParams", + "AzureBackupRecoveryPoint", + "AzureBackupRecoveryPointBasedRestoreRequest", + "AzureBackupRecoveryPointResource", + "AzureBackupRecoveryPointResourceList", + "AzureBackupRecoveryTimeBasedRestoreRequest", + "AzureBackupRehydrationRequest", + "AzureBackupRestoreRequest", + "AzureBackupRestoreWithRehydrationRequest", + "AzureBackupRule", + "AzureMonitorAlertSettings", + "AzureOperationalStoreParameters", + "AzureRetentionRule", + "BackupCriteria", + "BackupInstance", + "BackupInstanceResource", + "BackupInstanceResourceList", + "BackupParameters", + "BackupPolicy", + "BackupSchedule", + "BackupVault", + "BackupVaultResource", + "BackupVaultResourceList", + "BaseBackupPolicy", + "BaseBackupPolicyResource", + "BaseBackupPolicyResourceList", + "BasePolicyRule", + "CheckNameAvailabilityRequest", + "CheckNameAvailabilityResult", + "ClientDiscoveryDisplay", + "ClientDiscoveryForLogSpecification", + "ClientDiscoveryForProperties", + "ClientDiscoveryForServiceSpecification", + "ClientDiscoveryResponse", + "ClientDiscoveryValueForSingleApi", + "CopyOnExpiryOption", + "CopyOption", + "CustomCopyOption", + "DataStoreInfoBase", + "DataStoreParameters", + "Datasource", + "DatasourceSet", + "Day", + "DeleteOption", + "DeletedBackupInstance", + "DeletedBackupInstanceResource", + "DeletedBackupInstanceResourceList", + "DeletionInfo", + "DppBaseResource", + "DppBaseResourceList", + "DppIdentityDetails", + "DppProxyResource", + "DppResource", + "DppResourceList", + "DppTrackedResource", + "DppTrackedResourceList", + "DppWorkerRequest", + "Error", + "ErrorAdditionalInfo", + "ExportJobsResult", + "FeatureValidationRequest", + "FeatureValidationRequestBase", + "FeatureValidationResponse", + "FeatureValidationResponseBase", + "ImmediateCopyOption", + "ImmutabilitySettings", + "InnerError", + "ItemLevelRestoreCriteria", + "ItemLevelRestoreTargetInfo", + "JobExtendedInfo", + "JobSubTask", + "KubernetesPVRestoreCriteria", + "KubernetesStorageClassRestoreCriteria", + "MonitoringSettings", + "OperationExtendedInfo", + "OperationJobExtendedInfo", + "OperationResource", + "PatchBackupVaultInput", + "PatchResourceRequestInput", + "PolicyInfo", + "PolicyParameters", + "ProtectionStatusDetails", + "RangeBasedItemLevelRestoreCriteria", + "RecoveryPointDataStoreDetails", + "RecoveryPointsFilters", + "ResourceGuard", + "ResourceGuardOperation", + "ResourceGuardOperationDetail", + "ResourceGuardProxyBase", + "ResourceGuardProxyBaseResource", + "ResourceGuardProxyBaseResourceList", + "ResourceGuardResource", + "ResourceGuardResourceList", + "ResourceMoveDetails", + "RestorableTimeRange", + "RestoreFilesTargetInfo", + "RestoreJobRecoveryPointDetails", + "RestoreTargetInfo", + "RestoreTargetInfoBase", + "RetentionTag", + "ScheduleBasedBackupCriteria", + "ScheduleBasedTriggerContext", + "SecretStoreBasedAuthCredentials", + "SecretStoreResource", + "SecuritySettings", + "SoftDeleteSettings", + "SourceLifeCycle", + "StorageSetting", + "SupportedFeature", + "SyncBackupInstanceRequest", + "SystemData", + "TaggingCriteria", + "TargetCopySetting", + "TargetDetails", + "TriggerBackupRequest", + "TriggerContext", + "UnlockDeleteRequest", + "UnlockDeleteResponse", + "UserFacingError", + "ValidateForBackupRequest", + "ValidateRestoreRequestObject", + "AbsoluteMarker", + "AlertsState", + "CreatedByType", + "CurrentProtectionState", + "DataStoreTypes", + "DayOfWeek", + "FeatureSupportStatus", + "FeatureType", + "ImmutabilityState", + "Month", + "ProvisioningState", + "RecoveryOption", + "RehydrationPriority", + "RehydrationStatus", + "ResourceGuardProvisioningState", + "ResourceMoveState", + "RestoreSourceDataStoreType", + "RestoreTargetLocationType", + "SecretStoreType", + "SoftDeleteState", + "SourceDataStoreType", + "Status", + "StorageSettingStoreTypes", + "StorageSettingTypes", + "SyncType", + "ValidationType", + "WeekNumber", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_client_enums.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_client_enums.py index 926803c67b2c..d4d6b7def37b 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_client_enums.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AbsoluteMarker(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AbsoluteMarker(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AbsoluteMarker.""" ALL_BACKUP = "AllBackup" FIRST_OF_DAY = "FirstOfDay" @@ -34,18 +19,25 @@ class AbsoluteMarker(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FIRST_OF_WEEK = "FirstOfWeek" FIRST_OF_YEAR = "FirstOfYear" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class AlertsState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AlertsState.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class CurrentProtectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Specifies the current protection state of the resource - """ + +class CurrentProtectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the current protection state of the resource.""" INVALID = "Invalid" NOT_PROTECTED = "NotProtected" @@ -60,15 +52,17 @@ class CurrentProtectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) SOFT_DELETED = "SoftDeleted" UPDATING_PROTECTION = "UpdatingProtection" -class DataStoreTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """type of datastore; Operational/Vault/Archive - """ + +class DataStoreTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """type of datastore; Operational/Vault/Archive.""" OPERATIONAL_STORE = "OperationalStore" VAULT_STORE = "VaultStore" ARCHIVE_STORE = "ArchiveStore" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" FRIDAY = "Friday" MONDAY = "Monday" @@ -78,9 +72,9 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): TUESDAY = "Tuesday" WEDNESDAY = "Wednesday" -class FeatureSupportStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """feature support status - """ + +class FeatureSupportStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """feature support status.""" INVALID = "Invalid" NOT_SUPPORTED = "NotSupported" @@ -89,14 +83,24 @@ class FeatureSupportStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PUBLIC_PREVIEW = "PublicPreview" GENERALLY_AVAILABLE = "GenerallyAvailable" -class FeatureType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """backup support feature type. - """ + +class FeatureType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """backup support feature type.""" INVALID = "Invalid" DATA_SOURCE_TYPE = "DataSourceType" -class Month(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ImmutabilityState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Immutability state.""" + + DISABLED = "Disabled" + UNLOCKED = "Unlocked" + LOCKED = "Locked" + + +class Month(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Month.""" APRIL = "April" AUGUST = "August" @@ -111,9 +115,9 @@ class Month(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OCTOBER = "October" SEPTEMBER = "September" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the BackupVault resource - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the BackupVault resource.""" FAILED = "Failed" PROVISIONING = "Provisioning" @@ -121,21 +125,23 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNKNOWN = "Unknown" UPDATING = "Updating" -class RecoveryOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Recovery Option - """ + +class RecoveryOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Recovery Option.""" FAIL_IF_EXISTS = "FailIfExists" -class RehydrationPriority(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Priority to be used for rehydration. Values High or Standard - """ + +class RehydrationPriority(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Priority to be used for rehydration. Values High or Standard.""" INVALID = "Invalid" HIGH = "High" STANDARD = "Standard" -class RehydrationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RehydrationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RehydrationStatus.""" CREATE_IN_PROGRESS = "CREATE_IN_PROGRESS" COMPLETED = "COMPLETED" @@ -143,9 +149,19 @@ class RehydrationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "DELETED" FAILED = "FAILED" -class ResourceMoveState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Resource move state for backup vault - """ + +class ResourceGuardProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the BackupVault resource.""" + + FAILED = "Failed" + PROVISIONING = "Provisioning" + SUCCEEDED = "Succeeded" + UNKNOWN = "Unknown" + UPDATING = "Updating" + + +class ResourceMoveState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Resource move state for backup vault.""" UNKNOWN = "Unknown" IN_PROGRESS = "InProgress" @@ -158,42 +174,54 @@ class ResourceMoveState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PARTIAL_SUCCESS = "PartialSuccess" MOVE_SUCCEEDED = "MoveSucceeded" -class RestoreSourceDataStoreType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the source data store. - """ + +class RestoreSourceDataStoreType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the source data store.""" OPERATIONAL_STORE = "OperationalStore" VAULT_STORE = "VaultStore" ARCHIVE_STORE = "ArchiveStore" -class RestoreTargetLocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RestoreTargetLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Denotes the target location where the data will be restored, string value for the enum - {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType} + {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}. """ INVALID = "Invalid" AZURE_BLOBS = "AzureBlobs" AZURE_FILES = "AzureFiles" -class SecretStoreType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of secret store - """ + +class SecretStoreType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of secret store.""" INVALID = "Invalid" AZURE_KEY_VAULT = "AzureKeyVault" -class SourceDataStoreType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the source data store. - """ + +class SoftDeleteState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of soft delete.""" + + #: Soft Delete is turned off for the BackupVault + OFF = "Off" + #: Soft Delete is enabled for the BackupVault but can be turned off + ON = "On" + #: Soft Delete is permanently enabled for the BackupVault and the setting cannot be changed + ALWAYS_ON = "AlwaysOn" + + +class SourceDataStoreType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the source data store.""" ARCHIVE_STORE = "ArchiveStore" SNAPSHOT_STORE = "SnapshotStore" VAULT_STORE = "VaultStore" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Specifies the protection status of the resource - """ + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the protection status of the resource.""" CONFIGURING_PROTECTION = "ConfiguringProtection" CONFIGURING_PROTECTION_FAILED = "ConfiguringProtectionFailed" @@ -202,22 +230,41 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SOFT_DELETED = "SoftDeleted" SOFT_DELETING = "SoftDeleting" -class StorageSettingStoreTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type of the datastore. - """ + +class StorageSettingStoreTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type of the datastore.""" ARCHIVE_STORE = "ArchiveStore" SNAPSHOT_STORE = "SnapshotStore" VAULT_STORE = "VaultStore" -class StorageSettingTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Gets or sets the type. - """ + +class StorageSettingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the type.""" GEO_REDUNDANT = "GeoRedundant" LOCALLY_REDUNDANT = "LocallyRedundant" + ZONE_REDUNDANT = "ZoneRedundant" + + +class SyncType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Field indicating sync type e.g. to sync only in case of failure or in all cases.""" + + DEFAULT = "Default" + FORCE_RESYNC = "ForceResync" + + +class ValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the type of validation. In case of DeepValidation, all validations from + /validateForBackup API will run again. + """ + + SHALLOW_VALIDATION = "ShallowValidation" + DEEP_VALIDATION = "DeepValidation" + -class WeekNumber(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WeekNumber(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WeekNumber.""" FIRST = "First" FOURTH = "Fourth" diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models.py deleted file mode 100644 index 459c310a482e..000000000000 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models.py +++ /dev/null @@ -1,4205 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class DeleteOption(msrest.serialization.Model): - """Delete Option. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AbsoluteDeleteOption. - - All required parameters must be populated in order to send to Azure. - - :param duration: Required. Duration of deletion after given timespan. - :type duration: str - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'duration': {'required': True}, - 'object_type': {'required': True}, - } - - _attribute_map = { - 'duration': {'key': 'duration', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AbsoluteDeleteOption': 'AbsoluteDeleteOption'} - } - - def __init__( - self, - **kwargs - ): - super(DeleteOption, self).__init__(**kwargs) - self.duration = kwargs['duration'] - self.object_type = None # type: Optional[str] - - -class AbsoluteDeleteOption(DeleteOption): - """Delete option with duration. - - All required parameters must be populated in order to send to Azure. - - :param duration: Required. Duration of deletion after given timespan. - :type duration: str - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'duration': {'required': True}, - 'object_type': {'required': True}, - } - - _attribute_map = { - 'duration': {'key': 'duration', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AbsoluteDeleteOption, self).__init__(**kwargs) - self.object_type = 'AbsoluteDeleteOption' # type: str - - -class AdHocBackupRuleOptions(msrest.serialization.Model): - """Adhoc backup rules. - - All required parameters must be populated in order to send to Azure. - - :param rule_name: Required. - :type rule_name: str - :param trigger_option: Required. Adhoc backup trigger option. - :type trigger_option: ~azure.mgmt.dataprotection.models.AdhocBackupTriggerOption - """ - - _validation = { - 'rule_name': {'required': True}, - 'trigger_option': {'required': True}, - } - - _attribute_map = { - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'trigger_option': {'key': 'triggerOption', 'type': 'AdhocBackupTriggerOption'}, - } - - def __init__( - self, - **kwargs - ): - super(AdHocBackupRuleOptions, self).__init__(**kwargs) - self.rule_name = kwargs['rule_name'] - self.trigger_option = kwargs['trigger_option'] - - -class AdhocBackupTriggerOption(msrest.serialization.Model): - """Adhoc backup trigger option. - - :param retention_tag_override: - :type retention_tag_override: str - """ - - _attribute_map = { - 'retention_tag_override': {'key': 'retentionTagOverride', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdhocBackupTriggerOption, self).__init__(**kwargs) - self.retention_tag_override = kwargs.get('retention_tag_override', None) - - -class AdhocBasedTaggingCriteria(msrest.serialization.Model): - """Adhoc backup tagging criteria. - - :param tag_info: Retention tag information. - :type tag_info: ~azure.mgmt.dataprotection.models.RetentionTag - """ - - _attribute_map = { - 'tag_info': {'key': 'tagInfo', 'type': 'RetentionTag'}, - } - - def __init__( - self, - **kwargs - ): - super(AdhocBasedTaggingCriteria, self).__init__(**kwargs) - self.tag_info = kwargs.get('tag_info', None) - - -class TriggerContext(msrest.serialization.Model): - """Trigger context. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AdhocBasedTriggerContext, ScheduleBasedTriggerContext. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AdhocBasedTriggerContext': 'AdhocBasedTriggerContext', 'ScheduleBasedTriggerContext': 'ScheduleBasedTriggerContext'} - } - - def __init__( - self, - **kwargs - ): - super(TriggerContext, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class AdhocBasedTriggerContext(TriggerContext): - """Adhoc trigger context. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param tagging_criteria: Required. Tagging Criteria containing retention tag for adhoc backup. - :type tagging_criteria: ~azure.mgmt.dataprotection.models.AdhocBasedTaggingCriteria - """ - - _validation = { - 'object_type': {'required': True}, - 'tagging_criteria': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'tagging_criteria': {'key': 'taggingCriteria', 'type': 'AdhocBasedTaggingCriteria'}, - } - - def __init__( - self, - **kwargs - ): - super(AdhocBasedTriggerContext, self).__init__(**kwargs) - self.object_type = 'AdhocBasedTriggerContext' # type: str - self.tagging_criteria = kwargs['tagging_criteria'] - - -class AuthCredentials(msrest.serialization.Model): - """Base class for different types of authentication credentials. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SecretStoreBasedAuthCredentials. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'SecretStoreBasedAuthCredentials': 'SecretStoreBasedAuthCredentials'} - } - - def __init__( - self, - **kwargs - ): - super(AuthCredentials, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class AzureBackupRecoveryPoint(msrest.serialization.Model): - """Azure backup recoveryPoint. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupDiscreteRecoveryPoint. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Constant filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AzureBackupDiscreteRecoveryPoint': 'AzureBackupDiscreteRecoveryPoint'} - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRecoveryPoint, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class AzureBackupDiscreteRecoveryPoint(AzureBackupRecoveryPoint): - """Azure backup discrete RecoveryPoint. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Constant filled by server. - :type object_type: str - :param friendly_name: - :type friendly_name: str - :param recovery_point_data_stores_details: - :type recovery_point_data_stores_details: - list[~azure.mgmt.dataprotection.models.RecoveryPointDataStoreDetails] - :param recovery_point_time: Required. - :type recovery_point_time: ~datetime.datetime - :param policy_name: - :type policy_name: str - :param policy_version: - :type policy_version: str - :param recovery_point_id: - :type recovery_point_id: str - :param recovery_point_type: - :type recovery_point_type: str - :param retention_tag_name: - :type retention_tag_name: str - :param retention_tag_version: - :type retention_tag_version: str - """ - - _validation = { - 'object_type': {'required': True}, - 'recovery_point_time': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'recovery_point_data_stores_details': {'key': 'recoveryPointDataStoresDetails', 'type': '[RecoveryPointDataStoreDetails]'}, - 'recovery_point_time': {'key': 'recoveryPointTime', 'type': 'iso-8601'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, - 'policy_version': {'key': 'policyVersion', 'type': 'str'}, - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - 'recovery_point_type': {'key': 'recoveryPointType', 'type': 'str'}, - 'retention_tag_name': {'key': 'retentionTagName', 'type': 'str'}, - 'retention_tag_version': {'key': 'retentionTagVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupDiscreteRecoveryPoint, self).__init__(**kwargs) - self.object_type = 'AzureBackupDiscreteRecoveryPoint' # type: str - self.friendly_name = kwargs.get('friendly_name', None) - self.recovery_point_data_stores_details = kwargs.get('recovery_point_data_stores_details', None) - self.recovery_point_time = kwargs['recovery_point_time'] - self.policy_name = kwargs.get('policy_name', None) - self.policy_version = kwargs.get('policy_version', None) - self.recovery_point_id = kwargs.get('recovery_point_id', None) - self.recovery_point_type = kwargs.get('recovery_point_type', None) - self.retention_tag_name = kwargs.get('retention_tag_name', None) - self.retention_tag_version = kwargs.get('retention_tag_version', None) - - -class AzureBackupFindRestorableTimeRangesRequest(msrest.serialization.Model): - """List Restore Ranges Request. - - All required parameters must be populated in order to send to Azure. - - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "OperationalStore", "VaultStore", "ArchiveStore". - :type source_data_store_type: str or - ~azure.mgmt.dataprotection.models.RestoreSourceDataStoreType - :param start_time: Start time for the List Restore Ranges request. ISO 8601 format. - :type start_time: str - :param end_time: End time for the List Restore Ranges request. ISO 8601 format. - :type end_time: str - """ - - _validation = { - 'source_data_store_type': {'required': True}, - } - - _attribute_map = { - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupFindRestorableTimeRangesRequest, self).__init__(**kwargs) - self.source_data_store_type = kwargs['source_data_store_type'] - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - - -class DppWorkerRequest(msrest.serialization.Model): - """DppWorkerRequest. - - :param subscription_id: - :type subscription_id: str - :param uri: - :type uri: str - :param headers: Dictionary of - . - :type headers: dict[str, list[str]] - :param supported_group_versions: - :type supported_group_versions: list[str] - :param culture_info: - :type culture_info: str - :param parameters: Dictionary of :code:``. - :type parameters: dict[str, str] - :param http_method: - :type http_method: str - """ - - _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{[str]}'}, - 'supported_group_versions': {'key': 'supportedGroupVersions', 'type': '[str]'}, - 'culture_info': {'key': 'cultureInfo', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DppWorkerRequest, self).__init__(**kwargs) - self.subscription_id = kwargs.get('subscription_id', None) - self.uri = kwargs.get('uri', None) - self.headers = kwargs.get('headers', None) - self.supported_group_versions = kwargs.get('supported_group_versions', None) - self.culture_info = kwargs.get('culture_info', None) - self.parameters = kwargs.get('parameters', None) - self.http_method = kwargs.get('http_method', None) - - -class AzureBackupFindRestorableTimeRangesRequestResource(DppWorkerRequest): - """List Restore Ranges Request. - - :param subscription_id: - :type subscription_id: str - :param uri: - :type uri: str - :param headers: Dictionary of - . - :type headers: dict[str, list[str]] - :param supported_group_versions: - :type supported_group_versions: list[str] - :param culture_info: - :type culture_info: str - :param parameters: Dictionary of :code:``. - :type parameters: dict[str, str] - :param http_method: - :type http_method: str - :param content: AzureBackupFindRestorableTimeRangesRequestResource content. - :type content: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest - """ - - _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{[str]}'}, - 'supported_group_versions': {'key': 'supportedGroupVersions', 'type': '[str]'}, - 'culture_info': {'key': 'cultureInfo', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'AzureBackupFindRestorableTimeRangesRequest'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupFindRestorableTimeRangesRequestResource, self).__init__(**kwargs) - self.content = kwargs.get('content', None) - - -class AzureBackupFindRestorableTimeRangesResponse(msrest.serialization.Model): - """List Restore Ranges Response. - - :param restorable_time_ranges: Returns the Restore Ranges available on the Backup Instance. - :type restorable_time_ranges: list[~azure.mgmt.dataprotection.models.RestorableTimeRange] - :param object_type: - :type object_type: str - """ - - _attribute_map = { - 'restorable_time_ranges': {'key': 'restorableTimeRanges', 'type': '[RestorableTimeRange]'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupFindRestorableTimeRangesResponse, self).__init__(**kwargs) - self.restorable_time_ranges = kwargs.get('restorable_time_ranges', None) - self.object_type = kwargs.get('object_type', None) - - -class DppResource(msrest.serialization.Model): - """Resource class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(DppResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class AzureBackupFindRestorableTimeRangesResponseResource(DppResource): - """List Restore Ranges Response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: AzureBackupFindRestorableTimeRangesResponseResource properties. - :type properties: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponse - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'AzureBackupFindRestorableTimeRangesResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupFindRestorableTimeRangesResponseResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AzureBackupJob(msrest.serialization.Model): - """AzureBackup Job Class. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param activity_id: Required. Job Activity Id. - :type activity_id: str - :param backup_instance_friendly_name: Required. Name of the Backup Instance. - :type backup_instance_friendly_name: str - :ivar backup_instance_id: ARM ID of the Backup Instance. - :vartype backup_instance_id: str - :param data_source_id: Required. ARM ID of the DataSource. - :type data_source_id: str - :param data_source_location: Required. Location of the DataSource. - :type data_source_location: str - :param data_source_name: Required. User Friendly Name of the DataSource. - :type data_source_name: str - :param data_source_set_name: Data Source Set Name of the DataSource. - :type data_source_set_name: str - :param data_source_type: Required. Type of DataSource. - :type data_source_type: str - :param duration: Total run time of the job. ISO 8601 format. - :type duration: str - :ivar end_time: EndTime of the job(in UTC). - :vartype end_time: ~datetime.datetime - :ivar error_details: A List, detailing the errors related to the job. - :vartype error_details: list[~azure.mgmt.dataprotection.models.UserFacingError] - :ivar extended_info: Extended Information about the job. - :vartype extended_info: ~azure.mgmt.dataprotection.models.JobExtendedInfo - :param is_user_triggered: Required. Indicated that whether the job is adhoc(true) or - scheduled(false). - :type is_user_triggered: bool - :param operation: Required. It indicates the type of Job i.e. Backup:full/log/diff - ;Restore:ALR/OLR; Tiering:Backup/Archive ; Management:ConfigureProtection/UnConfigure. - :type operation: str - :param operation_category: Required. It indicates the type of Job i.e. - Backup/Restore/Tiering/Management. - :type operation_category: str - :ivar policy_id: ARM ID of the policy. - :vartype policy_id: str - :ivar policy_name: Name of the policy. - :vartype policy_name: str - :param progress_enabled: Required. Indicated whether progress is enabled for the job. - :type progress_enabled: bool - :ivar progress_url: Url which contains job's progress. - :vartype progress_url: str - :ivar restore_type: It indicates the sub type of operation i.e. in case of Restore it can be - ALR/OLR. - :vartype restore_type: str - :param source_resource_group: Required. Resource Group Name of the Datasource. - :type source_resource_group: str - :param source_subscription_id: Required. SubscriptionId corresponding to the DataSource. - :type source_subscription_id: str - :param start_time: Required. StartTime of the job(in UTC). - :type start_time: ~datetime.datetime - :param status: Required. Status of the job like - InProgress/Success/Failed/Cancelled/SuccessWithWarning. - :type status: str - :param subscription_id: Required. Subscription Id of the corresponding backup vault. - :type subscription_id: str - :param supported_actions: Required. List of supported actions. - :type supported_actions: list[str] - :param vault_name: Required. Name of the vault. - :type vault_name: str - :param etag: - :type etag: str - :param source_data_store_name: - :type source_data_store_name: str - :param destination_data_store_name: - :type destination_data_store_name: str - """ - - _validation = { - 'activity_id': {'required': True}, - 'backup_instance_friendly_name': {'required': True}, - 'backup_instance_id': {'readonly': True}, - 'data_source_id': {'required': True}, - 'data_source_location': {'required': True}, - 'data_source_name': {'required': True}, - 'data_source_type': {'required': True}, - 'end_time': {'readonly': True}, - 'error_details': {'readonly': True}, - 'extended_info': {'readonly': True}, - 'is_user_triggered': {'required': True}, - 'operation': {'required': True}, - 'operation_category': {'required': True}, - 'policy_id': {'readonly': True}, - 'policy_name': {'readonly': True}, - 'progress_enabled': {'required': True}, - 'progress_url': {'readonly': True}, - 'restore_type': {'readonly': True}, - 'source_resource_group': {'required': True}, - 'source_subscription_id': {'required': True}, - 'start_time': {'required': True}, - 'status': {'required': True}, - 'subscription_id': {'required': True}, - 'supported_actions': {'required': True}, - 'vault_name': {'required': True}, - } - - _attribute_map = { - 'activity_id': {'key': 'activityID', 'type': 'str'}, - 'backup_instance_friendly_name': {'key': 'backupInstanceFriendlyName', 'type': 'str'}, - 'backup_instance_id': {'key': 'backupInstanceId', 'type': 'str'}, - 'data_source_id': {'key': 'dataSourceId', 'type': 'str'}, - 'data_source_location': {'key': 'dataSourceLocation', 'type': 'str'}, - 'data_source_name': {'key': 'dataSourceName', 'type': 'str'}, - 'data_source_set_name': {'key': 'dataSourceSetName', 'type': 'str'}, - 'data_source_type': {'key': 'dataSourceType', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'error_details': {'key': 'errorDetails', 'type': '[UserFacingError]'}, - 'extended_info': {'key': 'extendedInfo', 'type': 'JobExtendedInfo'}, - 'is_user_triggered': {'key': 'isUserTriggered', 'type': 'bool'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'operation_category': {'key': 'operationCategory', 'type': 'str'}, - 'policy_id': {'key': 'policyId', 'type': 'str'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, - 'progress_enabled': {'key': 'progressEnabled', 'type': 'bool'}, - 'progress_url': {'key': 'progressUrl', 'type': 'str'}, - 'restore_type': {'key': 'restoreType', 'type': 'str'}, - 'source_resource_group': {'key': 'sourceResourceGroup', 'type': 'str'}, - 'source_subscription_id': {'key': 'sourceSubscriptionID', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'supported_actions': {'key': 'supportedActions', 'type': '[str]'}, - 'vault_name': {'key': 'vaultName', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'source_data_store_name': {'key': 'sourceDataStoreName', 'type': 'str'}, - 'destination_data_store_name': {'key': 'destinationDataStoreName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupJob, self).__init__(**kwargs) - self.activity_id = kwargs['activity_id'] - self.backup_instance_friendly_name = kwargs['backup_instance_friendly_name'] - self.backup_instance_id = None - self.data_source_id = kwargs['data_source_id'] - self.data_source_location = kwargs['data_source_location'] - self.data_source_name = kwargs['data_source_name'] - self.data_source_set_name = kwargs.get('data_source_set_name', None) - self.data_source_type = kwargs['data_source_type'] - self.duration = kwargs.get('duration', None) - self.end_time = None - self.error_details = None - self.extended_info = None - self.is_user_triggered = kwargs['is_user_triggered'] - self.operation = kwargs['operation'] - self.operation_category = kwargs['operation_category'] - self.policy_id = None - self.policy_name = None - self.progress_enabled = kwargs['progress_enabled'] - self.progress_url = None - self.restore_type = None - self.source_resource_group = kwargs['source_resource_group'] - self.source_subscription_id = kwargs['source_subscription_id'] - self.start_time = kwargs['start_time'] - self.status = kwargs['status'] - self.subscription_id = kwargs['subscription_id'] - self.supported_actions = kwargs['supported_actions'] - self.vault_name = kwargs['vault_name'] - self.etag = kwargs.get('etag', None) - self.source_data_store_name = kwargs.get('source_data_store_name', None) - self.destination_data_store_name = kwargs.get('destination_data_store_name', None) - - -class AzureBackupJobResource(DppResource): - """AzureBackup Job Resource Class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: AzureBackupJobResource properties. - :type properties: ~azure.mgmt.dataprotection.models.AzureBackupJob - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'AzureBackupJob'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupJobResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class DppResourceList(msrest.serialization.Model): - """ListResource. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DppResourceList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - - -class AzureBackupJobResourceList(DppResourceList): - """List of AzureBackup Job resources. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.AzureBackupJobResource] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[AzureBackupJobResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupJobResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class BackupParameters(msrest.serialization.Model): - """BackupParameters base. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupParams. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AzureBackupParams': 'AzureBackupParams'} - } - - def __init__( - self, - **kwargs - ): - super(BackupParameters, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class AzureBackupParams(BackupParameters): - """Azure backup parameters. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param backup_type: Required. BackupType ; Full/Incremental etc. - :type backup_type: str - """ - - _validation = { - 'object_type': {'required': True}, - 'backup_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'backup_type': {'key': 'backupType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupParams, self).__init__(**kwargs) - self.object_type = 'AzureBackupParams' # type: str - self.backup_type = kwargs['backup_type'] - - -class AzureBackupRestoreRequest(msrest.serialization.Model): - """Azure backup restore request. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupRecoveryPointBasedRestoreRequest, AzureBackupRecoveryTimeBasedRestoreRequest. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - """ - - _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AzureBackupRecoveryPointBasedRestoreRequest': 'AzureBackupRecoveryPointBasedRestoreRequest', 'AzureBackupRecoveryTimeBasedRestoreRequest': 'AzureBackupRecoveryTimeBasedRestoreRequest'} - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRestoreRequest, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - self.restore_target_info = kwargs['restore_target_info'] - self.source_data_store_type = kwargs['source_data_store_type'] - - -class AzureBackupRecoveryPointBasedRestoreRequest(AzureBackupRestoreRequest): - """Azure backup recoveryPoint based restore request. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupRestoreWithRehydrationRequest. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - :param recovery_point_id: Required. - :type recovery_point_id: str - """ - - _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - 'recovery_point_id': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AzureBackupRestoreWithRehydrationRequest': 'AzureBackupRestoreWithRehydrationRequest'} - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRecoveryPointBasedRestoreRequest, self).__init__(**kwargs) - self.object_type = 'AzureBackupRecoveryPointBasedRestoreRequest' # type: str - self.recovery_point_id = kwargs['recovery_point_id'] - - -class AzureBackupRecoveryPointResource(DppResource): - """Azure backup recoveryPoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: AzureBackupRecoveryPointResource properties. - :type properties: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPoint - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'AzureBackupRecoveryPoint'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRecoveryPointResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AzureBackupRecoveryPointResourceList(DppResourceList): - """Azure backup recoveryPoint resource list. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[AzureBackupRecoveryPointResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRecoveryPointResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class AzureBackupRecoveryTimeBasedRestoreRequest(AzureBackupRestoreRequest): - """AzureBackup RecoveryPointTime Based Restore Request. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - :param recovery_point_time: Required. The recovery time in ISO 8601 format example - - 2020-08-14T17:30:00.0000000Z. - :type recovery_point_time: str - """ - - _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - 'recovery_point_time': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'recovery_point_time': {'key': 'recoveryPointTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRecoveryTimeBasedRestoreRequest, self).__init__(**kwargs) - self.object_type = 'AzureBackupRecoveryTimeBasedRestoreRequest' # type: str - self.recovery_point_time = kwargs['recovery_point_time'] - - -class AzureBackupRehydrationRequest(msrest.serialization.Model): - """Azure Backup Rehydrate Request. - - All required parameters must be populated in order to send to Azure. - - :param recovery_point_id: Required. Id of the recovery point to be recovered. - :type recovery_point_id: str - :param rehydration_priority: Priority to be used for rehydration. Values High or Standard. - Possible values include: "Invalid", "High", "Standard". - :type rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority - :param rehydration_retention_duration: Required. Retention duration in ISO 8601 format i.e P10D - . - :type rehydration_retention_duration: str - """ - - _validation = { - 'recovery_point_id': {'required': True}, - 'rehydration_retention_duration': {'required': True}, - } - - _attribute_map = { - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - 'rehydration_priority': {'key': 'rehydrationPriority', 'type': 'str'}, - 'rehydration_retention_duration': {'key': 'rehydrationRetentionDuration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRehydrationRequest, self).__init__(**kwargs) - self.recovery_point_id = kwargs['recovery_point_id'] - self.rehydration_priority = kwargs.get('rehydration_priority', None) - self.rehydration_retention_duration = kwargs['rehydration_retention_duration'] - - -class AzureBackupRestoreWithRehydrationRequest(AzureBackupRecoveryPointBasedRestoreRequest): - """AzureBackup Restore with Rehydration Request. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - :param recovery_point_id: Required. - :type recovery_point_id: str - :param rehydration_priority: Required. Priority to be used for rehydration. Values High or - Standard. Possible values include: "Invalid", "High", "Standard". - :type rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority - :param rehydration_retention_duration: Required. Retention duration in ISO 8601 format i.e P10D - . - :type rehydration_retention_duration: str - """ - - _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - 'recovery_point_id': {'required': True}, - 'rehydration_priority': {'required': True}, - 'rehydration_retention_duration': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - 'rehydration_priority': {'key': 'rehydrationPriority', 'type': 'str'}, - 'rehydration_retention_duration': {'key': 'rehydrationRetentionDuration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRestoreWithRehydrationRequest, self).__init__(**kwargs) - self.object_type = 'AzureBackupRestoreWithRehydrationRequest' # type: str - self.rehydration_priority = kwargs['rehydration_priority'] - self.rehydration_retention_duration = kwargs['rehydration_retention_duration'] - - -class BasePolicyRule(msrest.serialization.Model): - """BasePolicy Rule. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupRule, AzureRetentionRule. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. - :type name: str - :param object_type: Required. Constant filled by server. - :type object_type: str - """ - - _validation = { - 'name': {'required': True}, - 'object_type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AzureBackupRule': 'AzureBackupRule', 'AzureRetentionRule': 'AzureRetentionRule'} - } - - def __init__( - self, - **kwargs - ): - super(BasePolicyRule, self).__init__(**kwargs) - self.name = kwargs['name'] - self.object_type = None # type: Optional[str] - - -class AzureBackupRule(BasePolicyRule): - """Azure backup rule. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. - :type name: str - :param object_type: Required. Constant filled by server. - :type object_type: str - :param backup_parameters: BackupParameters base. - :type backup_parameters: ~azure.mgmt.dataprotection.models.BackupParameters - :param data_store: Required. DataStoreInfo base. - :type data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase - :param trigger: Required. Trigger context. - :type trigger: ~azure.mgmt.dataprotection.models.TriggerContext - """ - - _validation = { - 'name': {'required': True}, - 'object_type': {'required': True}, - 'data_store': {'required': True}, - 'trigger': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'backup_parameters': {'key': 'backupParameters', 'type': 'BackupParameters'}, - 'data_store': {'key': 'dataStore', 'type': 'DataStoreInfoBase'}, - 'trigger': {'key': 'trigger', 'type': 'TriggerContext'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBackupRule, self).__init__(**kwargs) - self.object_type = 'AzureBackupRule' # type: str - self.backup_parameters = kwargs.get('backup_parameters', None) - self.data_store = kwargs['data_store'] - self.trigger = kwargs['trigger'] - - -class DataStoreParameters(msrest.serialization.Model): - """Parameters for DataStore. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureOperationalStoreParameters. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param data_store_type: Required. type of datastore; Operational/Vault/Archive. Possible values - include: "OperationalStore", "VaultStore", "ArchiveStore". - :type data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes - """ - - _validation = { - 'object_type': {'required': True}, - 'data_store_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'data_store_type': {'key': 'dataStoreType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'AzureOperationalStoreParameters': 'AzureOperationalStoreParameters'} - } - - def __init__( - self, - **kwargs - ): - super(DataStoreParameters, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - self.data_store_type = kwargs['data_store_type'] - - -class AzureOperationalStoreParameters(DataStoreParameters): - """Parameters for Operational-Tier DataStore. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param data_store_type: Required. type of datastore; Operational/Vault/Archive. Possible values - include: "OperationalStore", "VaultStore", "ArchiveStore". - :type data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes - :param resource_group_id: Gets or sets the Snapshot Resource Group Uri. - :type resource_group_id: str - """ - - _validation = { - 'object_type': {'required': True}, - 'data_store_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'data_store_type': {'key': 'dataStoreType', 'type': 'str'}, - 'resource_group_id': {'key': 'resourceGroupId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureOperationalStoreParameters, self).__init__(**kwargs) - self.object_type = 'AzureOperationalStoreParameters' # type: str - self.resource_group_id = kwargs.get('resource_group_id', None) - - -class AzureRetentionRule(BasePolicyRule): - """Azure retention rule. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. - :type name: str - :param object_type: Required. Constant filled by server. - :type object_type: str - :param is_default: - :type is_default: bool - :param lifecycles: Required. - :type lifecycles: list[~azure.mgmt.dataprotection.models.SourceLifeCycle] - """ - - _validation = { - 'name': {'required': True}, - 'object_type': {'required': True}, - 'lifecycles': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'lifecycles': {'key': 'lifecycles', 'type': '[SourceLifeCycle]'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureRetentionRule, self).__init__(**kwargs) - self.object_type = 'AzureRetentionRule' # type: str - self.is_default = kwargs.get('is_default', None) - self.lifecycles = kwargs['lifecycles'] - - -class BackupCriteria(msrest.serialization.Model): - """BackupCriteria base class. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ScheduleBasedBackupCriteria. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'ScheduleBasedBackupCriteria': 'ScheduleBasedBackupCriteria'} - } - - def __init__( - self, - **kwargs - ): - super(BackupCriteria, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class BackupInstance(msrest.serialization.Model): - """Backup Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param friendly_name: Gets or sets the Backup Instance friendly name. - :type friendly_name: str - :param data_source_info: Required. Gets or sets the data source information. - :type data_source_info: ~azure.mgmt.dataprotection.models.Datasource - :param data_source_set_info: Gets or sets the data source set information. - :type data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet - :param policy_info: Required. Gets or sets the policy information. - :type policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo - :ivar protection_status: Specifies the protection status of the resource. - :vartype protection_status: ~azure.mgmt.dataprotection.models.ProtectionStatusDetails - :ivar current_protection_state: Specifies the current protection state of the resource. - Possible values include: "Invalid", "NotProtected", "ConfiguringProtection", - "ProtectionConfigured", "BackupSchedulesSuspended", "RetentionSchedulesSuspended", - "ProtectionStopped", "ProtectionError", "ConfiguringProtectionFailed", "SoftDeleting", - "SoftDeleted", "UpdatingProtection". - :vartype current_protection_state: str or - ~azure.mgmt.dataprotection.models.CurrentProtectionState - :ivar protection_error_details: Specifies the protection error of the resource. - :vartype protection_error_details: ~azure.mgmt.dataprotection.models.UserFacingError - :ivar provisioning_state: Specifies the provisioning state of the resource i.e. - provisioning/updating/Succeeded/Failed. - :vartype provisioning_state: str - :param datasource_auth_credentials: Credentials to use to authenticate with data source - provider. - :type datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials - :param object_type: Required. - :type object_type: str - """ - - _validation = { - 'data_source_info': {'required': True}, - 'policy_info': {'required': True}, - 'protection_status': {'readonly': True}, - 'current_protection_state': {'readonly': True}, - 'protection_error_details': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'object_type': {'required': True}, - } - - _attribute_map = { - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'data_source_info': {'key': 'dataSourceInfo', 'type': 'Datasource'}, - 'data_source_set_info': {'key': 'dataSourceSetInfo', 'type': 'DatasourceSet'}, - 'policy_info': {'key': 'policyInfo', 'type': 'PolicyInfo'}, - 'protection_status': {'key': 'protectionStatus', 'type': 'ProtectionStatusDetails'}, - 'current_protection_state': {'key': 'currentProtectionState', 'type': 'str'}, - 'protection_error_details': {'key': 'protectionErrorDetails', 'type': 'UserFacingError'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'datasource_auth_credentials': {'key': 'datasourceAuthCredentials', 'type': 'AuthCredentials'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupInstance, self).__init__(**kwargs) - self.friendly_name = kwargs.get('friendly_name', None) - self.data_source_info = kwargs['data_source_info'] - self.data_source_set_info = kwargs.get('data_source_set_info', None) - self.policy_info = kwargs['policy_info'] - self.protection_status = None - self.current_protection_state = None - self.protection_error_details = None - self.provisioning_state = None - self.datasource_auth_credentials = kwargs.get('datasource_auth_credentials', None) - self.object_type = kwargs['object_type'] - - -class BackupInstanceResource(DppResource): - """BackupInstance Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: BackupInstanceResource properties. - :type properties: ~azure.mgmt.dataprotection.models.BackupInstance - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'BackupInstance'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupInstanceResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class BackupInstanceResourceList(DppResourceList): - """BackupInstance Resource list response. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.BackupInstanceResource] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BackupInstanceResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupInstanceResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class BaseBackupPolicy(msrest.serialization.Model): - """BackupPolicy base. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BackupPolicy. - - All required parameters must be populated in order to send to Azure. - - :param datasource_types: Required. Type of datasource for the backup management. - :type datasource_types: list[str] - :param object_type: Required. Constant filled by server. - :type object_type: str - """ - - _validation = { - 'datasource_types': {'required': True}, - 'object_type': {'required': True}, - } - - _attribute_map = { - 'datasource_types': {'key': 'datasourceTypes', 'type': '[str]'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'BackupPolicy': 'BackupPolicy'} - } - - def __init__( - self, - **kwargs - ): - super(BaseBackupPolicy, self).__init__(**kwargs) - self.datasource_types = kwargs['datasource_types'] - self.object_type = None # type: Optional[str] - - -class BackupPolicy(BaseBackupPolicy): - """Rule based backup policy. - - All required parameters must be populated in order to send to Azure. - - :param datasource_types: Required. Type of datasource for the backup management. - :type datasource_types: list[str] - :param object_type: Required. Constant filled by server. - :type object_type: str - :param policy_rules: Required. Policy rule dictionary that contains rules for each backuptype - i.e Full/Incremental/Logs etc. - :type policy_rules: list[~azure.mgmt.dataprotection.models.BasePolicyRule] - """ - - _validation = { - 'datasource_types': {'required': True}, - 'object_type': {'required': True}, - 'policy_rules': {'required': True}, - } - - _attribute_map = { - 'datasource_types': {'key': 'datasourceTypes', 'type': '[str]'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'policy_rules': {'key': 'policyRules', 'type': '[BasePolicyRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupPolicy, self).__init__(**kwargs) - self.object_type = 'BackupPolicy' # type: str - self.policy_rules = kwargs['policy_rules'] - - -class BackupSchedule(msrest.serialization.Model): - """Schedule for backup. - - All required parameters must be populated in order to send to Azure. - - :param repeating_time_intervals: Required. ISO 8601 repeating time interval format. - :type repeating_time_intervals: list[str] - :param time_zone: Time zone for a schedule. Example: Pacific Standard Time. - :type time_zone: str - """ - - _validation = { - 'repeating_time_intervals': {'required': True}, - } - - _attribute_map = { - 'repeating_time_intervals': {'key': 'repeatingTimeIntervals', 'type': '[str]'}, - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupSchedule, self).__init__(**kwargs) - self.repeating_time_intervals = kwargs['repeating_time_intervals'] - self.time_zone = kwargs.get('time_zone', None) - - -class BackupVault(msrest.serialization.Model): - """Backup Vault. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar provisioning_state: Provisioning state of the BackupVault resource. Possible values - include: "Failed", "Provisioning", "Succeeded", "Unknown", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.dataprotection.models.ProvisioningState - :ivar resource_move_state: Resource move state for backup vault. Possible values include: - "Unknown", "InProgress", "PrepareFailed", "CommitFailed", "Failed", "PrepareTimedout", - "CommitTimedout", "CriticalFailure", "PartialSuccess", "MoveSucceeded". - :vartype resource_move_state: str or ~azure.mgmt.dataprotection.models.ResourceMoveState - :ivar resource_move_details: Resource move details for backup vault. - :vartype resource_move_details: ~azure.mgmt.dataprotection.models.ResourceMoveDetails - :param storage_settings: Required. Storage Settings. - :type storage_settings: list[~azure.mgmt.dataprotection.models.StorageSetting] - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_move_state': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'storage_settings': {'required': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_move_state': {'key': 'resourceMoveState', 'type': 'str'}, - 'resource_move_details': {'key': 'resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'storage_settings': {'key': 'storageSettings', 'type': '[StorageSetting]'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupVault, self).__init__(**kwargs) - self.provisioning_state = None - self.resource_move_state = None - self.resource_move_details = None - self.storage_settings = kwargs['storage_settings'] - - -class DppTrackedResource(msrest.serialization.Model): - """DppTrackedResource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param e_tag: Optional ETag. - :type e_tag: str - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param location: Resource location. - :type location: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(DppTrackedResource, self).__init__(**kwargs) - self.e_tag = kwargs.get('e_tag', None) - self.id = None - self.identity = kwargs.get('identity', None) - self.location = kwargs.get('location', None) - self.name = None - self.tags = kwargs.get('tags', None) - self.type = None - self.system_data = None - - -class BackupVaultResource(DppTrackedResource): - """Backup Vault Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param e_tag: Optional ETag. - :type e_tag: str - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param location: Resource location. - :type location: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: Required. BackupVaultResource properties. - :type properties: ~azure.mgmt.dataprotection.models.BackupVault - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'properties': {'required': True}, - } - - _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'BackupVault'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupVaultResource, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class BackupVaultResourceList(DppResourceList): - """List of BackupVault resources. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.BackupVaultResource] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BackupVaultResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupVaultResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class BaseBackupPolicyResource(DppResource): - """BaseBackupPolicy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: BaseBackupPolicyResource properties. - :type properties: ~azure.mgmt.dataprotection.models.BaseBackupPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'BaseBackupPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(BaseBackupPolicyResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class BaseBackupPolicyResourceList(DppResourceList): - """List of BaseBackupPolicy resources. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.BaseBackupPolicyResource] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BaseBackupPolicyResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(BaseBackupPolicyResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CheckNameAvailabilityRequest(msrest.serialization.Model): - """CheckNameAvailability Request. - - :param name: Resource name for which availability needs to be checked. - :type name: str - :param type: Describes the Resource type: Microsoft.DataProtection/BackupVaults. - :type type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """CheckNameAvailability Result. - - :param message: Gets or sets the message. - :type message: str - :param name_available: Gets or sets a value indicating whether [name available]. - :type name_available: bool - :param reason: Gets or sets the reason. - :type reason: str - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - - -class ClientDiscoveryDisplay(msrest.serialization.Model): - """Localized display information of an operation. - - :param description: Description of the operation having details of what operation is about. - :type description: str - :param operation: Operations Name itself. - :type operation: str - :param provider: Name of the provider for display purposes. - :type provider: str - :param resource: ResourceType for which this Operation can be performed. - :type resource: str - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientDiscoveryDisplay, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.operation = kwargs.get('operation', None) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - - -class ClientDiscoveryForLogSpecification(msrest.serialization.Model): - """Class to represent shoebox log specification in json client discovery. - - :param blob_duration: blob duration of shoebox log specification. - :type blob_duration: str - :param display_name: Localized display name. - :type display_name: str - :param name: Name for shoebox log specification. - :type name: str - """ - - _attribute_map = { - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientDiscoveryForLogSpecification, self).__init__(**kwargs) - self.blob_duration = kwargs.get('blob_duration', None) - self.display_name = kwargs.get('display_name', None) - self.name = kwargs.get('name', None) - - -class ClientDiscoveryForProperties(msrest.serialization.Model): - """Class to represent shoebox properties in json client discovery. - - :param service_specification: Operation properties. - :type service_specification: - ~azure.mgmt.dataprotection.models.ClientDiscoveryForServiceSpecification - """ - - _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ClientDiscoveryForServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientDiscoveryForProperties, self).__init__(**kwargs) - self.service_specification = kwargs.get('service_specification', None) - - -class ClientDiscoveryForServiceSpecification(msrest.serialization.Model): - """Class to represent shoebox service specification in json client discovery. - - :param log_specifications: List of log specifications of this operation. - :type log_specifications: - list[~azure.mgmt.dataprotection.models.ClientDiscoveryForLogSpecification] - """ - - _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[ClientDiscoveryForLogSpecification]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientDiscoveryForServiceSpecification, self).__init__(**kwargs) - self.log_specifications = kwargs.get('log_specifications', None) - - -class ClientDiscoveryResponse(msrest.serialization.Model): - """Operations List response which contains list of available APIs. - - :param next_link: Link to the next chunk of Response. - :type next_link: str - :param value: List of available operations. - :type value: list[~azure.mgmt.dataprotection.models.ClientDiscoveryValueForSingleApi] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ClientDiscoveryValueForSingleApi]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientDiscoveryResponse, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class ClientDiscoveryValueForSingleApi(msrest.serialization.Model): - """Available operation details. - - :param display: Contains the localized display information for this particular operation. - :type display: ~azure.mgmt.dataprotection.models.ClientDiscoveryDisplay - :param name: Name of the Operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param origin: The intended executor of the operation;governs the display of the operation in - the RBAC UX and the audit logs UX. - :type origin: str - :param properties: Properties for the given operation. - :type properties: ~azure.mgmt.dataprotection.models.ClientDiscoveryForProperties - """ - - _attribute_map = { - 'display': {'key': 'display', 'type': 'ClientDiscoveryDisplay'}, - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ClientDiscoveryForProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientDiscoveryValueForSingleApi, self).__init__(**kwargs) - self.display = kwargs.get('display', None) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class CopyOption(msrest.serialization.Model): - """Options to copy. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CopyOnExpiryOption, CustomCopyOption, ImmediateCopyOption. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'CopyOnExpiryOption': 'CopyOnExpiryOption', 'CustomCopyOption': 'CustomCopyOption', 'ImmediateCopyOption': 'ImmediateCopyOption'} - } - - def __init__( - self, - **kwargs - ): - super(CopyOption, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class CopyOnExpiryOption(CopyOption): - """Copy on Expiry Option. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CopyOnExpiryOption, self).__init__(**kwargs) - self.object_type = 'CopyOnExpiryOption' # type: str - - -class CustomCopyOption(CopyOption): - """Duration based custom options to copy. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param duration: Data copied after given timespan. - :type duration: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomCopyOption, self).__init__(**kwargs) - self.object_type = 'CustomCopyOption' # type: str - self.duration = kwargs.get('duration', None) - - -class Datasource(msrest.serialization.Model): - """Datasource to be backed up. - - All required parameters must be populated in order to send to Azure. - - :param datasource_type: DatasourceType of the resource. - :type datasource_type: str - :param object_type: Type of Datasource object, used to initialize the right inherited type. - :type object_type: str - :param resource_id: Required. Full ARM ID of the resource. For azure resources, this is ARM ID. - For non azure resources, this will be the ID created by backup service via Fabric/Vault. - :type resource_id: str - :param resource_location: Location of datasource. - :type resource_location: str - :param resource_name: Unique identifier of the resource in the context of parent. - :type resource_name: str - :param resource_type: Resource Type of Datasource. - :type resource_type: str - :param resource_uri: Uri of the resource. - :type resource_uri: str - """ - - _validation = { - 'resource_id': {'required': True}, - } - - _attribute_map = { - 'datasource_type': {'key': 'datasourceType', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'resource_id': {'key': 'resourceID', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Datasource, self).__init__(**kwargs) - self.datasource_type = kwargs.get('datasource_type', None) - self.object_type = kwargs.get('object_type', None) - self.resource_id = kwargs['resource_id'] - self.resource_location = kwargs.get('resource_location', None) - self.resource_name = kwargs.get('resource_name', None) - self.resource_type = kwargs.get('resource_type', None) - self.resource_uri = kwargs.get('resource_uri', None) - - -class DatasourceSet(msrest.serialization.Model): - """DatasourceSet details of datasource to be backed up. - - All required parameters must be populated in order to send to Azure. - - :param datasource_type: DatasourceType of the resource. - :type datasource_type: str - :param object_type: Type of Datasource object, used to initialize the right inherited type. - :type object_type: str - :param resource_id: Required. Full ARM ID of the resource. For azure resources, this is ARM ID. - For non azure resources, this will be the ID created by backup service via Fabric/Vault. - :type resource_id: str - :param resource_location: Location of datasource. - :type resource_location: str - :param resource_name: Unique identifier of the resource in the context of parent. - :type resource_name: str - :param resource_type: Resource Type of Datasource. - :type resource_type: str - :param resource_uri: Uri of the resource. - :type resource_uri: str - """ - - _validation = { - 'resource_id': {'required': True}, - } - - _attribute_map = { - 'datasource_type': {'key': 'datasourceType', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'resource_id': {'key': 'resourceID', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatasourceSet, self).__init__(**kwargs) - self.datasource_type = kwargs.get('datasource_type', None) - self.object_type = kwargs.get('object_type', None) - self.resource_id = kwargs['resource_id'] - self.resource_location = kwargs.get('resource_location', None) - self.resource_name = kwargs.get('resource_name', None) - self.resource_type = kwargs.get('resource_type', None) - self.resource_uri = kwargs.get('resource_uri', None) - - -class DataStoreInfoBase(msrest.serialization.Model): - """DataStoreInfo base. - - All required parameters must be populated in order to send to Azure. - - :param data_store_type: Required. type of datastore; Operational/Vault/Archive. Possible values - include: "OperationalStore", "VaultStore", "ArchiveStore". - :type data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type. - :type object_type: str - """ - - _validation = { - 'data_store_type': {'required': True}, - 'object_type': {'required': True}, - } - - _attribute_map = { - 'data_store_type': {'key': 'dataStoreType', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataStoreInfoBase, self).__init__(**kwargs) - self.data_store_type = kwargs['data_store_type'] - self.object_type = kwargs['object_type'] - - -class Day(msrest.serialization.Model): - """Day of the week. - - :param date: Date of the month. - :type date: int - :param is_last: Whether Date is last date of month. - :type is_last: bool - """ - - _attribute_map = { - 'date': {'key': 'date', 'type': 'int'}, - 'is_last': {'key': 'isLast', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Day, self).__init__(**kwargs) - self.date = kwargs.get('date', None) - self.is_last = kwargs.get('is_last', None) - - -class DppBaseResource(msrest.serialization.Model): - """Base resource under Microsoft.DataProtection provider namespace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DppBaseResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DppBaseResourceList(msrest.serialization.Model): - """Base for all lists of V2 resources. - - :param value: List of Dpp resources. - :type value: list[~azure.mgmt.dataprotection.models.DppBaseResource] - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DppBaseResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DppBaseResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DppIdentityDetails(msrest.serialization.Model): - """Identity details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The object ID of the service principal object for the managed identity that - is used to grant role-based access to an Azure resource. - :vartype principal_id: str - :ivar tenant_id: A Globally Unique Identifier (GUID) that represents the Azure AD tenant where - the resource is now a member. - :vartype tenant_id: str - :param type: The identityType which can be either SystemAssigned or None. - :type type: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DppIdentityDetails, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class DppTrackedResourceList(msrest.serialization.Model): - """DppTrackedResourceList. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DppTrackedResourceList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - - -class Error(msrest.serialization.Model): - """The resource management error response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.dataprotection.models.ErrorAdditionalInfo] - :ivar code: The error code. - :vartype code: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.dataprotection.models.Error] - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - """ - - _validation = { - 'additional_info': {'readonly': True}, - 'code': {'readonly': True}, - 'details': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - } - - _attribute_map = { - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Error, self).__init__(**kwargs) - self.additional_info = None - self.code = None - self.details = None - self.message = None - self.target = None - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar info: The additional info. - :vartype info: any - :ivar type: The additional info type. - :vartype type: str - """ - - _validation = { - 'info': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'info': {'key': 'info', 'type': 'object'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.info = None - self.type = None - - -class ExportJobsResult(msrest.serialization.Model): - """The result for export jobs containing blob details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar blob_url: URL of the blob into which the serialized string of list of jobs is exported. - :vartype blob_url: str - :ivar blob_sas_key: SAS key to access the blob. - :vartype blob_sas_key: str - :ivar excel_file_blob_url: URL of the blob into which the ExcelFile is uploaded. - :vartype excel_file_blob_url: str - :ivar excel_file_blob_sas_key: SAS key to access the ExcelFile blob. - :vartype excel_file_blob_sas_key: str - """ - - _validation = { - 'blob_url': {'readonly': True}, - 'blob_sas_key': {'readonly': True}, - 'excel_file_blob_url': {'readonly': True}, - 'excel_file_blob_sas_key': {'readonly': True}, - } - - _attribute_map = { - 'blob_url': {'key': 'blobUrl', 'type': 'str'}, - 'blob_sas_key': {'key': 'blobSasKey', 'type': 'str'}, - 'excel_file_blob_url': {'key': 'excelFileBlobUrl', 'type': 'str'}, - 'excel_file_blob_sas_key': {'key': 'excelFileBlobSasKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExportJobsResult, self).__init__(**kwargs) - self.blob_url = None - self.blob_sas_key = None - self.excel_file_blob_url = None - self.excel_file_blob_sas_key = None - - -class FeatureValidationRequestBase(msrest.serialization.Model): - """Base class for Backup Feature support. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FeatureValidationRequest. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'FeatureValidationRequest': 'FeatureValidationRequest'} - } - - def __init__( - self, - **kwargs - ): - super(FeatureValidationRequestBase, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class FeatureValidationRequest(FeatureValidationRequestBase): - """Base class for feature object. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param feature_type: backup support feature type. Possible values include: "Invalid", - "DataSourceType". - :type feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType - :param feature_name: backup support feature name. - :type feature_name: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'feature_type': {'key': 'featureType', 'type': 'str'}, - 'feature_name': {'key': 'featureName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FeatureValidationRequest, self).__init__(**kwargs) - self.object_type = 'FeatureValidationRequest' # type: str - self.feature_type = kwargs.get('feature_type', None) - self.feature_name = kwargs.get('feature_name', None) - - -class FeatureValidationResponseBase(msrest.serialization.Model): - """Base class for Backup Feature support. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FeatureValidationResponse. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'FeatureValidationResponse': 'FeatureValidationResponse'} - } - - def __init__( - self, - **kwargs - ): - super(FeatureValidationResponseBase, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class FeatureValidationResponse(FeatureValidationResponseBase): - """Feature Validation Response. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param feature_type: backup support feature type. Possible values include: "Invalid", - "DataSourceType". - :type feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType - :param features: Response features. - :type features: list[~azure.mgmt.dataprotection.models.SupportedFeature] - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'feature_type': {'key': 'featureType', 'type': 'str'}, - 'features': {'key': 'features', 'type': '[SupportedFeature]'}, - } - - def __init__( - self, - **kwargs - ): - super(FeatureValidationResponse, self).__init__(**kwargs) - self.object_type = 'FeatureValidationResponse' # type: str - self.feature_type = kwargs.get('feature_type', None) - self.features = kwargs.get('features', None) - - -class ImmediateCopyOption(CopyOption): - """Immediate copy Option. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImmediateCopyOption, self).__init__(**kwargs) - self.object_type = 'ImmediateCopyOption' # type: str - - -class InnerError(msrest.serialization.Model): - """Inner Error. - - :param additional_info: Any Key value pairs that can be provided to the client for additional - verbose information. - :type additional_info: dict[str, str] - :param code: Unique code for this error. - :type code: str - :param embedded_inner_error: Child Inner Error, to allow Nesting. - :type embedded_inner_error: ~azure.mgmt.dataprotection.models.InnerError - """ - - _attribute_map = { - 'additional_info': {'key': 'additionalInfo', 'type': '{str}'}, - 'code': {'key': 'code', 'type': 'str'}, - 'embedded_inner_error': {'key': 'embeddedInnerError', 'type': 'InnerError'}, - } - - def __init__( - self, - **kwargs - ): - super(InnerError, self).__init__(**kwargs) - self.additional_info = kwargs.get('additional_info', None) - self.code = kwargs.get('code', None) - self.embedded_inner_error = kwargs.get('embedded_inner_error', None) - - -class ItemLevelRestoreCriteria(msrest.serialization.Model): - """Class to contain criteria for item level restore. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RangeBasedItemLevelRestoreCriteria. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'RangeBasedItemLevelRestoreCriteria': 'RangeBasedItemLevelRestoreCriteria'} - } - - def __init__( - self, - **kwargs - ): - super(ItemLevelRestoreCriteria, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class RestoreTargetInfoBase(msrest.serialization.Model): - """Base class common to RestoreTargetInfo and RestoreFilesTargetInfo. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ItemLevelRestoreTargetInfo, RestoreFilesTargetInfo, RestoreTargetInfo. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - """ - - _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'ItemLevelRestoreTargetInfo': 'ItemLevelRestoreTargetInfo', 'RestoreFilesTargetInfo': 'RestoreFilesTargetInfo', 'RestoreTargetInfo': 'RestoreTargetInfo'} - } - - def __init__( - self, - **kwargs - ): - super(RestoreTargetInfoBase, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - self.recovery_option = kwargs['recovery_option'] - self.restore_location = kwargs.get('restore_location', None) - - -class ItemLevelRestoreTargetInfo(RestoreTargetInfoBase): - """Restore target info for Item level restore operation. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - :param restore_criteria: Required. Restore Criteria. - :type restore_criteria: list[~azure.mgmt.dataprotection.models.ItemLevelRestoreCriteria] - :param datasource_info: Required. Information of target DS. - :type datasource_info: ~azure.mgmt.dataprotection.models.Datasource - :param datasource_set_info: Information of target DS Set. - :type datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet - :param datasource_auth_credentials: Credentials to use to authenticate with data source - provider. - :type datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials - """ - - _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - 'restore_criteria': {'required': True}, - 'datasource_info': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - 'restore_criteria': {'key': 'restoreCriteria', 'type': '[ItemLevelRestoreCriteria]'}, - 'datasource_info': {'key': 'datasourceInfo', 'type': 'Datasource'}, - 'datasource_set_info': {'key': 'datasourceSetInfo', 'type': 'DatasourceSet'}, - 'datasource_auth_credentials': {'key': 'datasourceAuthCredentials', 'type': 'AuthCredentials'}, - } - - def __init__( - self, - **kwargs - ): - super(ItemLevelRestoreTargetInfo, self).__init__(**kwargs) - self.object_type = 'ItemLevelRestoreTargetInfo' # type: str - self.restore_criteria = kwargs['restore_criteria'] - self.datasource_info = kwargs['datasource_info'] - self.datasource_set_info = kwargs.get('datasource_set_info', None) - self.datasource_auth_credentials = kwargs.get('datasource_auth_credentials', None) - - -class JobExtendedInfo(msrest.serialization.Model): - """Extended Information about the job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param additional_details: Job's Additional Details. - :type additional_details: dict[str, str] - :ivar backup_instance_state: State of the Backup Instance. - :vartype backup_instance_state: str - :ivar data_transferred_in_bytes: Number of bytes transferred. - :vartype data_transferred_in_bytes: float - :ivar recovery_destination: Destination where restore is done. - :vartype recovery_destination: str - :ivar source_recover_point: Details of the Source Recovery Point. - :vartype source_recover_point: ~azure.mgmt.dataprotection.models.RestoreJobRecoveryPointDetails - :ivar sub_tasks: List of Sub Tasks of the job. - :vartype sub_tasks: list[~azure.mgmt.dataprotection.models.JobSubTask] - :ivar target_recover_point: Details of the Target Recovery Point. - :vartype target_recover_point: ~azure.mgmt.dataprotection.models.RestoreJobRecoveryPointDetails - """ - - _validation = { - 'backup_instance_state': {'readonly': True}, - 'data_transferred_in_bytes': {'readonly': True}, - 'recovery_destination': {'readonly': True}, - 'source_recover_point': {'readonly': True}, - 'sub_tasks': {'readonly': True}, - 'target_recover_point': {'readonly': True}, - } - - _attribute_map = { - 'additional_details': {'key': 'additionalDetails', 'type': '{str}'}, - 'backup_instance_state': {'key': 'backupInstanceState', 'type': 'str'}, - 'data_transferred_in_bytes': {'key': 'dataTransferredInBytes', 'type': 'float'}, - 'recovery_destination': {'key': 'recoveryDestination', 'type': 'str'}, - 'source_recover_point': {'key': 'sourceRecoverPoint', 'type': 'RestoreJobRecoveryPointDetails'}, - 'sub_tasks': {'key': 'subTasks', 'type': '[JobSubTask]'}, - 'target_recover_point': {'key': 'targetRecoverPoint', 'type': 'RestoreJobRecoveryPointDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(JobExtendedInfo, self).__init__(**kwargs) - self.additional_details = kwargs.get('additional_details', None) - self.backup_instance_state = None - self.data_transferred_in_bytes = None - self.recovery_destination = None - self.source_recover_point = None - self.sub_tasks = None - self.target_recover_point = None - - -class JobSubTask(msrest.serialization.Model): - """Details of Job's Sub Task. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param additional_details: Additional details of Sub Tasks. - :type additional_details: dict[str, str] - :param task_id: Required. Task Id of the Sub Task. - :type task_id: int - :param task_name: Required. Name of the Sub Task. - :type task_name: str - :ivar task_progress: Progress of the Sub Task. - :vartype task_progress: str - :param task_status: Required. Status of the Sub Task. - :type task_status: str - """ - - _validation = { - 'task_id': {'required': True}, - 'task_name': {'required': True}, - 'task_progress': {'readonly': True}, - 'task_status': {'required': True}, - } - - _attribute_map = { - 'additional_details': {'key': 'additionalDetails', 'type': '{str}'}, - 'task_id': {'key': 'taskId', 'type': 'int'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, - 'task_progress': {'key': 'taskProgress', 'type': 'str'}, - 'task_status': {'key': 'taskStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobSubTask, self).__init__(**kwargs) - self.additional_details = kwargs.get('additional_details', None) - self.task_id = kwargs['task_id'] - self.task_name = kwargs['task_name'] - self.task_progress = None - self.task_status = kwargs['task_status'] - - -class OperationExtendedInfo(msrest.serialization.Model): - """Operation Extended Info. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: OperationJobExtendedInfo. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. This property will be used as the discriminator for deciding the - specific types in the polymorphic chain of types.Constant filled by server. - :type object_type: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - _subtype_map = { - 'object_type': {'OperationJobExtendedInfo': 'OperationJobExtendedInfo'} - } - - def __init__( - self, - **kwargs - ): - super(OperationExtendedInfo, self).__init__(**kwargs) - self.object_type = None # type: Optional[str] - - -class OperationJobExtendedInfo(OperationExtendedInfo): - """Operation Job Extended Info. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. This property will be used as the discriminator for deciding the - specific types in the polymorphic chain of types.Constant filled by server. - :type object_type: str - :param job_id: Arm Id of the job created for this operation. - :type job_id: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'job_id': {'key': 'jobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationJobExtendedInfo, self).__init__(**kwargs) - self.object_type = 'OperationJobExtendedInfo' # type: str - self.job_id = kwargs.get('job_id', None) - - -class OperationResource(msrest.serialization.Model): - """Operation Resource. - - :param end_time: End time of the operation. - :type end_time: ~datetime.datetime - :param error: Required if status == failed or status == canceled. This is the OData v4 error - format, used by the RPC and will go into the v2.2 Azure REST API guidelines. - The full set of optional properties (e.g. inner errors / details) can be found in the "Error - Response" section. - :type error: ~azure.mgmt.dataprotection.models.Error - :param id: It should match what is used to GET the operation result. - :type id: str - :param name: It must match the last segment of the "id" field, and will typically be a GUID / - system generated value. - :type name: str - :param properties: End time of the operation. - :type properties: ~azure.mgmt.dataprotection.models.OperationExtendedInfo - :param start_time: Start time of the operation. - :type start_time: ~datetime.datetime - :param status: - :type status: str - """ - - _attribute_map = { - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationExtendedInfo'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResource, self).__init__(**kwargs) - self.end_time = kwargs.get('end_time', None) - self.error = kwargs.get('error', None) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.properties = kwargs.get('properties', None) - self.start_time = kwargs.get('start_time', None) - self.status = kwargs.get('status', None) - - -class PatchResourceRequestInput(msrest.serialization.Model): - """Patch Request content for Microsoft.DataProtection resources. - - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(PatchResourceRequestInput, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.tags = kwargs.get('tags', None) - - -class PolicyInfo(msrest.serialization.Model): - """Policy Info in backupInstance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param policy_id: Required. - :type policy_id: str - :ivar policy_version: - :vartype policy_version: str - :param policy_parameters: Policy parameters for the backup instance. - :type policy_parameters: ~azure.mgmt.dataprotection.models.PolicyParameters - """ - - _validation = { - 'policy_id': {'required': True}, - 'policy_version': {'readonly': True}, - } - - _attribute_map = { - 'policy_id': {'key': 'policyId', 'type': 'str'}, - 'policy_version': {'key': 'policyVersion', 'type': 'str'}, - 'policy_parameters': {'key': 'policyParameters', 'type': 'PolicyParameters'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyInfo, self).__init__(**kwargs) - self.policy_id = kwargs['policy_id'] - self.policy_version = None - self.policy_parameters = kwargs.get('policy_parameters', None) - - -class PolicyParameters(msrest.serialization.Model): - """Parameters in Policy. - - :param data_store_parameters_list: Gets or sets the DataStore Parameters. - :type data_store_parameters_list: list[~azure.mgmt.dataprotection.models.DataStoreParameters] - """ - - _attribute_map = { - 'data_store_parameters_list': {'key': 'dataStoreParametersList', 'type': '[DataStoreParameters]'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyParameters, self).__init__(**kwargs) - self.data_store_parameters_list = kwargs.get('data_store_parameters_list', None) - - -class ProtectionStatusDetails(msrest.serialization.Model): - """Protection status details. - - :param error_details: Specifies the protection status error of the resource. - :type error_details: ~azure.mgmt.dataprotection.models.UserFacingError - :param status: Specifies the protection status of the resource. Possible values include: - "ConfiguringProtection", "ConfiguringProtectionFailed", "ProtectionConfigured", - "ProtectionStopped", "SoftDeleted", "SoftDeleting". - :type status: str or ~azure.mgmt.dataprotection.models.Status - """ - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': 'UserFacingError'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProtectionStatusDetails, self).__init__(**kwargs) - self.error_details = kwargs.get('error_details', None) - self.status = kwargs.get('status', None) - - -class RangeBasedItemLevelRestoreCriteria(ItemLevelRestoreCriteria): - """Item Level target info for restore operation. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param min_matching_value: minimum value for range prefix match. - :type min_matching_value: str - :param max_matching_value: maximum value for range prefix match. - :type max_matching_value: str - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'min_matching_value': {'key': 'minMatchingValue', 'type': 'str'}, - 'max_matching_value': {'key': 'maxMatchingValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RangeBasedItemLevelRestoreCriteria, self).__init__(**kwargs) - self.object_type = 'RangeBasedItemLevelRestoreCriteria' # type: str - self.min_matching_value = kwargs.get('min_matching_value', None) - self.max_matching_value = kwargs.get('max_matching_value', None) - - -class RecoveryPointDataStoreDetails(msrest.serialization.Model): - """RecoveryPoint datastore details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param creation_time: - :type creation_time: ~datetime.datetime - :param expiry_time: - :type expiry_time: ~datetime.datetime - :param id: - :type id: str - :param meta_data: - :type meta_data: str - :param state: - :type state: str - :param type: - :type type: str - :param visible: - :type visible: bool - :ivar rehydration_expiry_time: - :vartype rehydration_expiry_time: ~datetime.datetime - :ivar rehydration_status: Possible values include: "CREATE_IN_PROGRESS", "COMPLETED", - "DELETE_IN_PROGRESS", "DELETED", "FAILED". - :vartype rehydration_status: str or ~azure.mgmt.dataprotection.models.RehydrationStatus - """ - - _validation = { - 'rehydration_expiry_time': {'readonly': True}, - 'rehydration_status': {'readonly': True}, - } - - _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'id': {'key': 'id', 'type': 'str'}, - 'meta_data': {'key': 'metaData', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'visible': {'key': 'visible', 'type': 'bool'}, - 'rehydration_expiry_time': {'key': 'rehydrationExpiryTime', 'type': 'iso-8601'}, - 'rehydration_status': {'key': 'rehydrationStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecoveryPointDataStoreDetails, self).__init__(**kwargs) - self.creation_time = kwargs.get('creation_time', None) - self.expiry_time = kwargs.get('expiry_time', None) - self.id = kwargs.get('id', None) - self.meta_data = kwargs.get('meta_data', None) - self.state = kwargs.get('state', None) - self.type = kwargs.get('type', None) - self.visible = kwargs.get('visible', None) - self.rehydration_expiry_time = None - self.rehydration_status = None - - -class RecoveryPointsFilters(msrest.serialization.Model): - """RecoveryPointsFilters. - - :param restore_point_data_store_id: - :type restore_point_data_store_id: str - :param is_visible: - :type is_visible: bool - :param start_date: - :type start_date: str - :param end_date: - :type end_date: str - :param extended_info: - :type extended_info: bool - :param restore_point_state: - :type restore_point_state: str - """ - - _attribute_map = { - 'restore_point_data_store_id': {'key': 'restorePointDataStoreId', 'type': 'str'}, - 'is_visible': {'key': 'isVisible', 'type': 'bool'}, - 'start_date': {'key': 'startDate', 'type': 'str'}, - 'end_date': {'key': 'endDate', 'type': 'str'}, - 'extended_info': {'key': 'extendedInfo', 'type': 'bool'}, - 'restore_point_state': {'key': 'restorePointState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecoveryPointsFilters, self).__init__(**kwargs) - self.restore_point_data_store_id = kwargs.get('restore_point_data_store_id', None) - self.is_visible = kwargs.get('is_visible', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.extended_info = kwargs.get('extended_info', None) - self.restore_point_state = kwargs.get('restore_point_state', None) - - -class ResourceGuard(msrest.serialization.Model): - """ResourceGuard. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning state of the BackupVault resource. Possible values - include: "Failed", "Provisioning", "Succeeded", "Unknown", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.dataprotection.models.ProvisioningState - :ivar allow_auto_approvals: This flag indicates whether auto approval is allowed or not. - :vartype allow_auto_approvals: bool - :ivar resource_guard_operations: {readonly} List of operation details those are protected by - the ResourceGuard resource. - :vartype resource_guard_operations: - list[~azure.mgmt.dataprotection.models.ResourceGuardOperation] - :ivar vault_critical_operation_exclusion_list: List of critical operations which are not - protected by this resourceGuard. - :vartype vault_critical_operation_exclusion_list: list[str] - :ivar description: Description about the pre-req steps to perform all the critical operations. - :vartype description: str - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'allow_auto_approvals': {'readonly': True}, - 'resource_guard_operations': {'readonly': True}, - 'vault_critical_operation_exclusion_list': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'allow_auto_approvals': {'key': 'allowAutoApprovals', 'type': 'bool'}, - 'resource_guard_operations': {'key': 'resourceGuardOperations', 'type': '[ResourceGuardOperation]'}, - 'vault_critical_operation_exclusion_list': {'key': 'vaultCriticalOperationExclusionList', 'type': '[str]'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceGuard, self).__init__(**kwargs) - self.provisioning_state = None - self.allow_auto_approvals = None - self.resource_guard_operations = None - self.vault_critical_operation_exclusion_list = None - self.description = None - - -class ResourceGuardOperation(msrest.serialization.Model): - """This class contains all the details about a critical operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vault_critical_operation: Name of the critical operation. - :vartype vault_critical_operation: str - :ivar request_resource_type: Type of resource request. - :vartype request_resource_type: str - """ - - _validation = { - 'vault_critical_operation': {'readonly': True}, - 'request_resource_type': {'readonly': True}, - } - - _attribute_map = { - 'vault_critical_operation': {'key': 'vaultCriticalOperation', 'type': 'str'}, - 'request_resource_type': {'key': 'requestResourceType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceGuardOperation, self).__init__(**kwargs) - self.vault_critical_operation = None - self.request_resource_type = None - - -class ResourceGuardResource(DppTrackedResource): - """ResourceGuardResource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param e_tag: Optional ETag. - :type e_tag: str - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param location: Resource location. - :type location: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar type: Resource type represents the complete path of the form - Namespace/ResourceType/ResourceType/... - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: ResourceGuardResource properties. - :type properties: ~azure.mgmt.dataprotection.models.ResourceGuard - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'ResourceGuard'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceGuardResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ResourceGuardResourceList(DppTrackedResourceList): - """List of ResourceGuard resources. - - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.ResourceGuardResource] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ResourceGuardResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceGuardResourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ResourceMoveDetails(msrest.serialization.Model): - """ResourceMoveDetails will be returned in response to GetResource call from ARM. - - :param operation_id: CorrelationId of latest ResourceMove operation attempted. - :type operation_id: str - :param start_time_utc: Start time in UTC of latest ResourceMove operation attempted. ISO 8601 - format. - :type start_time_utc: str - :param completion_time_utc: Completion time in UTC of latest ResourceMove operation attempted. - ISO 8601 format. - :type completion_time_utc: str - :param source_resource_path: ARM resource path of source resource. - :type source_resource_path: str - :param target_resource_path: ARM resource path of target resource used in latest ResourceMove - operation. - :type target_resource_path: str - """ - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'str'}, - 'completion_time_utc': {'key': 'completionTimeUtc', 'type': 'str'}, - 'source_resource_path': {'key': 'sourceResourcePath', 'type': 'str'}, - 'target_resource_path': {'key': 'targetResourcePath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceMoveDetails, self).__init__(**kwargs) - self.operation_id = kwargs.get('operation_id', None) - self.start_time_utc = kwargs.get('start_time_utc', None) - self.completion_time_utc = kwargs.get('completion_time_utc', None) - self.source_resource_path = kwargs.get('source_resource_path', None) - self.target_resource_path = kwargs.get('target_resource_path', None) - - -class RestorableTimeRange(msrest.serialization.Model): - """RestorableTimeRange. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. Start time for the available restore range. - :type start_time: str - :param end_time: Required. End time for the available restore range. - :type end_time: str - :param object_type: - :type object_type: str - """ - - _validation = { - 'start_time': {'required': True}, - 'end_time': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestorableTimeRange, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.end_time = kwargs['end_time'] - self.object_type = kwargs.get('object_type', None) - - -class RestoreFilesTargetInfo(RestoreTargetInfoBase): - """Class encapsulating restore as files target parameters. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - :param target_details: Required. Destination of RestoreAsFiles operation, when destination is - not a datasource. - :type target_details: ~azure.mgmt.dataprotection.models.TargetDetails - """ - - _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - 'target_details': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - 'target_details': {'key': 'targetDetails', 'type': 'TargetDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(RestoreFilesTargetInfo, self).__init__(**kwargs) - self.object_type = 'RestoreFilesTargetInfo' # type: str - self.target_details = kwargs['target_details'] - - -class RestoreJobRecoveryPointDetails(msrest.serialization.Model): - """RestoreJobRecoveryPointDetails. - - :param recovery_point_id: - :type recovery_point_id: str - :param recovery_point_time: - :type recovery_point_time: ~datetime.datetime - """ - - _attribute_map = { - 'recovery_point_id': {'key': 'recoveryPointID', 'type': 'str'}, - 'recovery_point_time': {'key': 'recoveryPointTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(RestoreJobRecoveryPointDetails, self).__init__(**kwargs) - self.recovery_point_id = kwargs.get('recovery_point_id', None) - self.recovery_point_time = kwargs.get('recovery_point_time', None) - - -class RestoreTargetInfo(RestoreTargetInfoBase): - """Class encapsulating restore target parameters. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - :param datasource_info: Required. Information of target DS. - :type datasource_info: ~azure.mgmt.dataprotection.models.Datasource - :param datasource_set_info: Information of target DS Set. - :type datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet - :param datasource_auth_credentials: Credentials to use to authenticate with data source - provider. - :type datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials - """ - - _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - 'datasource_info': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - 'datasource_info': {'key': 'datasourceInfo', 'type': 'Datasource'}, - 'datasource_set_info': {'key': 'datasourceSetInfo', 'type': 'DatasourceSet'}, - 'datasource_auth_credentials': {'key': 'datasourceAuthCredentials', 'type': 'AuthCredentials'}, - } - - def __init__( - self, - **kwargs - ): - super(RestoreTargetInfo, self).__init__(**kwargs) - self.object_type = 'RestoreTargetInfo' # type: str - self.datasource_info = kwargs['datasource_info'] - self.datasource_set_info = kwargs.get('datasource_set_info', None) - self.datasource_auth_credentials = kwargs.get('datasource_auth_credentials', None) - - -class RetentionTag(msrest.serialization.Model): - """Retention tag. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar e_tag: Retention Tag version. - :vartype e_tag: str - :ivar id: Retention Tag version. - :vartype id: str - :param tag_name: Required. Retention Tag Name to relate it to retention rule. - :type tag_name: str - """ - - _validation = { - 'e_tag': {'readonly': True}, - 'id': {'readonly': True}, - 'tag_name': {'required': True}, - } - - _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RetentionTag, self).__init__(**kwargs) - self.e_tag = None - self.id = None - self.tag_name = kwargs['tag_name'] - - -class ScheduleBasedBackupCriteria(BackupCriteria): - """Schedule based backup criteria. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param absolute_criteria: it contains absolute values like "AllBackup" / "FirstOfDay" / - "FirstOfWeek" / "FirstOfMonth" - and should be part of AbsoluteMarker enum. - :type absolute_criteria: list[str or ~azure.mgmt.dataprotection.models.AbsoluteMarker] - :param days_of_month: This is day of the month from 1 to 28 other wise last of month. - :type days_of_month: list[~azure.mgmt.dataprotection.models.Day] - :param days_of_the_week: It should be Sunday/Monday/T..../Saturday. - :type days_of_the_week: list[str or ~azure.mgmt.dataprotection.models.DayOfWeek] - :param months_of_year: It should be January/February/....../December. - :type months_of_year: list[str or ~azure.mgmt.dataprotection.models.Month] - :param schedule_times: List of schedule times for backup. - :type schedule_times: list[~datetime.datetime] - :param weeks_of_the_month: It should be First/Second/Third/Fourth/Last. - :type weeks_of_the_month: list[str or ~azure.mgmt.dataprotection.models.WeekNumber] - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'absolute_criteria': {'key': 'absoluteCriteria', 'type': '[str]'}, - 'days_of_month': {'key': 'daysOfMonth', 'type': '[Day]'}, - 'days_of_the_week': {'key': 'daysOfTheWeek', 'type': '[str]'}, - 'months_of_year': {'key': 'monthsOfYear', 'type': '[str]'}, - 'schedule_times': {'key': 'scheduleTimes', 'type': '[iso-8601]'}, - 'weeks_of_the_month': {'key': 'weeksOfTheMonth', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleBasedBackupCriteria, self).__init__(**kwargs) - self.object_type = 'ScheduleBasedBackupCriteria' # type: str - self.absolute_criteria = kwargs.get('absolute_criteria', None) - self.days_of_month = kwargs.get('days_of_month', None) - self.days_of_the_week = kwargs.get('days_of_the_week', None) - self.months_of_year = kwargs.get('months_of_year', None) - self.schedule_times = kwargs.get('schedule_times', None) - self.weeks_of_the_month = kwargs.get('weeks_of_the_month', None) - - -class ScheduleBasedTriggerContext(TriggerContext): - """Schedule based trigger context. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param schedule: Required. Schedule for this backup. - :type schedule: ~azure.mgmt.dataprotection.models.BackupSchedule - :param tagging_criteria: Required. List of tags that can be applicable for given schedule. - :type tagging_criteria: list[~azure.mgmt.dataprotection.models.TaggingCriteria] - """ - - _validation = { - 'object_type': {'required': True}, - 'schedule': {'required': True}, - 'tagging_criteria': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'BackupSchedule'}, - 'tagging_criteria': {'key': 'taggingCriteria', 'type': '[TaggingCriteria]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleBasedTriggerContext, self).__init__(**kwargs) - self.object_type = 'ScheduleBasedTriggerContext' # type: str - self.schedule = kwargs['schedule'] - self.tagging_criteria = kwargs['tagging_criteria'] - - -class SecretStoreBasedAuthCredentials(AuthCredentials): - """Secret store based authentication credentials. - - All required parameters must be populated in order to send to Azure. - - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param secret_store_resource: Secret store resource. - :type secret_store_resource: ~azure.mgmt.dataprotection.models.SecretStoreResource - """ - - _validation = { - 'object_type': {'required': True}, - } - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'secret_store_resource': {'key': 'secretStoreResource', 'type': 'SecretStoreResource'}, - } - - def __init__( - self, - **kwargs - ): - super(SecretStoreBasedAuthCredentials, self).__init__(**kwargs) - self.object_type = 'SecretStoreBasedAuthCredentials' # type: str - self.secret_store_resource = kwargs.get('secret_store_resource', None) - - -class SecretStoreResource(msrest.serialization.Model): - """Class representing a secret store resource. - - All required parameters must be populated in order to send to Azure. - - :param uri: Uri to get to the resource. - :type uri: str - :param secret_store_type: Required. Gets or sets the type of secret store. Possible values - include: "Invalid", "AzureKeyVault". - :type secret_store_type: str or ~azure.mgmt.dataprotection.models.SecretStoreType - """ - - _validation = { - 'secret_store_type': {'required': True}, - } - - _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'secret_store_type': {'key': 'secretStoreType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecretStoreResource, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) - self.secret_store_type = kwargs['secret_store_type'] - - -class SourceLifeCycle(msrest.serialization.Model): - """Source LifeCycle. - - All required parameters must be populated in order to send to Azure. - - :param delete_after: Required. Delete Option. - :type delete_after: ~azure.mgmt.dataprotection.models.DeleteOption - :param source_data_store: Required. DataStoreInfo base. - :type source_data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase - :param target_data_store_copy_settings: - :type target_data_store_copy_settings: - list[~azure.mgmt.dataprotection.models.TargetCopySetting] - """ - - _validation = { - 'delete_after': {'required': True}, - 'source_data_store': {'required': True}, - } - - _attribute_map = { - 'delete_after': {'key': 'deleteAfter', 'type': 'DeleteOption'}, - 'source_data_store': {'key': 'sourceDataStore', 'type': 'DataStoreInfoBase'}, - 'target_data_store_copy_settings': {'key': 'targetDataStoreCopySettings', 'type': '[TargetCopySetting]'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceLifeCycle, self).__init__(**kwargs) - self.delete_after = kwargs['delete_after'] - self.source_data_store = kwargs['source_data_store'] - self.target_data_store_copy_settings = kwargs.get('target_data_store_copy_settings', None) - - -class StorageSetting(msrest.serialization.Model): - """Storage setting. - - :param datastore_type: Gets or sets the type of the datastore. Possible values include: - "ArchiveStore", "SnapshotStore", "VaultStore". - :type datastore_type: str or ~azure.mgmt.dataprotection.models.StorageSettingStoreTypes - :param type: Gets or sets the type. Possible values include: "GeoRedundant", - "LocallyRedundant". - :type type: str or ~azure.mgmt.dataprotection.models.StorageSettingTypes - """ - - _attribute_map = { - 'datastore_type': {'key': 'datastoreType', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSetting, self).__init__(**kwargs) - self.datastore_type = kwargs.get('datastore_type', None) - self.type = kwargs.get('type', None) - - -class SupportedFeature(msrest.serialization.Model): - """Elements class for feature request. - - :param feature_name: support feature type. - :type feature_name: str - :param support_status: feature support status. Possible values include: "Invalid", - "NotSupported", "AlphaPreview", "PrivatePreview", "PublicPreview", "GenerallyAvailable". - :type support_status: str or ~azure.mgmt.dataprotection.models.FeatureSupportStatus - :param exposure_controlled_features: support feature type. - :type exposure_controlled_features: list[str] - """ - - _attribute_map = { - 'feature_name': {'key': 'featureName', 'type': 'str'}, - 'support_status': {'key': 'supportStatus', 'type': 'str'}, - 'exposure_controlled_features': {'key': 'exposureControlledFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SupportedFeature, self).__init__(**kwargs) - self.feature_name = kwargs.get('feature_name', None) - self.support_status = kwargs.get('support_status', None) - self.exposure_controlled_features = kwargs.get('exposure_controlled_features', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TaggingCriteria(msrest.serialization.Model): - """Tagging criteria. - - All required parameters must be populated in order to send to Azure. - - :param criteria: Criteria which decides whether the tag can be applied to a triggered backup. - :type criteria: list[~azure.mgmt.dataprotection.models.BackupCriteria] - :param is_default: Required. Specifies if tag is default. - :type is_default: bool - :param tagging_priority: Required. Retention Tag priority. - :type tagging_priority: long - :param tag_info: Required. Retention tag information. - :type tag_info: ~azure.mgmt.dataprotection.models.RetentionTag - """ - - _validation = { - 'is_default': {'required': True}, - 'tagging_priority': {'required': True}, - 'tag_info': {'required': True}, - } - - _attribute_map = { - 'criteria': {'key': 'criteria', 'type': '[BackupCriteria]'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'tagging_priority': {'key': 'taggingPriority', 'type': 'long'}, - 'tag_info': {'key': 'tagInfo', 'type': 'RetentionTag'}, - } - - def __init__( - self, - **kwargs - ): - super(TaggingCriteria, self).__init__(**kwargs) - self.criteria = kwargs.get('criteria', None) - self.is_default = kwargs['is_default'] - self.tagging_priority = kwargs['tagging_priority'] - self.tag_info = kwargs['tag_info'] - - -class TargetCopySetting(msrest.serialization.Model): - """Target copy settings. - - All required parameters must be populated in order to send to Azure. - - :param copy_after: Required. It can be CustomCopyOption or ImmediateCopyOption. - :type copy_after: ~azure.mgmt.dataprotection.models.CopyOption - :param data_store: Required. Info of target datastore. - :type data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase - """ - - _validation = { - 'copy_after': {'required': True}, - 'data_store': {'required': True}, - } - - _attribute_map = { - 'copy_after': {'key': 'copyAfter', 'type': 'CopyOption'}, - 'data_store': {'key': 'dataStore', 'type': 'DataStoreInfoBase'}, - } - - def __init__( - self, - **kwargs - ): - super(TargetCopySetting, self).__init__(**kwargs) - self.copy_after = kwargs['copy_after'] - self.data_store = kwargs['data_store'] - - -class TargetDetails(msrest.serialization.Model): - """Class encapsulating target details, used where the destination is not a datasource. - - All required parameters must be populated in order to send to Azure. - - :param file_prefix: Required. Restore operation may create multiple files inside location - pointed by Url - Below will be the common prefix for all of them. - :type file_prefix: str - :param restore_target_location_type: Required. Denotes the target location where the data will - be restored, - string value for the enum - {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}. - Possible values include: "Invalid", "AzureBlobs", "AzureFiles". - :type restore_target_location_type: str or - ~azure.mgmt.dataprotection.models.RestoreTargetLocationType - :param url: Required. Url denoting the restore destination. It can point to container / file - share etc. - :type url: str - """ - - _validation = { - 'file_prefix': {'required': True}, - 'restore_target_location_type': {'required': True}, - 'url': {'required': True}, - } - - _attribute_map = { - 'file_prefix': {'key': 'filePrefix', 'type': 'str'}, - 'restore_target_location_type': {'key': 'restoreTargetLocationType', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TargetDetails, self).__init__(**kwargs) - self.file_prefix = kwargs['file_prefix'] - self.restore_target_location_type = kwargs['restore_target_location_type'] - self.url = kwargs['url'] - - -class TriggerBackupRequest(msrest.serialization.Model): - """Trigger backup request. - - All required parameters must be populated in order to send to Azure. - - :param backup_rule_options: Required. Name for the Rule of the Policy which needs to be applied - for this backup. - :type backup_rule_options: ~azure.mgmt.dataprotection.models.AdHocBackupRuleOptions - """ - - _validation = { - 'backup_rule_options': {'required': True}, - } - - _attribute_map = { - 'backup_rule_options': {'key': 'backupRuleOptions', 'type': 'AdHocBackupRuleOptions'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerBackupRequest, self).__init__(**kwargs) - self.backup_rule_options = kwargs['backup_rule_options'] - - -class UserFacingError(msrest.serialization.Model): - """Error object used by layers that have access to localized content, and propagate that to user. - - :param code: Unique code for this error. - :type code: str - :param details: Additional related Errors. - :type details: list[~azure.mgmt.dataprotection.models.UserFacingError] - :param inner_error: Inner Error. - :type inner_error: ~azure.mgmt.dataprotection.models.InnerError - :param is_retryable: Whether the operation will be retryable or not. - :type is_retryable: bool - :param is_user_error: Whether the operation is due to a user error or service error. - :type is_user_error: bool - :param properties: Any key value pairs that can be injected inside error object. - :type properties: dict[str, str] - :param message: - :type message: str - :param recommended_action: RecommendedAction � localized. - :type recommended_action: list[str] - :param target: Target of the error. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[UserFacingError]'}, - 'inner_error': {'key': 'innerError', 'type': 'InnerError'}, - 'is_retryable': {'key': 'isRetryable', 'type': 'bool'}, - 'is_user_error': {'key': 'isUserError', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'message': {'key': 'message', 'type': 'str'}, - 'recommended_action': {'key': 'recommendedAction', 'type': '[str]'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserFacingError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.details = kwargs.get('details', None) - self.inner_error = kwargs.get('inner_error', None) - self.is_retryable = kwargs.get('is_retryable', None) - self.is_user_error = kwargs.get('is_user_error', None) - self.properties = kwargs.get('properties', None) - self.message = kwargs.get('message', None) - self.recommended_action = kwargs.get('recommended_action', None) - self.target = kwargs.get('target', None) - - -class ValidateForBackupRequest(msrest.serialization.Model): - """Validate for backup request. - - All required parameters must be populated in order to send to Azure. - - :param backup_instance: Required. Backup Instance. - :type backup_instance: ~azure.mgmt.dataprotection.models.BackupInstance - """ - - _validation = { - 'backup_instance': {'required': True}, - } - - _attribute_map = { - 'backup_instance': {'key': 'backupInstance', 'type': 'BackupInstance'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidateForBackupRequest, self).__init__(**kwargs) - self.backup_instance = kwargs['backup_instance'] - - -class ValidateRestoreRequestObject(msrest.serialization.Model): - """Validate restore request object. - - All required parameters must be populated in order to send to Azure. - - :param restore_request_object: Required. Gets or sets the restore request object. - :type restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest - """ - - _validation = { - 'restore_request_object': {'required': True}, - } - - _attribute_map = { - 'restore_request_object': {'key': 'restoreRequestObject', 'type': 'AzureBackupRestoreRequest'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidateRestoreRequestObject, self).__init__(**kwargs) - self.restore_request_object = kwargs['restore_request_object'] diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py index 27867c12c61d..c14b1a8877f8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,49 +8,47 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from .. import _serialization -from ._data_protection_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class DeleteOption(msrest.serialization.Model): +class DeleteOption(_serialization.Model): """Delete Option. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AbsoluteDeleteOption. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AbsoluteDeleteOption All required parameters must be populated in order to send to Azure. - :param duration: Required. Duration of deletion after given timespan. - :type duration: str - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar duration: Duration of deletion after given timespan. Required. + :vartype duration: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'duration': {'required': True}, - 'object_type': {'required': True}, + "duration": {"required": True}, + "object_type": {"required": True}, } _attribute_map = { - 'duration': {'key': 'duration', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, + "duration": {"key": "duration", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'AbsoluteDeleteOption': 'AbsoluteDeleteOption'} - } + _subtype_map = {"object_type": {"AbsoluteDeleteOption": "AbsoluteDeleteOption"}} - def __init__( - self, - *, - duration: str, - **kwargs - ): - super(DeleteOption, self).__init__(**kwargs) + def __init__(self, *, duration: str, **kwargs): + """ + :keyword duration: Duration of deletion after given timespan. Required. + :paramtype duration: str + """ + super().__init__(**kwargs) self.duration = duration self.object_type = None # type: Optional[str] @@ -59,138 +58,134 @@ class AbsoluteDeleteOption(DeleteOption): All required parameters must be populated in order to send to Azure. - :param duration: Required. Duration of deletion after given timespan. - :type duration: str - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar duration: Duration of deletion after given timespan. Required. + :vartype duration: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'duration': {'required': True}, - 'object_type': {'required': True}, + "duration": {"required": True}, + "object_type": {"required": True}, } _attribute_map = { - 'duration': {'key': 'duration', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, + "duration": {"key": "duration", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, } - def __init__( - self, - *, - duration: str, - **kwargs - ): - super(AbsoluteDeleteOption, self).__init__(duration=duration, **kwargs) - self.object_type = 'AbsoluteDeleteOption' # type: str + def __init__(self, *, duration: str, **kwargs): + """ + :keyword duration: Duration of deletion after given timespan. Required. + :paramtype duration: str + """ + super().__init__(duration=duration, **kwargs) + self.object_type = "AbsoluteDeleteOption" # type: str -class AdHocBackupRuleOptions(msrest.serialization.Model): +class AdHocBackupRuleOptions(_serialization.Model): """Adhoc backup rules. All required parameters must be populated in order to send to Azure. - :param rule_name: Required. - :type rule_name: str - :param trigger_option: Required. Adhoc backup trigger option. - :type trigger_option: ~azure.mgmt.dataprotection.models.AdhocBackupTriggerOption + :ivar rule_name: Required. + :vartype rule_name: str + :ivar trigger_option: Adhoc backup trigger option. Required. + :vartype trigger_option: ~azure.mgmt.dataprotection.models.AdhocBackupTriggerOption """ _validation = { - 'rule_name': {'required': True}, - 'trigger_option': {'required': True}, + "rule_name": {"required": True}, + "trigger_option": {"required": True}, } _attribute_map = { - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'trigger_option': {'key': 'triggerOption', 'type': 'AdhocBackupTriggerOption'}, - } - - def __init__( - self, - *, - rule_name: str, - trigger_option: "AdhocBackupTriggerOption", - **kwargs - ): - super(AdHocBackupRuleOptions, self).__init__(**kwargs) + "rule_name": {"key": "ruleName", "type": "str"}, + "trigger_option": {"key": "triggerOption", "type": "AdhocBackupTriggerOption"}, + } + + def __init__(self, *, rule_name: str, trigger_option: "_models.AdhocBackupTriggerOption", **kwargs): + """ + :keyword rule_name: Required. + :paramtype rule_name: str + :keyword trigger_option: Adhoc backup trigger option. Required. + :paramtype trigger_option: ~azure.mgmt.dataprotection.models.AdhocBackupTriggerOption + """ + super().__init__(**kwargs) self.rule_name = rule_name self.trigger_option = trigger_option -class AdhocBackupTriggerOption(msrest.serialization.Model): +class AdhocBackupTriggerOption(_serialization.Model): """Adhoc backup trigger option. - :param retention_tag_override: - :type retention_tag_override: str + :ivar retention_tag_override: + :vartype retention_tag_override: str """ _attribute_map = { - 'retention_tag_override': {'key': 'retentionTagOverride', 'type': 'str'}, + "retention_tag_override": {"key": "retentionTagOverride", "type": "str"}, } - def __init__( - self, - *, - retention_tag_override: Optional[str] = None, - **kwargs - ): - super(AdhocBackupTriggerOption, self).__init__(**kwargs) + def __init__(self, *, retention_tag_override: Optional[str] = None, **kwargs): + """ + :keyword retention_tag_override: + :paramtype retention_tag_override: str + """ + super().__init__(**kwargs) self.retention_tag_override = retention_tag_override -class AdhocBasedTaggingCriteria(msrest.serialization.Model): +class AdhocBasedTaggingCriteria(_serialization.Model): """Adhoc backup tagging criteria. - :param tag_info: Retention tag information. - :type tag_info: ~azure.mgmt.dataprotection.models.RetentionTag + :ivar tag_info: Retention tag information. + :vartype tag_info: ~azure.mgmt.dataprotection.models.RetentionTag """ _attribute_map = { - 'tag_info': {'key': 'tagInfo', 'type': 'RetentionTag'}, + "tag_info": {"key": "tagInfo", "type": "RetentionTag"}, } - def __init__( - self, - *, - tag_info: Optional["RetentionTag"] = None, - **kwargs - ): - super(AdhocBasedTaggingCriteria, self).__init__(**kwargs) + def __init__(self, *, tag_info: Optional["_models.RetentionTag"] = None, **kwargs): + """ + :keyword tag_info: Retention tag information. + :paramtype tag_info: ~azure.mgmt.dataprotection.models.RetentionTag + """ + super().__init__(**kwargs) self.tag_info = tag_info -class TriggerContext(msrest.serialization.Model): +class TriggerContext(_serialization.Model): """Trigger context. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AdhocBasedTriggerContext, ScheduleBasedTriggerContext. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AdhocBasedTriggerContext, ScheduleBasedTriggerContext All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } _subtype_map = { - 'object_type': {'AdhocBasedTriggerContext': 'AdhocBasedTriggerContext', 'ScheduleBasedTriggerContext': 'ScheduleBasedTriggerContext'} + "object_type": { + "AdhocBasedTriggerContext": "AdhocBasedTriggerContext", + "ScheduleBasedTriggerContext": "ScheduleBasedTriggerContext", + } } - def __init__( - self, - **kwargs - ): - super(TriggerContext, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -199,96 +194,86 @@ class AdhocBasedTriggerContext(TriggerContext): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param tagging_criteria: Required. Tagging Criteria containing retention tag for adhoc backup. - :type tagging_criteria: ~azure.mgmt.dataprotection.models.AdhocBasedTaggingCriteria + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar tagging_criteria: Tagging Criteria containing retention tag for adhoc backup. Required. + :vartype tagging_criteria: ~azure.mgmt.dataprotection.models.AdhocBasedTaggingCriteria """ _validation = { - 'object_type': {'required': True}, - 'tagging_criteria': {'required': True}, + "object_type": {"required": True}, + "tagging_criteria": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'tagging_criteria': {'key': 'taggingCriteria', 'type': 'AdhocBasedTaggingCriteria'}, - } - - def __init__( - self, - *, - tagging_criteria: "AdhocBasedTaggingCriteria", - **kwargs - ): - super(AdhocBasedTriggerContext, self).__init__(**kwargs) - self.object_type = 'AdhocBasedTriggerContext' # type: str + "object_type": {"key": "objectType", "type": "str"}, + "tagging_criteria": {"key": "taggingCriteria", "type": "AdhocBasedTaggingCriteria"}, + } + + def __init__(self, *, tagging_criteria: "_models.AdhocBasedTaggingCriteria", **kwargs): + """ + :keyword tagging_criteria: Tagging Criteria containing retention tag for adhoc backup. + Required. + :paramtype tagging_criteria: ~azure.mgmt.dataprotection.models.AdhocBasedTaggingCriteria + """ + super().__init__(**kwargs) + self.object_type = "AdhocBasedTriggerContext" # type: str self.tagging_criteria = tagging_criteria -class AuthCredentials(msrest.serialization.Model): +class AuthCredentials(_serialization.Model): """Base class for different types of authentication credentials. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SecretStoreBasedAuthCredentials. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SecretStoreBasedAuthCredentials All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'SecretStoreBasedAuthCredentials': 'SecretStoreBasedAuthCredentials'} - } + _subtype_map = {"object_type": {"SecretStoreBasedAuthCredentials": "SecretStoreBasedAuthCredentials"}} - def __init__( - self, - **kwargs - ): - super(AuthCredentials, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] -class AzureBackupRecoveryPoint(msrest.serialization.Model): +class AzureBackupRecoveryPoint(_serialization.Model): """Azure backup recoveryPoint. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupDiscreteRecoveryPoint. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureBackupDiscreteRecoveryPoint All required parameters must be populated in order to send to Azure. - :param object_type: Required. Constant filled by server. - :type object_type: str + :ivar object_type: Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'AzureBackupDiscreteRecoveryPoint': 'AzureBackupDiscreteRecoveryPoint'} - } + _subtype_map = {"object_type": {"AzureBackupDiscreteRecoveryPoint": "AzureBackupDiscreteRecoveryPoint"}} - def __init__( - self, - **kwargs - ): - super(AzureBackupRecoveryPoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -297,45 +282,48 @@ class AzureBackupDiscreteRecoveryPoint(AzureBackupRecoveryPoint): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Constant filled by server. - :type object_type: str - :param friendly_name: - :type friendly_name: str - :param recovery_point_data_stores_details: - :type recovery_point_data_stores_details: + :ivar object_type: Required. + :vartype object_type: str + :ivar friendly_name: + :vartype friendly_name: str + :ivar recovery_point_data_stores_details: + :vartype recovery_point_data_stores_details: list[~azure.mgmt.dataprotection.models.RecoveryPointDataStoreDetails] - :param recovery_point_time: Required. - :type recovery_point_time: ~datetime.datetime - :param policy_name: - :type policy_name: str - :param policy_version: - :type policy_version: str - :param recovery_point_id: - :type recovery_point_id: str - :param recovery_point_type: - :type recovery_point_type: str - :param retention_tag_name: - :type retention_tag_name: str - :param retention_tag_version: - :type retention_tag_version: str + :ivar recovery_point_time: Required. + :vartype recovery_point_time: ~datetime.datetime + :ivar policy_name: + :vartype policy_name: str + :ivar policy_version: + :vartype policy_version: str + :ivar recovery_point_id: + :vartype recovery_point_id: str + :ivar recovery_point_type: + :vartype recovery_point_type: str + :ivar retention_tag_name: + :vartype retention_tag_name: str + :ivar retention_tag_version: + :vartype retention_tag_version: str """ _validation = { - 'object_type': {'required': True}, - 'recovery_point_time': {'required': True}, + "object_type": {"required": True}, + "recovery_point_time": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'recovery_point_data_stores_details': {'key': 'recoveryPointDataStoresDetails', 'type': '[RecoveryPointDataStoreDetails]'}, - 'recovery_point_time': {'key': 'recoveryPointTime', 'type': 'iso-8601'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, - 'policy_version': {'key': 'policyVersion', 'type': 'str'}, - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - 'recovery_point_type': {'key': 'recoveryPointType', 'type': 'str'}, - 'retention_tag_name': {'key': 'retentionTagName', 'type': 'str'}, - 'retention_tag_version': {'key': 'retentionTagVersion', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "friendly_name": {"key": "friendlyName", "type": "str"}, + "recovery_point_data_stores_details": { + "key": "recoveryPointDataStoresDetails", + "type": "[RecoveryPointDataStoreDetails]", + }, + "recovery_point_time": {"key": "recoveryPointTime", "type": "iso-8601"}, + "policy_name": {"key": "policyName", "type": "str"}, + "policy_version": {"key": "policyVersion", "type": "str"}, + "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, + "recovery_point_type": {"key": "recoveryPointType", "type": "str"}, + "retention_tag_name": {"key": "retentionTagName", "type": "str"}, + "retention_tag_version": {"key": "retentionTagVersion", "type": "str"}, } def __init__( @@ -343,7 +331,7 @@ def __init__( *, recovery_point_time: datetime.datetime, friendly_name: Optional[str] = None, - recovery_point_data_stores_details: Optional[List["RecoveryPointDataStoreDetails"]] = None, + recovery_point_data_stores_details: Optional[List["_models.RecoveryPointDataStoreDetails"]] = None, policy_name: Optional[str] = None, policy_version: Optional[str] = None, recovery_point_id: Optional[str] = None, @@ -352,8 +340,29 @@ def __init__( retention_tag_version: Optional[str] = None, **kwargs ): - super(AzureBackupDiscreteRecoveryPoint, self).__init__(**kwargs) - self.object_type = 'AzureBackupDiscreteRecoveryPoint' # type: str + """ + :keyword friendly_name: + :paramtype friendly_name: str + :keyword recovery_point_data_stores_details: + :paramtype recovery_point_data_stores_details: + list[~azure.mgmt.dataprotection.models.RecoveryPointDataStoreDetails] + :keyword recovery_point_time: Required. + :paramtype recovery_point_time: ~datetime.datetime + :keyword policy_name: + :paramtype policy_name: str + :keyword policy_version: + :paramtype policy_version: str + :keyword recovery_point_id: + :paramtype recovery_point_id: str + :keyword recovery_point_type: + :paramtype recovery_point_type: str + :keyword retention_tag_name: + :paramtype retention_tag_name: str + :keyword retention_tag_version: + :paramtype retention_tag_version: str + """ + super().__init__(**kwargs) + self.object_type = "AzureBackupDiscreteRecoveryPoint" # type: str self.friendly_name = friendly_name self.recovery_point_data_stores_details = recovery_point_data_stores_details self.recovery_point_time = recovery_point_time @@ -365,73 +374,83 @@ def __init__( self.retention_tag_version = retention_tag_version -class AzureBackupFindRestorableTimeRangesRequest(msrest.serialization.Model): +class AzureBackupFindRestorableTimeRangesRequest(_serialization.Model): """List Restore Ranges Request. All required parameters must be populated in order to send to Azure. - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "OperationalStore", "VaultStore", "ArchiveStore". - :type source_data_store_type: str or + :ivar source_data_store_type: Gets or sets the type of the source data store. Required. Known + values are: "OperationalStore", "VaultStore", and "ArchiveStore". + :vartype source_data_store_type: str or ~azure.mgmt.dataprotection.models.RestoreSourceDataStoreType - :param start_time: Start time for the List Restore Ranges request. ISO 8601 format. - :type start_time: str - :param end_time: End time for the List Restore Ranges request. ISO 8601 format. - :type end_time: str + :ivar start_time: Start time for the List Restore Ranges request. ISO 8601 format. + :vartype start_time: str + :ivar end_time: End time for the List Restore Ranges request. ISO 8601 format. + :vartype end_time: str """ _validation = { - 'source_data_store_type': {'required': True}, + "source_data_store_type": {"required": True}, } _attribute_map = { - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, + "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, } def __init__( self, *, - source_data_store_type: Union[str, "RestoreSourceDataStoreType"], + source_data_store_type: Union[str, "_models.RestoreSourceDataStoreType"], start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs ): - super(AzureBackupFindRestorableTimeRangesRequest, self).__init__(**kwargs) + """ + :keyword source_data_store_type: Gets or sets the type of the source data store. Required. + Known values are: "OperationalStore", "VaultStore", and "ArchiveStore". + :paramtype source_data_store_type: str or + ~azure.mgmt.dataprotection.models.RestoreSourceDataStoreType + :keyword start_time: Start time for the List Restore Ranges request. ISO 8601 format. + :paramtype start_time: str + :keyword end_time: End time for the List Restore Ranges request. ISO 8601 format. + :paramtype end_time: str + """ + super().__init__(**kwargs) self.source_data_store_type = source_data_store_type self.start_time = start_time self.end_time = end_time -class DppWorkerRequest(msrest.serialization.Model): +class DppWorkerRequest(_serialization.Model): """DppWorkerRequest. - :param subscription_id: - :type subscription_id: str - :param uri: - :type uri: str - :param headers: Dictionary of + :ivar subscription_id: + :vartype subscription_id: str + :ivar uri: + :vartype uri: str + :ivar headers: Dictionary of . - :type headers: dict[str, list[str]] - :param supported_group_versions: - :type supported_group_versions: list[str] - :param culture_info: - :type culture_info: str - :param parameters: Dictionary of :code:``. - :type parameters: dict[str, str] - :param http_method: - :type http_method: str + :vartype headers: dict[str, list[str]] + :ivar supported_group_versions: + :vartype supported_group_versions: list[str] + :ivar culture_info: + :vartype culture_info: str + :ivar parameters: Dictionary of :code:``. + :vartype parameters: dict[str, str] + :ivar http_method: + :vartype http_method: str """ _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{[str]}'}, - 'supported_group_versions': {'key': 'supportedGroupVersions', 'type': '[str]'}, - 'culture_info': {'key': 'cultureInfo', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "headers": {"key": "headers", "type": "{[str]}"}, + "supported_group_versions": {"key": "supportedGroupVersions", "type": "[str]"}, + "culture_info": {"key": "cultureInfo", "type": "str"}, + "parameters": {"key": "parameters", "type": "{str}"}, + "http_method": {"key": "httpMethod", "type": "str"}, } def __init__( @@ -446,7 +465,24 @@ def __init__( http_method: Optional[str] = None, **kwargs ): - super(DppWorkerRequest, self).__init__(**kwargs) + """ + :keyword subscription_id: + :paramtype subscription_id: str + :keyword uri: + :paramtype uri: str + :keyword headers: Dictionary of + . + :paramtype headers: dict[str, list[str]] + :keyword supported_group_versions: + :paramtype supported_group_versions: list[str] + :keyword culture_info: + :paramtype culture_info: str + :keyword parameters: Dictionary of :code:``. + :paramtype parameters: dict[str, str] + :keyword http_method: + :paramtype http_method: str + """ + super().__init__(**kwargs) self.subscription_id = subscription_id self.uri = uri self.headers = headers @@ -459,34 +495,34 @@ def __init__( class AzureBackupFindRestorableTimeRangesRequestResource(DppWorkerRequest): """List Restore Ranges Request. - :param subscription_id: - :type subscription_id: str - :param uri: - :type uri: str - :param headers: Dictionary of + :ivar subscription_id: + :vartype subscription_id: str + :ivar uri: + :vartype uri: str + :ivar headers: Dictionary of . - :type headers: dict[str, list[str]] - :param supported_group_versions: - :type supported_group_versions: list[str] - :param culture_info: - :type culture_info: str - :param parameters: Dictionary of :code:``. - :type parameters: dict[str, str] - :param http_method: - :type http_method: str - :param content: AzureBackupFindRestorableTimeRangesRequestResource content. - :type content: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest - """ - - _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{[str]}'}, - 'supported_group_versions': {'key': 'supportedGroupVersions', 'type': '[str]'}, - 'culture_info': {'key': 'cultureInfo', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'AzureBackupFindRestorableTimeRangesRequest'}, + :vartype headers: dict[str, list[str]] + :ivar supported_group_versions: + :vartype supported_group_versions: list[str] + :ivar culture_info: + :vartype culture_info: str + :ivar parameters: Dictionary of :code:``. + :vartype parameters: dict[str, str] + :ivar http_method: + :vartype http_method: str + :ivar content: AzureBackupFindRestorableTimeRangesRequestResource content. + :vartype content: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest + """ + + _attribute_map = { + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "headers": {"key": "headers", "type": "{[str]}"}, + "supported_group_versions": {"key": "supportedGroupVersions", "type": "[str]"}, + "culture_info": {"key": "cultureInfo", "type": "str"}, + "parameters": {"key": "parameters", "type": "{str}"}, + "http_method": {"key": "httpMethod", "type": "str"}, + "content": {"key": "content", "type": "AzureBackupFindRestorableTimeRangesRequest"}, } def __init__( @@ -499,40 +535,75 @@ def __init__( culture_info: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, http_method: Optional[str] = None, - content: Optional["AzureBackupFindRestorableTimeRangesRequest"] = None, + content: Optional["_models.AzureBackupFindRestorableTimeRangesRequest"] = None, **kwargs ): - super(AzureBackupFindRestorableTimeRangesRequestResource, self).__init__(subscription_id=subscription_id, uri=uri, headers=headers, supported_group_versions=supported_group_versions, culture_info=culture_info, parameters=parameters, http_method=http_method, **kwargs) + """ + :keyword subscription_id: + :paramtype subscription_id: str + :keyword uri: + :paramtype uri: str + :keyword headers: Dictionary of + . + :paramtype headers: dict[str, list[str]] + :keyword supported_group_versions: + :paramtype supported_group_versions: list[str] + :keyword culture_info: + :paramtype culture_info: str + :keyword parameters: Dictionary of :code:``. + :paramtype parameters: dict[str, str] + :keyword http_method: + :paramtype http_method: str + :keyword content: AzureBackupFindRestorableTimeRangesRequestResource content. + :paramtype content: + ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest + """ + super().__init__( + subscription_id=subscription_id, + uri=uri, + headers=headers, + supported_group_versions=supported_group_versions, + culture_info=culture_info, + parameters=parameters, + http_method=http_method, + **kwargs + ) self.content = content -class AzureBackupFindRestorableTimeRangesResponse(msrest.serialization.Model): +class AzureBackupFindRestorableTimeRangesResponse(_serialization.Model): """List Restore Ranges Response. - :param restorable_time_ranges: Returns the Restore Ranges available on the Backup Instance. - :type restorable_time_ranges: list[~azure.mgmt.dataprotection.models.RestorableTimeRange] - :param object_type: - :type object_type: str + :ivar restorable_time_ranges: Returns the Restore Ranges available on the Backup Instance. + :vartype restorable_time_ranges: list[~azure.mgmt.dataprotection.models.RestorableTimeRange] + :ivar object_type: + :vartype object_type: str """ _attribute_map = { - 'restorable_time_ranges': {'key': 'restorableTimeRanges', 'type': '[RestorableTimeRange]'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, + "restorable_time_ranges": {"key": "restorableTimeRanges", "type": "[RestorableTimeRange]"}, + "object_type": {"key": "objectType", "type": "str"}, } def __init__( self, *, - restorable_time_ranges: Optional[List["RestorableTimeRange"]] = None, + restorable_time_ranges: Optional[List["_models.RestorableTimeRange"]] = None, object_type: Optional[str] = None, **kwargs ): - super(AzureBackupFindRestorableTimeRangesResponse, self).__init__(**kwargs) + """ + :keyword restorable_time_ranges: Returns the Restore Ranges available on the Backup Instance. + :paramtype restorable_time_ranges: list[~azure.mgmt.dataprotection.models.RestorableTimeRange] + :keyword object_type: + :paramtype object_type: str + """ + super().__init__(**kwargs) self.restorable_time_ranges = restorable_time_ranges self.object_type = object_type -class DppResource(msrest.serialization.Model): +class DppResource(_serialization.Model): """Resource class. Variables are only populated by the server, and will be ignored when sending a request. @@ -549,24 +620,22 @@ class DppResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - super(DppResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -587,171 +656,172 @@ class AzureBackupFindRestorableTimeRangesResponseResource(DppResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: AzureBackupFindRestorableTimeRangesResponseResource properties. - :type properties: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponse + :ivar properties: AzureBackupFindRestorableTimeRangesResponseResource properties. + :vartype properties: + ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponse """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'AzureBackupFindRestorableTimeRangesResponse'}, - } - - def __init__( - self, - *, - properties: Optional["AzureBackupFindRestorableTimeRangesResponse"] = None, - **kwargs - ): - super(AzureBackupFindRestorableTimeRangesResponseResource, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "AzureBackupFindRestorableTimeRangesResponse"}, + } + + def __init__(self, *, properties: Optional["_models.AzureBackupFindRestorableTimeRangesResponse"] = None, **kwargs): + """ + :keyword properties: AzureBackupFindRestorableTimeRangesResponseResource properties. + :paramtype properties: + ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponse + """ + super().__init__(**kwargs) self.properties = properties -class AzureBackupJob(msrest.serialization.Model): +class AzureBackupJob(_serialization.Model): # pylint: disable=too-many-instance-attributes """AzureBackup Job Class. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param activity_id: Required. Job Activity Id. - :type activity_id: str - :param backup_instance_friendly_name: Required. Name of the Backup Instance. - :type backup_instance_friendly_name: str + :ivar activity_id: Job Activity Id. Required. + :vartype activity_id: str + :ivar backup_instance_friendly_name: Name of the Backup Instance. Required. + :vartype backup_instance_friendly_name: str :ivar backup_instance_id: ARM ID of the Backup Instance. :vartype backup_instance_id: str - :param data_source_id: Required. ARM ID of the DataSource. - :type data_source_id: str - :param data_source_location: Required. Location of the DataSource. - :type data_source_location: str - :param data_source_name: Required. User Friendly Name of the DataSource. - :type data_source_name: str - :param data_source_set_name: Data Source Set Name of the DataSource. - :type data_source_set_name: str - :param data_source_type: Required. Type of DataSource. - :type data_source_type: str - :param duration: Total run time of the job. ISO 8601 format. - :type duration: str + :ivar data_source_id: ARM ID of the DataSource. Required. + :vartype data_source_id: str + :ivar data_source_location: Location of the DataSource. Required. + :vartype data_source_location: str + :ivar data_source_name: User Friendly Name of the DataSource. Required. + :vartype data_source_name: str + :ivar data_source_set_name: Data Source Set Name of the DataSource. + :vartype data_source_set_name: str + :ivar data_source_type: Type of DataSource. Required. + :vartype data_source_type: str + :ivar duration: Total run time of the job. ISO 8601 format. + :vartype duration: str :ivar end_time: EndTime of the job(in UTC). :vartype end_time: ~datetime.datetime :ivar error_details: A List, detailing the errors related to the job. :vartype error_details: list[~azure.mgmt.dataprotection.models.UserFacingError] :ivar extended_info: Extended Information about the job. :vartype extended_info: ~azure.mgmt.dataprotection.models.JobExtendedInfo - :param is_user_triggered: Required. Indicated that whether the job is adhoc(true) or - scheduled(false). - :type is_user_triggered: bool - :param operation: Required. It indicates the type of Job i.e. Backup:full/log/diff - ;Restore:ALR/OLR; Tiering:Backup/Archive ; Management:ConfigureProtection/UnConfigure. - :type operation: str - :param operation_category: Required. It indicates the type of Job i.e. - Backup/Restore/Tiering/Management. - :type operation_category: str + :ivar is_user_triggered: Indicated that whether the job is adhoc(true) or scheduled(false). + Required. + :vartype is_user_triggered: bool + :ivar operation: It indicates the type of Job i.e. Backup:full/log/diff ;Restore:ALR/OLR; + Tiering:Backup/Archive ; Management:ConfigureProtection/UnConfigure. Required. + :vartype operation: str + :ivar operation_category: It indicates the type of Job i.e. Backup/Restore/Tiering/Management. + Required. + :vartype operation_category: str :ivar policy_id: ARM ID of the policy. :vartype policy_id: str :ivar policy_name: Name of the policy. :vartype policy_name: str - :param progress_enabled: Required. Indicated whether progress is enabled for the job. - :type progress_enabled: bool + :ivar progress_enabled: Indicated whether progress is enabled for the job. Required. + :vartype progress_enabled: bool :ivar progress_url: Url which contains job's progress. :vartype progress_url: str :ivar restore_type: It indicates the sub type of operation i.e. in case of Restore it can be ALR/OLR. :vartype restore_type: str - :param source_resource_group: Required. Resource Group Name of the Datasource. - :type source_resource_group: str - :param source_subscription_id: Required. SubscriptionId corresponding to the DataSource. - :type source_subscription_id: str - :param start_time: Required. StartTime of the job(in UTC). - :type start_time: ~datetime.datetime - :param status: Required. Status of the job like - InProgress/Success/Failed/Cancelled/SuccessWithWarning. - :type status: str - :param subscription_id: Required. Subscription Id of the corresponding backup vault. - :type subscription_id: str - :param supported_actions: Required. List of supported actions. - :type supported_actions: list[str] - :param vault_name: Required. Name of the vault. - :type vault_name: str - :param etag: - :type etag: str - :param source_data_store_name: - :type source_data_store_name: str - :param destination_data_store_name: - :type destination_data_store_name: str + :ivar source_resource_group: Resource Group Name of the Datasource. Required. + :vartype source_resource_group: str + :ivar source_subscription_id: SubscriptionId corresponding to the DataSource. Required. + :vartype source_subscription_id: str + :ivar start_time: StartTime of the job(in UTC). Required. + :vartype start_time: ~datetime.datetime + :ivar status: Status of the job like InProgress/Success/Failed/Cancelled/SuccessWithWarning. + Required. + :vartype status: str + :ivar subscription_id: Subscription Id of the corresponding backup vault. Required. + :vartype subscription_id: str + :ivar supported_actions: List of supported actions. Required. + :vartype supported_actions: list[str] + :ivar vault_name: Name of the vault. Required. + :vartype vault_name: str + :ivar etag: + :vartype etag: str + :ivar source_data_store_name: + :vartype source_data_store_name: str + :ivar destination_data_store_name: + :vartype destination_data_store_name: str """ _validation = { - 'activity_id': {'required': True}, - 'backup_instance_friendly_name': {'required': True}, - 'backup_instance_id': {'readonly': True}, - 'data_source_id': {'required': True}, - 'data_source_location': {'required': True}, - 'data_source_name': {'required': True}, - 'data_source_type': {'required': True}, - 'end_time': {'readonly': True}, - 'error_details': {'readonly': True}, - 'extended_info': {'readonly': True}, - 'is_user_triggered': {'required': True}, - 'operation': {'required': True}, - 'operation_category': {'required': True}, - 'policy_id': {'readonly': True}, - 'policy_name': {'readonly': True}, - 'progress_enabled': {'required': True}, - 'progress_url': {'readonly': True}, - 'restore_type': {'readonly': True}, - 'source_resource_group': {'required': True}, - 'source_subscription_id': {'required': True}, - 'start_time': {'required': True}, - 'status': {'required': True}, - 'subscription_id': {'required': True}, - 'supported_actions': {'required': True}, - 'vault_name': {'required': True}, - } - - _attribute_map = { - 'activity_id': {'key': 'activityID', 'type': 'str'}, - 'backup_instance_friendly_name': {'key': 'backupInstanceFriendlyName', 'type': 'str'}, - 'backup_instance_id': {'key': 'backupInstanceId', 'type': 'str'}, - 'data_source_id': {'key': 'dataSourceId', 'type': 'str'}, - 'data_source_location': {'key': 'dataSourceLocation', 'type': 'str'}, - 'data_source_name': {'key': 'dataSourceName', 'type': 'str'}, - 'data_source_set_name': {'key': 'dataSourceSetName', 'type': 'str'}, - 'data_source_type': {'key': 'dataSourceType', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'error_details': {'key': 'errorDetails', 'type': '[UserFacingError]'}, - 'extended_info': {'key': 'extendedInfo', 'type': 'JobExtendedInfo'}, - 'is_user_triggered': {'key': 'isUserTriggered', 'type': 'bool'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'operation_category': {'key': 'operationCategory', 'type': 'str'}, - 'policy_id': {'key': 'policyId', 'type': 'str'}, - 'policy_name': {'key': 'policyName', 'type': 'str'}, - 'progress_enabled': {'key': 'progressEnabled', 'type': 'bool'}, - 'progress_url': {'key': 'progressUrl', 'type': 'str'}, - 'restore_type': {'key': 'restoreType', 'type': 'str'}, - 'source_resource_group': {'key': 'sourceResourceGroup', 'type': 'str'}, - 'source_subscription_id': {'key': 'sourceSubscriptionID', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'supported_actions': {'key': 'supportedActions', 'type': '[str]'}, - 'vault_name': {'key': 'vaultName', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'source_data_store_name': {'key': 'sourceDataStoreName', 'type': 'str'}, - 'destination_data_store_name': {'key': 'destinationDataStoreName', 'type': 'str'}, + "activity_id": {"required": True}, + "backup_instance_friendly_name": {"required": True}, + "backup_instance_id": {"readonly": True}, + "data_source_id": {"required": True}, + "data_source_location": {"required": True}, + "data_source_name": {"required": True}, + "data_source_type": {"required": True}, + "end_time": {"readonly": True}, + "error_details": {"readonly": True}, + "extended_info": {"readonly": True}, + "is_user_triggered": {"required": True}, + "operation": {"required": True}, + "operation_category": {"required": True}, + "policy_id": {"readonly": True}, + "policy_name": {"readonly": True}, + "progress_enabled": {"required": True}, + "progress_url": {"readonly": True}, + "restore_type": {"readonly": True}, + "source_resource_group": {"required": True}, + "source_subscription_id": {"required": True}, + "start_time": {"required": True}, + "status": {"required": True}, + "subscription_id": {"required": True}, + "supported_actions": {"required": True}, + "vault_name": {"required": True}, } - def __init__( + _attribute_map = { + "activity_id": {"key": "activityID", "type": "str"}, + "backup_instance_friendly_name": {"key": "backupInstanceFriendlyName", "type": "str"}, + "backup_instance_id": {"key": "backupInstanceId", "type": "str"}, + "data_source_id": {"key": "dataSourceId", "type": "str"}, + "data_source_location": {"key": "dataSourceLocation", "type": "str"}, + "data_source_name": {"key": "dataSourceName", "type": "str"}, + "data_source_set_name": {"key": "dataSourceSetName", "type": "str"}, + "data_source_type": {"key": "dataSourceType", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "error_details": {"key": "errorDetails", "type": "[UserFacingError]"}, + "extended_info": {"key": "extendedInfo", "type": "JobExtendedInfo"}, + "is_user_triggered": {"key": "isUserTriggered", "type": "bool"}, + "operation": {"key": "operation", "type": "str"}, + "operation_category": {"key": "operationCategory", "type": "str"}, + "policy_id": {"key": "policyId", "type": "str"}, + "policy_name": {"key": "policyName", "type": "str"}, + "progress_enabled": {"key": "progressEnabled", "type": "bool"}, + "progress_url": {"key": "progressUrl", "type": "str"}, + "restore_type": {"key": "restoreType", "type": "str"}, + "source_resource_group": {"key": "sourceResourceGroup", "type": "str"}, + "source_subscription_id": {"key": "sourceSubscriptionID", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "supported_actions": {"key": "supportedActions", "type": "[str]"}, + "vault_name": {"key": "vaultName", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "source_data_store_name": {"key": "sourceDataStoreName", "type": "str"}, + "destination_data_store_name": {"key": "destinationDataStoreName", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, activity_id: str, @@ -778,7 +848,57 @@ def __init__( destination_data_store_name: Optional[str] = None, **kwargs ): - super(AzureBackupJob, self).__init__(**kwargs) + """ + :keyword activity_id: Job Activity Id. Required. + :paramtype activity_id: str + :keyword backup_instance_friendly_name: Name of the Backup Instance. Required. + :paramtype backup_instance_friendly_name: str + :keyword data_source_id: ARM ID of the DataSource. Required. + :paramtype data_source_id: str + :keyword data_source_location: Location of the DataSource. Required. + :paramtype data_source_location: str + :keyword data_source_name: User Friendly Name of the DataSource. Required. + :paramtype data_source_name: str + :keyword data_source_set_name: Data Source Set Name of the DataSource. + :paramtype data_source_set_name: str + :keyword data_source_type: Type of DataSource. Required. + :paramtype data_source_type: str + :keyword duration: Total run time of the job. ISO 8601 format. + :paramtype duration: str + :keyword is_user_triggered: Indicated that whether the job is adhoc(true) or scheduled(false). + Required. + :paramtype is_user_triggered: bool + :keyword operation: It indicates the type of Job i.e. Backup:full/log/diff ;Restore:ALR/OLR; + Tiering:Backup/Archive ; Management:ConfigureProtection/UnConfigure. Required. + :paramtype operation: str + :keyword operation_category: It indicates the type of Job i.e. + Backup/Restore/Tiering/Management. Required. + :paramtype operation_category: str + :keyword progress_enabled: Indicated whether progress is enabled for the job. Required. + :paramtype progress_enabled: bool + :keyword source_resource_group: Resource Group Name of the Datasource. Required. + :paramtype source_resource_group: str + :keyword source_subscription_id: SubscriptionId corresponding to the DataSource. Required. + :paramtype source_subscription_id: str + :keyword start_time: StartTime of the job(in UTC). Required. + :paramtype start_time: ~datetime.datetime + :keyword status: Status of the job like InProgress/Success/Failed/Cancelled/SuccessWithWarning. + Required. + :paramtype status: str + :keyword subscription_id: Subscription Id of the corresponding backup vault. Required. + :paramtype subscription_id: str + :keyword supported_actions: List of supported actions. Required. + :paramtype supported_actions: list[str] + :keyword vault_name: Name of the vault. Required. + :paramtype vault_name: str + :keyword etag: + :paramtype etag: str + :keyword source_data_store_name: + :paramtype source_data_store_name: str + :keyword destination_data_store_name: + :paramtype destination_data_store_name: str + """ + super().__init__(**kwargs) self.activity_id = activity_id self.backup_instance_friendly_name = backup_instance_friendly_name self.backup_instance_id = None @@ -825,113 +945,114 @@ class AzureBackupJobResource(DppResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: AzureBackupJobResource properties. - :type properties: ~azure.mgmt.dataprotection.models.AzureBackupJob + :ivar properties: AzureBackupJobResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.AzureBackupJob """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'AzureBackupJob'}, - } - - def __init__( - self, - *, - properties: Optional["AzureBackupJob"] = None, - **kwargs - ): - super(AzureBackupJobResource, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "AzureBackupJob"}, + } + + def __init__(self, *, properties: Optional["_models.AzureBackupJob"] = None, **kwargs): + """ + :keyword properties: AzureBackupJobResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.AzureBackupJob + """ + super().__init__(**kwargs) self.properties = properties -class DppResourceList(msrest.serialization.Model): +class DppResourceList(_serialization.Model): """ListResource. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - **kwargs - ): - super(DppResourceList, self).__init__(**kwargs) + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.next_link = next_link class AzureBackupJobResourceList(DppResourceList): """List of AzureBackup Job resources. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.AzureBackupJobResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.AzureBackupJobResource] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[AzureBackupJobResource]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[AzureBackupJobResource]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["AzureBackupJobResource"]] = None, + value: Optional[List["_models.AzureBackupJobResource"]] = None, **kwargs ): - super(AzureBackupJobResourceList, self).__init__(next_link=next_link, **kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.AzureBackupJobResource] + """ + super().__init__(next_link=next_link, **kwargs) self.value = value -class BackupParameters(msrest.serialization.Model): +class BackupParameters(_serialization.Model): """BackupParameters base. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupParams. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureBackupParams All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'AzureBackupParams': 'AzureBackupParams'} - } + _subtype_map = {"object_type": {"AzureBackupParams": "AzureBackupParams"}} - def __init__( - self, - **kwargs - ): - super(BackupParameters, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -940,127 +1061,166 @@ class AzureBackupParams(BackupParameters): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param backup_type: Required. BackupType ; Full/Incremental etc. - :type backup_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar backup_type: BackupType ; Full/Incremental etc. Required. + :vartype backup_type: str """ _validation = { - 'object_type': {'required': True}, - 'backup_type': {'required': True}, + "object_type": {"required": True}, + "backup_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'backup_type': {'key': 'backupType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "backup_type": {"key": "backupType", "type": "str"}, } - def __init__( - self, - *, - backup_type: str, - **kwargs - ): - super(AzureBackupParams, self).__init__(**kwargs) - self.object_type = 'AzureBackupParams' # type: str + def __init__(self, *, backup_type: str, **kwargs): + """ + :keyword backup_type: BackupType ; Full/Incremental etc. Required. + :paramtype backup_type: str + """ + super().__init__(**kwargs) + self.object_type = "AzureBackupParams" # type: str self.backup_type = backup_type -class AzureBackupRestoreRequest(msrest.serialization.Model): +class AzureBackupRestoreRequest(_serialization.Model): """Azure backup restore request. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupRecoveryPointBasedRestoreRequest, AzureBackupRecoveryTimeBasedRestoreRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureBackupRecoveryPointBasedRestoreRequest, AzureBackupRecoveryTimeBasedRestoreRequest All required parameters must be populated in order to send to Azure. - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :ivar object_type: Required. + :vartype object_type: str + :ivar restore_target_info: Gets or sets the restore target information. Required. + :vartype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :ivar source_data_store_type: Gets or sets the type of the source data store. Required. Known + values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :vartype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is + being recovered. + :vartype source_resource_id: str """ _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, + "object_type": {"required": True}, + "restore_target_info": {"required": True}, + "source_data_store_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, + "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, + "source_resource_id": {"key": "sourceResourceId", "type": "str"}, } _subtype_map = { - 'object_type': {'AzureBackupRecoveryPointBasedRestoreRequest': 'AzureBackupRecoveryPointBasedRestoreRequest', 'AzureBackupRecoveryTimeBasedRestoreRequest': 'AzureBackupRecoveryTimeBasedRestoreRequest'} + "object_type": { + "AzureBackupRecoveryPointBasedRestoreRequest": "AzureBackupRecoveryPointBasedRestoreRequest", + "AzureBackupRecoveryTimeBasedRestoreRequest": "AzureBackupRecoveryTimeBasedRestoreRequest", + } } def __init__( self, *, - restore_target_info: "RestoreTargetInfoBase", - source_data_store_type: Union[str, "SourceDataStoreType"], + restore_target_info: "_models.RestoreTargetInfoBase", + source_data_store_type: Union[str, "_models.SourceDataStoreType"], + source_resource_id: Optional[str] = None, **kwargs ): - super(AzureBackupRestoreRequest, self).__init__(**kwargs) + """ + :keyword restore_target_info: Gets or sets the restore target information. Required. + :paramtype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :keyword source_data_store_type: Gets or sets the type of the source data store. Required. + Known values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :paramtype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which + is being recovered. + :paramtype source_resource_id: str + """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] self.restore_target_info = restore_target_info self.source_data_store_type = source_data_store_type + self.source_resource_id = source_resource_id class AzureBackupRecoveryPointBasedRestoreRequest(AzureBackupRestoreRequest): """Azure backup recoveryPoint based restore request. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupRestoreWithRehydrationRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureBackupRestoreWithRehydrationRequest All required parameters must be populated in order to send to Azure. - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - :param recovery_point_id: Required. - :type recovery_point_id: str + :ivar object_type: Required. + :vartype object_type: str + :ivar restore_target_info: Gets or sets the restore target information. Required. + :vartype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :ivar source_data_store_type: Gets or sets the type of the source data store. Required. Known + values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :vartype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is + being recovered. + :vartype source_resource_id: str + :ivar recovery_point_id: Required. + :vartype recovery_point_id: str """ _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - 'recovery_point_id': {'required': True}, + "object_type": {"required": True}, + "restore_target_info": {"required": True}, + "source_data_store_type": {"required": True}, + "recovery_point_id": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, + "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, + "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, } _subtype_map = { - 'object_type': {'AzureBackupRestoreWithRehydrationRequest': 'AzureBackupRestoreWithRehydrationRequest'} + "object_type": {"AzureBackupRestoreWithRehydrationRequest": "AzureBackupRestoreWithRehydrationRequest"} } def __init__( self, *, - restore_target_info: "RestoreTargetInfoBase", - source_data_store_type: Union[str, "SourceDataStoreType"], + restore_target_info: "_models.RestoreTargetInfoBase", + source_data_store_type: Union[str, "_models.SourceDataStoreType"], recovery_point_id: str, + source_resource_id: Optional[str] = None, **kwargs ): - super(AzureBackupRecoveryPointBasedRestoreRequest, self).__init__(restore_target_info=restore_target_info, source_data_store_type=source_data_store_type, **kwargs) - self.object_type = 'AzureBackupRecoveryPointBasedRestoreRequest' # type: str + """ + :keyword restore_target_info: Gets or sets the restore target information. Required. + :paramtype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :keyword source_data_store_type: Gets or sets the type of the source data store. Required. + Known values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :paramtype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which + is being recovered. + :paramtype source_resource_id: str + :keyword recovery_point_id: Required. + :paramtype recovery_point_id: str + """ + super().__init__( + restore_target_info=restore_target_info, + source_data_store_type=source_data_store_type, + source_resource_id=source_resource_id, + **kwargs + ) + self.object_type = "AzureBackupRecoveryPointBasedRestoreRequest" # type: str self.recovery_point_id = recovery_point_id @@ -1078,58 +1238,64 @@ class AzureBackupRecoveryPointResource(DppResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: AzureBackupRecoveryPointResource properties. - :type properties: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPoint + :ivar properties: AzureBackupRecoveryPointResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPoint """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'AzureBackupRecoveryPoint'}, - } - - def __init__( - self, - *, - properties: Optional["AzureBackupRecoveryPoint"] = None, - **kwargs - ): - super(AzureBackupRecoveryPointResource, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "AzureBackupRecoveryPoint"}, + } + + def __init__(self, *, properties: Optional["_models.AzureBackupRecoveryPoint"] = None, **kwargs): + """ + :keyword properties: AzureBackupRecoveryPointResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPoint + """ + super().__init__(**kwargs) self.properties = properties class AzureBackupRecoveryPointResourceList(DppResourceList): """Azure backup recoveryPoint resource list. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[AzureBackupRecoveryPointResource]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[AzureBackupRecoveryPointResource]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["AzureBackupRecoveryPointResource"]] = None, + value: Optional[List["_models.AzureBackupRecoveryPointResource"]] = None, **kwargs ): - super(AzureBackupRecoveryPointResourceList, self).__init__(next_link=next_link, **kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource] + """ + super().__init__(next_link=next_link, **kwargs) self.value = value @@ -1138,69 +1304,92 @@ class AzureBackupRecoveryTimeBasedRestoreRequest(AzureBackupRestoreRequest): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - :param recovery_point_time: Required. The recovery time in ISO 8601 format example - - 2020-08-14T17:30:00.0000000Z. - :type recovery_point_time: str + :ivar object_type: Required. + :vartype object_type: str + :ivar restore_target_info: Gets or sets the restore target information. Required. + :vartype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :ivar source_data_store_type: Gets or sets the type of the source data store. Required. Known + values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :vartype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is + being recovered. + :vartype source_resource_id: str + :ivar recovery_point_time: The recovery time in ISO 8601 format example - + 2020-08-14T17:30:00.0000000Z. Required. + :vartype recovery_point_time: str """ _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - 'recovery_point_time': {'required': True}, + "object_type": {"required": True}, + "restore_target_info": {"required": True}, + "source_data_store_type": {"required": True}, + "recovery_point_time": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'recovery_point_time': {'key': 'recoveryPointTime', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, + "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, + "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "recovery_point_time": {"key": "recoveryPointTime", "type": "str"}, } def __init__( self, *, - restore_target_info: "RestoreTargetInfoBase", - source_data_store_type: Union[str, "SourceDataStoreType"], + restore_target_info: "_models.RestoreTargetInfoBase", + source_data_store_type: Union[str, "_models.SourceDataStoreType"], recovery_point_time: str, + source_resource_id: Optional[str] = None, **kwargs ): - super(AzureBackupRecoveryTimeBasedRestoreRequest, self).__init__(restore_target_info=restore_target_info, source_data_store_type=source_data_store_type, **kwargs) - self.object_type = 'AzureBackupRecoveryTimeBasedRestoreRequest' # type: str + """ + :keyword restore_target_info: Gets or sets the restore target information. Required. + :paramtype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :keyword source_data_store_type: Gets or sets the type of the source data store. Required. + Known values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :paramtype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which + is being recovered. + :paramtype source_resource_id: str + :keyword recovery_point_time: The recovery time in ISO 8601 format example - + 2020-08-14T17:30:00.0000000Z. Required. + :paramtype recovery_point_time: str + """ + super().__init__( + restore_target_info=restore_target_info, + source_data_store_type=source_data_store_type, + source_resource_id=source_resource_id, + **kwargs + ) + self.object_type = "AzureBackupRecoveryTimeBasedRestoreRequest" # type: str self.recovery_point_time = recovery_point_time -class AzureBackupRehydrationRequest(msrest.serialization.Model): +class AzureBackupRehydrationRequest(_serialization.Model): """Azure Backup Rehydrate Request. All required parameters must be populated in order to send to Azure. - :param recovery_point_id: Required. Id of the recovery point to be recovered. - :type recovery_point_id: str - :param rehydration_priority: Priority to be used for rehydration. Values High or Standard. - Possible values include: "Invalid", "High", "Standard". - :type rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority - :param rehydration_retention_duration: Required. Retention duration in ISO 8601 format i.e P10D - . - :type rehydration_retention_duration: str + :ivar recovery_point_id: Id of the recovery point to be recovered. Required. + :vartype recovery_point_id: str + :ivar rehydration_priority: Priority to be used for rehydration. Values High or Standard. Known + values are: "Invalid", "High", and "Standard". + :vartype rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority + :ivar rehydration_retention_duration: Retention duration in ISO 8601 format i.e P10D . + Required. + :vartype rehydration_retention_duration: str """ _validation = { - 'recovery_point_id': {'required': True}, - 'rehydration_retention_duration': {'required': True}, + "recovery_point_id": {"required": True}, + "rehydration_retention_duration": {"required": True}, } _attribute_map = { - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - 'rehydration_priority': {'key': 'rehydrationPriority', 'type': 'str'}, - 'rehydration_retention_duration': {'key': 'rehydrationRetentionDuration', 'type': 'str'}, + "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, + "rehydration_priority": {"key": "rehydrationPriority", "type": "str"}, + "rehydration_retention_duration": {"key": "rehydrationRetentionDuration", "type": "str"}, } def __init__( @@ -1208,10 +1397,20 @@ def __init__( *, recovery_point_id: str, rehydration_retention_duration: str, - rehydration_priority: Optional[Union[str, "RehydrationPriority"]] = None, + rehydration_priority: Optional[Union[str, "_models.RehydrationPriority"]] = None, **kwargs ): - super(AzureBackupRehydrationRequest, self).__init__(**kwargs) + """ + :keyword recovery_point_id: Id of the recovery point to be recovered. Required. + :paramtype recovery_point_id: str + :keyword rehydration_priority: Priority to be used for rehydration. Values High or Standard. + Known values are: "Invalid", "High", and "Standard". + :paramtype rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority + :keyword rehydration_retention_duration: Retention duration in ISO 8601 format i.e P10D . + Required. + :paramtype rehydration_retention_duration: str + """ + super().__init__(**kwargs) self.recovery_point_id = recovery_point_id self.rehydration_priority = rehydration_priority self.rehydration_retention_duration = rehydration_retention_duration @@ -1222,92 +1421,118 @@ class AzureBackupRestoreWithRehydrationRequest(AzureBackupRecoveryPointBasedRest All required parameters must be populated in order to send to Azure. - :param object_type: Required. Constant filled by server. - :type object_type: str - :param restore_target_info: Required. Gets or sets the restore target information. - :type restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase - :param source_data_store_type: Required. Gets or sets the type of the source data store. - Possible values include: "ArchiveStore", "SnapshotStore", "VaultStore". - :type source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType - :param recovery_point_id: Required. - :type recovery_point_id: str - :param rehydration_priority: Required. Priority to be used for rehydration. Values High or - Standard. Possible values include: "Invalid", "High", "Standard". - :type rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority - :param rehydration_retention_duration: Required. Retention duration in ISO 8601 format i.e P10D - . - :type rehydration_retention_duration: str + :ivar object_type: Required. + :vartype object_type: str + :ivar restore_target_info: Gets or sets the restore target information. Required. + :vartype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :ivar source_data_store_type: Gets or sets the type of the source data store. Required. Known + values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :vartype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is + being recovered. + :vartype source_resource_id: str + :ivar recovery_point_id: Required. + :vartype recovery_point_id: str + :ivar rehydration_priority: Priority to be used for rehydration. Values High or Standard. + Required. Known values are: "Invalid", "High", and "Standard". + :vartype rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority + :ivar rehydration_retention_duration: Retention duration in ISO 8601 format i.e P10D . + Required. + :vartype rehydration_retention_duration: str """ _validation = { - 'object_type': {'required': True}, - 'restore_target_info': {'required': True}, - 'source_data_store_type': {'required': True}, - 'recovery_point_id': {'required': True}, - 'rehydration_priority': {'required': True}, - 'rehydration_retention_duration': {'required': True}, + "object_type": {"required": True}, + "restore_target_info": {"required": True}, + "source_data_store_type": {"required": True}, + "recovery_point_id": {"required": True}, + "rehydration_priority": {"required": True}, + "rehydration_retention_duration": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'restore_target_info': {'key': 'restoreTargetInfo', 'type': 'RestoreTargetInfoBase'}, - 'source_data_store_type': {'key': 'sourceDataStoreType', 'type': 'str'}, - 'recovery_point_id': {'key': 'recoveryPointId', 'type': 'str'}, - 'rehydration_priority': {'key': 'rehydrationPriority', 'type': 'str'}, - 'rehydration_retention_duration': {'key': 'rehydrationRetentionDuration', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, + "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, + "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, + "rehydration_priority": {"key": "rehydrationPriority", "type": "str"}, + "rehydration_retention_duration": {"key": "rehydrationRetentionDuration", "type": "str"}, } def __init__( self, *, - restore_target_info: "RestoreTargetInfoBase", - source_data_store_type: Union[str, "SourceDataStoreType"], + restore_target_info: "_models.RestoreTargetInfoBase", + source_data_store_type: Union[str, "_models.SourceDataStoreType"], recovery_point_id: str, - rehydration_priority: Union[str, "RehydrationPriority"], + rehydration_priority: Union[str, "_models.RehydrationPriority"], rehydration_retention_duration: str, + source_resource_id: Optional[str] = None, **kwargs ): - super(AzureBackupRestoreWithRehydrationRequest, self).__init__(restore_target_info=restore_target_info, source_data_store_type=source_data_store_type, recovery_point_id=recovery_point_id, **kwargs) - self.object_type = 'AzureBackupRestoreWithRehydrationRequest' # type: str + """ + :keyword restore_target_info: Gets or sets the restore target information. Required. + :paramtype restore_target_info: ~azure.mgmt.dataprotection.models.RestoreTargetInfoBase + :keyword source_data_store_type: Gets or sets the type of the source data store. Required. + Known values are: "ArchiveStore", "SnapshotStore", and "VaultStore". + :paramtype source_data_store_type: str or ~azure.mgmt.dataprotection.models.SourceDataStoreType + :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which + is being recovered. + :paramtype source_resource_id: str + :keyword recovery_point_id: Required. + :paramtype recovery_point_id: str + :keyword rehydration_priority: Priority to be used for rehydration. Values High or Standard. + Required. Known values are: "Invalid", "High", and "Standard". + :paramtype rehydration_priority: str or ~azure.mgmt.dataprotection.models.RehydrationPriority + :keyword rehydration_retention_duration: Retention duration in ISO 8601 format i.e P10D . + Required. + :paramtype rehydration_retention_duration: str + """ + super().__init__( + restore_target_info=restore_target_info, + source_data_store_type=source_data_store_type, + source_resource_id=source_resource_id, + recovery_point_id=recovery_point_id, + **kwargs + ) + self.object_type = "AzureBackupRestoreWithRehydrationRequest" # type: str self.rehydration_priority = rehydration_priority self.rehydration_retention_duration = rehydration_retention_duration -class BasePolicyRule(msrest.serialization.Model): +class BasePolicyRule(_serialization.Model): """BasePolicy Rule. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBackupRule, AzureRetentionRule. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureBackupRule, AzureRetentionRule All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param object_type: Required. Constant filled by server. - :type object_type: str + :ivar name: Required. + :vartype name: str + :ivar object_type: Required. + :vartype object_type: str """ _validation = { - 'name': {'required': True}, - 'object_type': {'required': True}, + "name": {"required": True}, + "object_type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'AzureBackupRule': 'AzureBackupRule', 'AzureRetentionRule': 'AzureRetentionRule'} - } + _subtype_map = {"object_type": {"AzureBackupRule": "AzureBackupRule", "AzureRetentionRule": "AzureRetentionRule"}} - def __init__( - self, - *, - name: str, - **kwargs - ): - super(BasePolicyRule, self).__init__(**kwargs) + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: Required. + :paramtype name: str + """ + super().__init__(**kwargs) self.name = name self.object_type = None # type: Optional[str] @@ -1317,86 +1542,113 @@ class AzureBackupRule(BasePolicyRule): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param object_type: Required. Constant filled by server. - :type object_type: str - :param backup_parameters: BackupParameters base. - :type backup_parameters: ~azure.mgmt.dataprotection.models.BackupParameters - :param data_store: Required. DataStoreInfo base. - :type data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase - :param trigger: Required. Trigger context. - :type trigger: ~azure.mgmt.dataprotection.models.TriggerContext + :ivar name: Required. + :vartype name: str + :ivar object_type: Required. + :vartype object_type: str + :ivar backup_parameters: BackupParameters base. + :vartype backup_parameters: ~azure.mgmt.dataprotection.models.BackupParameters + :ivar data_store: DataStoreInfo base. Required. + :vartype data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase + :ivar trigger: Trigger context. Required. + :vartype trigger: ~azure.mgmt.dataprotection.models.TriggerContext """ _validation = { - 'name': {'required': True}, - 'object_type': {'required': True}, - 'data_store': {'required': True}, - 'trigger': {'required': True}, + "name": {"required": True}, + "object_type": {"required": True}, + "data_store": {"required": True}, + "trigger": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'backup_parameters': {'key': 'backupParameters', 'type': 'BackupParameters'}, - 'data_store': {'key': 'dataStore', 'type': 'DataStoreInfoBase'}, - 'trigger': {'key': 'trigger', 'type': 'TriggerContext'}, + "name": {"key": "name", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "backup_parameters": {"key": "backupParameters", "type": "BackupParameters"}, + "data_store": {"key": "dataStore", "type": "DataStoreInfoBase"}, + "trigger": {"key": "trigger", "type": "TriggerContext"}, } def __init__( self, *, name: str, - data_store: "DataStoreInfoBase", - trigger: "TriggerContext", - backup_parameters: Optional["BackupParameters"] = None, + data_store: "_models.DataStoreInfoBase", + trigger: "_models.TriggerContext", + backup_parameters: Optional["_models.BackupParameters"] = None, **kwargs ): - super(AzureBackupRule, self).__init__(name=name, **kwargs) - self.object_type = 'AzureBackupRule' # type: str + """ + :keyword name: Required. + :paramtype name: str + :keyword backup_parameters: BackupParameters base. + :paramtype backup_parameters: ~azure.mgmt.dataprotection.models.BackupParameters + :keyword data_store: DataStoreInfo base. Required. + :paramtype data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase + :keyword trigger: Trigger context. Required. + :paramtype trigger: ~azure.mgmt.dataprotection.models.TriggerContext + """ + super().__init__(name=name, **kwargs) + self.object_type = "AzureBackupRule" # type: str self.backup_parameters = backup_parameters self.data_store = data_store self.trigger = trigger -class DataStoreParameters(msrest.serialization.Model): +class AzureMonitorAlertSettings(_serialization.Model): + """Settings for Azure Monitor based alerts. + + :ivar alerts_for_all_job_failures: Known values are: "Enabled" and "Disabled". + :vartype alerts_for_all_job_failures: str or ~azure.mgmt.dataprotection.models.AlertsState + """ + + _attribute_map = { + "alerts_for_all_job_failures": {"key": "alertsForAllJobFailures", "type": "str"}, + } + + def __init__(self, *, alerts_for_all_job_failures: Optional[Union[str, "_models.AlertsState"]] = None, **kwargs): + """ + :keyword alerts_for_all_job_failures: Known values are: "Enabled" and "Disabled". + :paramtype alerts_for_all_job_failures: str or ~azure.mgmt.dataprotection.models.AlertsState + """ + super().__init__(**kwargs) + self.alerts_for_all_job_failures = alerts_for_all_job_failures + + +class DataStoreParameters(_serialization.Model): """Parameters for DataStore. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureOperationalStoreParameters. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureOperationalStoreParameters All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param data_store_type: Required. type of datastore; Operational/Vault/Archive. Possible values - include: "OperationalStore", "VaultStore", "ArchiveStore". - :type data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values + are: "OperationalStore", "VaultStore", and "ArchiveStore". + :vartype data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes """ _validation = { - 'object_type': {'required': True}, - 'data_store_type': {'required': True}, + "object_type": {"required": True}, + "data_store_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'data_store_type': {'key': 'dataStoreType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "data_store_type": {"key": "dataStoreType", "type": "str"}, } - _subtype_map = { - 'object_type': {'AzureOperationalStoreParameters': 'AzureOperationalStoreParameters'} - } + _subtype_map = {"object_type": {"AzureOperationalStoreParameters": "AzureOperationalStoreParameters"}} - def __init__( - self, - *, - data_store_type: Union[str, "DataStoreTypes"], - **kwargs - ): - super(DataStoreParameters, self).__init__(**kwargs) + def __init__(self, *, data_store_type: Union[str, "_models.DataStoreTypes"], **kwargs): + """ + :keyword data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values + are: "OperationalStore", "VaultStore", and "ArchiveStore". + :paramtype data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes + """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] self.data_store_type = data_store_type @@ -1406,36 +1658,42 @@ class AzureOperationalStoreParameters(DataStoreParameters): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param data_store_type: Required. type of datastore; Operational/Vault/Archive. Possible values - include: "OperationalStore", "VaultStore", "ArchiveStore". - :type data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes - :param resource_group_id: Gets or sets the Snapshot Resource Group Uri. - :type resource_group_id: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values + are: "OperationalStore", "VaultStore", and "ArchiveStore". + :vartype data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes + :ivar resource_group_id: Gets or sets the Snapshot Resource Group Uri. + :vartype resource_group_id: str """ _validation = { - 'object_type': {'required': True}, - 'data_store_type': {'required': True}, + "object_type": {"required": True}, + "data_store_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'data_store_type': {'key': 'dataStoreType', 'type': 'str'}, - 'resource_group_id': {'key': 'resourceGroupId', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "data_store_type": {"key": "dataStoreType", "type": "str"}, + "resource_group_id": {"key": "resourceGroupId", "type": "str"}, } def __init__( self, *, - data_store_type: Union[str, "DataStoreTypes"], + data_store_type: Union[str, "_models.DataStoreTypes"], resource_group_id: Optional[str] = None, **kwargs ): - super(AzureOperationalStoreParameters, self).__init__(data_store_type=data_store_type, **kwargs) - self.object_type = 'AzureOperationalStoreParameters' # type: str + """ + :keyword data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values + are: "OperationalStore", "VaultStore", and "ArchiveStore". + :paramtype data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes + :keyword resource_group_id: Gets or sets the Snapshot Resource Group Uri. + :paramtype resource_group_id: str + """ + super().__init__(data_store_type=data_store_type, **kwargs) + self.object_type = "AzureOperationalStoreParameters" # type: str self.resource_group_id = resource_group_id @@ -1444,98 +1702,96 @@ class AzureRetentionRule(BasePolicyRule): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param object_type: Required. Constant filled by server. - :type object_type: str - :param is_default: - :type is_default: bool - :param lifecycles: Required. - :type lifecycles: list[~azure.mgmt.dataprotection.models.SourceLifeCycle] + :ivar name: Required. + :vartype name: str + :ivar object_type: Required. + :vartype object_type: str + :ivar is_default: + :vartype is_default: bool + :ivar lifecycles: Required. + :vartype lifecycles: list[~azure.mgmt.dataprotection.models.SourceLifeCycle] """ _validation = { - 'name': {'required': True}, - 'object_type': {'required': True}, - 'lifecycles': {'required': True}, + "name": {"required": True}, + "object_type": {"required": True}, + "lifecycles": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'lifecycles': {'key': 'lifecycles', 'type': '[SourceLifeCycle]'}, + "name": {"key": "name", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "is_default": {"key": "isDefault", "type": "bool"}, + "lifecycles": {"key": "lifecycles", "type": "[SourceLifeCycle]"}, } def __init__( - self, - *, - name: str, - lifecycles: List["SourceLifeCycle"], - is_default: Optional[bool] = None, - **kwargs + self, *, name: str, lifecycles: List["_models.SourceLifeCycle"], is_default: Optional[bool] = None, **kwargs ): - super(AzureRetentionRule, self).__init__(name=name, **kwargs) - self.object_type = 'AzureRetentionRule' # type: str + """ + :keyword name: Required. + :paramtype name: str + :keyword is_default: + :paramtype is_default: bool + :keyword lifecycles: Required. + :paramtype lifecycles: list[~azure.mgmt.dataprotection.models.SourceLifeCycle] + """ + super().__init__(name=name, **kwargs) + self.object_type = "AzureRetentionRule" # type: str self.is_default = is_default self.lifecycles = lifecycles -class BackupCriteria(msrest.serialization.Model): +class BackupCriteria(_serialization.Model): """BackupCriteria base class. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ScheduleBasedBackupCriteria. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ScheduleBasedBackupCriteria All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'ScheduleBasedBackupCriteria': 'ScheduleBasedBackupCriteria'} - } + _subtype_map = {"object_type": {"ScheduleBasedBackupCriteria": "ScheduleBasedBackupCriteria"}} - def __init__( - self, - **kwargs - ): - super(BackupCriteria, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] -class BackupInstance(msrest.serialization.Model): +class BackupInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Backup Instance. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param friendly_name: Gets or sets the Backup Instance friendly name. - :type friendly_name: str - :param data_source_info: Required. Gets or sets the data source information. - :type data_source_info: ~azure.mgmt.dataprotection.models.Datasource - :param data_source_set_info: Gets or sets the data source set information. - :type data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet - :param policy_info: Required. Gets or sets the policy information. - :type policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :ivar friendly_name: Gets or sets the Backup Instance friendly name. + :vartype friendly_name: str + :ivar data_source_info: Gets or sets the data source information. Required. + :vartype data_source_info: ~azure.mgmt.dataprotection.models.Datasource + :ivar data_source_set_info: Gets or sets the data source set information. + :vartype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :ivar policy_info: Gets or sets the policy information. Required. + :vartype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo :ivar protection_status: Specifies the protection status of the resource. :vartype protection_status: ~azure.mgmt.dataprotection.models.ProtectionStatusDetails - :ivar current_protection_state: Specifies the current protection state of the resource. - Possible values include: "Invalid", "NotProtected", "ConfiguringProtection", - "ProtectionConfigured", "BackupSchedulesSuspended", "RetentionSchedulesSuspended", - "ProtectionStopped", "ProtectionError", "ConfiguringProtectionFailed", "SoftDeleting", - "SoftDeleted", "UpdatingProtection". + :ivar current_protection_state: Specifies the current protection state of the resource. Known + values are: "Invalid", "NotProtected", "ConfiguringProtection", "ProtectionConfigured", + "BackupSchedulesSuspended", "RetentionSchedulesSuspended", "ProtectionStopped", + "ProtectionError", "ConfiguringProtectionFailed", "SoftDeleting", "SoftDeleted", and + "UpdatingProtection". :vartype current_protection_state: str or ~azure.mgmt.dataprotection.models.CurrentProtectionState :ivar protection_error_details: Specifies the protection error of the resource. @@ -1543,48 +1799,73 @@ class BackupInstance(msrest.serialization.Model): :ivar provisioning_state: Specifies the provisioning state of the resource i.e. provisioning/updating/Succeeded/Failed. :vartype provisioning_state: str - :param datasource_auth_credentials: Credentials to use to authenticate with data source + :ivar datasource_auth_credentials: Credentials to use to authenticate with data source provider. - :type datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials - :param object_type: Required. - :type object_type: str + :vartype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + :ivar validation_type: Specifies the type of validation. In case of DeepValidation, all + validations from /validateForBackup API will run again. Known values are: "ShallowValidation" + and "DeepValidation". + :vartype validation_type: str or ~azure.mgmt.dataprotection.models.ValidationType + :ivar object_type: Required. + :vartype object_type: str """ _validation = { - 'data_source_info': {'required': True}, - 'policy_info': {'required': True}, - 'protection_status': {'readonly': True}, - 'current_protection_state': {'readonly': True}, - 'protection_error_details': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'object_type': {'required': True}, + "data_source_info": {"required": True}, + "policy_info": {"required": True}, + "protection_status": {"readonly": True}, + "current_protection_state": {"readonly": True}, + "protection_error_details": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "object_type": {"required": True}, } _attribute_map = { - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'data_source_info': {'key': 'dataSourceInfo', 'type': 'Datasource'}, - 'data_source_set_info': {'key': 'dataSourceSetInfo', 'type': 'DatasourceSet'}, - 'policy_info': {'key': 'policyInfo', 'type': 'PolicyInfo'}, - 'protection_status': {'key': 'protectionStatus', 'type': 'ProtectionStatusDetails'}, - 'current_protection_state': {'key': 'currentProtectionState', 'type': 'str'}, - 'protection_error_details': {'key': 'protectionErrorDetails', 'type': 'UserFacingError'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'datasource_auth_credentials': {'key': 'datasourceAuthCredentials', 'type': 'AuthCredentials'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, + "friendly_name": {"key": "friendlyName", "type": "str"}, + "data_source_info": {"key": "dataSourceInfo", "type": "Datasource"}, + "data_source_set_info": {"key": "dataSourceSetInfo", "type": "DatasourceSet"}, + "policy_info": {"key": "policyInfo", "type": "PolicyInfo"}, + "protection_status": {"key": "protectionStatus", "type": "ProtectionStatusDetails"}, + "current_protection_state": {"key": "currentProtectionState", "type": "str"}, + "protection_error_details": {"key": "protectionErrorDetails", "type": "UserFacingError"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "datasource_auth_credentials": {"key": "datasourceAuthCredentials", "type": "AuthCredentials"}, + "validation_type": {"key": "validationType", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, } def __init__( self, *, - data_source_info: "Datasource", - policy_info: "PolicyInfo", + data_source_info: "_models.Datasource", + policy_info: "_models.PolicyInfo", object_type: str, friendly_name: Optional[str] = None, - data_source_set_info: Optional["DatasourceSet"] = None, - datasource_auth_credentials: Optional["AuthCredentials"] = None, + data_source_set_info: Optional["_models.DatasourceSet"] = None, + datasource_auth_credentials: Optional["_models.AuthCredentials"] = None, + validation_type: Optional[Union[str, "_models.ValidationType"]] = None, **kwargs ): - super(BackupInstance, self).__init__(**kwargs) + """ + :keyword friendly_name: Gets or sets the Backup Instance friendly name. + :paramtype friendly_name: str + :keyword data_source_info: Gets or sets the data source information. Required. + :paramtype data_source_info: ~azure.mgmt.dataprotection.models.Datasource + :keyword data_source_set_info: Gets or sets the data source set information. + :paramtype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :keyword policy_info: Gets or sets the policy information. Required. + :paramtype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :keyword datasource_auth_credentials: Credentials to use to authenticate with data source + provider. + :paramtype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + :keyword validation_type: Specifies the type of validation. In case of DeepValidation, all + validations from /validateForBackup API will run again. Known values are: "ShallowValidation" + and "DeepValidation". + :paramtype validation_type: str or ~azure.mgmt.dataprotection.models.ValidationType + :keyword object_type: Required. + :paramtype object_type: str + """ + super().__init__(**kwargs) self.friendly_name = friendly_name self.data_source_info = data_source_info self.data_source_set_info = data_source_set_info @@ -1594,113 +1875,170 @@ def __init__( self.protection_error_details = None self.provisioning_state = None self.datasource_auth_credentials = datasource_auth_credentials + self.validation_type = validation_type self.object_type = object_type -class BackupInstanceResource(DppResource): +class DppProxyResource(_serialization.Model): + """DppProxyResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Proxy Resource Id represents the complete path to the resource. + :vartype id: str + :ivar name: Proxy Resource name associated with the resource. + :vartype name: str + :ivar type: Proxy Resource type represents the complete path of the form + Namespace/ResourceType/ResourceType/... + :vartype type: str + :ivar tags: Proxy Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Proxy Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = tags + self.system_data = None + + +class BackupInstanceResource(DppProxyResource): """BackupInstance Resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id represents the complete path to the resource. + :ivar id: Proxy Resource Id represents the complete path to the resource. :vartype id: str - :ivar name: Resource name associated with the resource. + :ivar name: Proxy Resource name associated with the resource. :vartype name: str - :ivar type: Resource type represents the complete path of the form + :ivar type: Proxy Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/... :vartype type: str + :ivar tags: Proxy Resource tags. + :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: BackupInstanceResource properties. - :type properties: ~azure.mgmt.dataprotection.models.BackupInstance + :ivar properties: BackupInstanceResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.BackupInstance """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'BackupInstance'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "BackupInstance"}, } def __init__( - self, - *, - properties: Optional["BackupInstance"] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.BackupInstance"] = None, **kwargs ): - super(BackupInstanceResource, self).__init__(**kwargs) + """ + :keyword tags: Proxy Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: BackupInstanceResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.BackupInstance + """ + super().__init__(tags=tags, **kwargs) self.properties = properties class BackupInstanceResourceList(DppResourceList): """BackupInstance Resource list response. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.BackupInstanceResource] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BackupInstanceResource]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[BackupInstanceResource]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["BackupInstanceResource"]] = None, + value: Optional[List["_models.BackupInstanceResource"]] = None, **kwargs ): - super(BackupInstanceResourceList, self).__init__(next_link=next_link, **kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.BackupInstanceResource] + """ + super().__init__(next_link=next_link, **kwargs) self.value = value -class BaseBackupPolicy(msrest.serialization.Model): +class BaseBackupPolicy(_serialization.Model): """BackupPolicy base. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BackupPolicy. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BackupPolicy All required parameters must be populated in order to send to Azure. - :param datasource_types: Required. Type of datasource for the backup management. - :type datasource_types: list[str] - :param object_type: Required. Constant filled by server. - :type object_type: str + :ivar datasource_types: Type of datasource for the backup management. Required. + :vartype datasource_types: list[str] + :ivar object_type: Required. + :vartype object_type: str """ _validation = { - 'datasource_types': {'required': True}, - 'object_type': {'required': True}, + "datasource_types": {"required": True}, + "object_type": {"required": True}, } _attribute_map = { - 'datasource_types': {'key': 'datasourceTypes', 'type': '[str]'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, + "datasource_types": {"key": "datasourceTypes", "type": "[str]"}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'BackupPolicy': 'BackupPolicy'} - } + _subtype_map = {"object_type": {"BackupPolicy": "BackupPolicy"}} - def __init__( - self, - *, - datasource_types: List[str], - **kwargs - ): - super(BaseBackupPolicy, self).__init__(**kwargs) + def __init__(self, *, datasource_types: List[str], **kwargs): + """ + :keyword datasource_types: Type of datasource for the backup management. Required. + :paramtype datasource_types: list[str] + """ + super().__init__(**kwargs) self.datasource_types = datasource_types self.object_type = None # type: Optional[str] @@ -1710,135 +2048,161 @@ class BackupPolicy(BaseBackupPolicy): All required parameters must be populated in order to send to Azure. - :param datasource_types: Required. Type of datasource for the backup management. - :type datasource_types: list[str] - :param object_type: Required. Constant filled by server. - :type object_type: str - :param policy_rules: Required. Policy rule dictionary that contains rules for each backuptype - i.e Full/Incremental/Logs etc. - :type policy_rules: list[~azure.mgmt.dataprotection.models.BasePolicyRule] + :ivar datasource_types: Type of datasource for the backup management. Required. + :vartype datasource_types: list[str] + :ivar object_type: Required. + :vartype object_type: str + :ivar policy_rules: Policy rule dictionary that contains rules for each backuptype i.e + Full/Incremental/Logs etc. Required. + :vartype policy_rules: list[~azure.mgmt.dataprotection.models.BasePolicyRule] """ _validation = { - 'datasource_types': {'required': True}, - 'object_type': {'required': True}, - 'policy_rules': {'required': True}, + "datasource_types": {"required": True}, + "object_type": {"required": True}, + "policy_rules": {"required": True}, } _attribute_map = { - 'datasource_types': {'key': 'datasourceTypes', 'type': '[str]'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'policy_rules': {'key': 'policyRules', 'type': '[BasePolicyRule]'}, - } - - def __init__( - self, - *, - datasource_types: List[str], - policy_rules: List["BasePolicyRule"], - **kwargs - ): - super(BackupPolicy, self).__init__(datasource_types=datasource_types, **kwargs) - self.object_type = 'BackupPolicy' # type: str + "datasource_types": {"key": "datasourceTypes", "type": "[str]"}, + "object_type": {"key": "objectType", "type": "str"}, + "policy_rules": {"key": "policyRules", "type": "[BasePolicyRule]"}, + } + + def __init__(self, *, datasource_types: List[str], policy_rules: List["_models.BasePolicyRule"], **kwargs): + """ + :keyword datasource_types: Type of datasource for the backup management. Required. + :paramtype datasource_types: list[str] + :keyword policy_rules: Policy rule dictionary that contains rules for each backuptype i.e + Full/Incremental/Logs etc. Required. + :paramtype policy_rules: list[~azure.mgmt.dataprotection.models.BasePolicyRule] + """ + super().__init__(datasource_types=datasource_types, **kwargs) + self.object_type = "BackupPolicy" # type: str self.policy_rules = policy_rules -class BackupSchedule(msrest.serialization.Model): +class BackupSchedule(_serialization.Model): """Schedule for backup. All required parameters must be populated in order to send to Azure. - :param repeating_time_intervals: Required. ISO 8601 repeating time interval format. - :type repeating_time_intervals: list[str] - :param time_zone: Time zone for a schedule. Example: Pacific Standard Time. - :type time_zone: str + :ivar repeating_time_intervals: ISO 8601 repeating time interval format. Required. + :vartype repeating_time_intervals: list[str] + :ivar time_zone: Time zone for a schedule. Example: Pacific Standard Time. + :vartype time_zone: str """ _validation = { - 'repeating_time_intervals': {'required': True}, + "repeating_time_intervals": {"required": True}, } _attribute_map = { - 'repeating_time_intervals': {'key': 'repeatingTimeIntervals', 'type': '[str]'}, - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - } - - def __init__( - self, - *, - repeating_time_intervals: List[str], - time_zone: Optional[str] = None, - **kwargs - ): - super(BackupSchedule, self).__init__(**kwargs) + "repeating_time_intervals": {"key": "repeatingTimeIntervals", "type": "[str]"}, + "time_zone": {"key": "timeZone", "type": "str"}, + } + + def __init__(self, *, repeating_time_intervals: List[str], time_zone: Optional[str] = None, **kwargs): + """ + :keyword repeating_time_intervals: ISO 8601 repeating time interval format. Required. + :paramtype repeating_time_intervals: list[str] + :keyword time_zone: Time zone for a schedule. Example: Pacific Standard Time. + :paramtype time_zone: str + """ + super().__init__(**kwargs) self.repeating_time_intervals = repeating_time_intervals self.time_zone = time_zone -class BackupVault(msrest.serialization.Model): +class BackupVault(_serialization.Model): """Backup Vault. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar provisioning_state: Provisioning state of the BackupVault resource. Possible values - include: "Failed", "Provisioning", "Succeeded", "Unknown", "Updating". + :ivar monitoring_settings: Monitoring Settings. + :vartype monitoring_settings: ~azure.mgmt.dataprotection.models.MonitoringSettings + :ivar provisioning_state: Provisioning state of the BackupVault resource. Known values are: + "Failed", "Provisioning", "Succeeded", "Unknown", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.dataprotection.models.ProvisioningState - :ivar resource_move_state: Resource move state for backup vault. Possible values include: - "Unknown", "InProgress", "PrepareFailed", "CommitFailed", "Failed", "PrepareTimedout", - "CommitTimedout", "CriticalFailure", "PartialSuccess", "MoveSucceeded". + :ivar resource_move_state: Resource move state for backup vault. Known values are: "Unknown", + "InProgress", "PrepareFailed", "CommitFailed", "Failed", "PrepareTimedout", "CommitTimedout", + "CriticalFailure", "PartialSuccess", and "MoveSucceeded". :vartype resource_move_state: str or ~azure.mgmt.dataprotection.models.ResourceMoveState :ivar resource_move_details: Resource move details for backup vault. :vartype resource_move_details: ~azure.mgmt.dataprotection.models.ResourceMoveDetails - :param storage_settings: Required. Storage Settings. - :type storage_settings: list[~azure.mgmt.dataprotection.models.StorageSetting] + :ivar security_settings: Security Settings. + :vartype security_settings: ~azure.mgmt.dataprotection.models.SecuritySettings + :ivar storage_settings: Storage Settings. Required. + :vartype storage_settings: list[~azure.mgmt.dataprotection.models.StorageSetting] + :ivar is_vault_protected_by_resource_guard: Is vault protected by resource guard. + :vartype is_vault_protected_by_resource_guard: bool """ _validation = { - 'provisioning_state': {'readonly': True}, - 'resource_move_state': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'storage_settings': {'required': True}, + "provisioning_state": {"readonly": True}, + "resource_move_state": {"readonly": True}, + "resource_move_details": {"readonly": True}, + "storage_settings": {"required": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_move_state': {'key': 'resourceMoveState', 'type': 'str'}, - 'resource_move_details': {'key': 'resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'storage_settings': {'key': 'storageSettings', 'type': '[StorageSetting]'}, + "monitoring_settings": {"key": "monitoringSettings", "type": "MonitoringSettings"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "resource_move_state": {"key": "resourceMoveState", "type": "str"}, + "resource_move_details": {"key": "resourceMoveDetails", "type": "ResourceMoveDetails"}, + "security_settings": {"key": "securitySettings", "type": "SecuritySettings"}, + "storage_settings": {"key": "storageSettings", "type": "[StorageSetting]"}, + "is_vault_protected_by_resource_guard": {"key": "isVaultProtectedByResourceGuard", "type": "bool"}, } def __init__( self, *, - storage_settings: List["StorageSetting"], + storage_settings: List["_models.StorageSetting"], + monitoring_settings: Optional["_models.MonitoringSettings"] = None, + security_settings: Optional["_models.SecuritySettings"] = None, + is_vault_protected_by_resource_guard: Optional[bool] = None, **kwargs ): - super(BackupVault, self).__init__(**kwargs) + """ + :keyword monitoring_settings: Monitoring Settings. + :paramtype monitoring_settings: ~azure.mgmt.dataprotection.models.MonitoringSettings + :keyword security_settings: Security Settings. + :paramtype security_settings: ~azure.mgmt.dataprotection.models.SecuritySettings + :keyword storage_settings: Storage Settings. Required. + :paramtype storage_settings: list[~azure.mgmt.dataprotection.models.StorageSetting] + :keyword is_vault_protected_by_resource_guard: Is vault protected by resource guard. + :paramtype is_vault_protected_by_resource_guard: bool + """ + super().__init__(**kwargs) + self.monitoring_settings = monitoring_settings self.provisioning_state = None self.resource_move_state = None self.resource_move_details = None + self.security_settings = security_settings self.storage_settings = storage_settings + self.is_vault_protected_by_resource_guard = is_vault_protected_by_resource_guard -class DppTrackedResource(msrest.serialization.Model): +class DppTrackedResource(_serialization.Model): """DppTrackedResource. Variables are only populated by the server, and will be ignored when sending a request. - :param e_tag: Optional ETag. - :type e_tag: str + :ivar e_tag: Optional ETag. + :vartype e_tag: str :ivar id: Resource Id represents the complete path to the resource. :vartype id: str - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param location: Resource location. - :type location: str + :ivar identity: Input Managed Identity Details. + :vartype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :ivar location: Resource location. + :vartype location: str :ivar name: Resource name associated with the resource. :vartype name: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: Resource tags. + :vartype tags: dict[str, str] :ivar type: Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/... :vartype type: str @@ -1847,33 +2211,43 @@ class DppTrackedResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "e_tag": {"key": "eTag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "identity": {"key": "identity", "type": "DppIdentityDetails"}, + "location": {"key": "location", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, e_tag: Optional[str] = None, - identity: Optional["DppIdentityDetails"] = None, + identity: Optional["_models.DppIdentityDetails"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): - super(DppTrackedResource, self).__init__(**kwargs) + """ + :keyword e_tag: Optional ETag. + :paramtype e_tag: str + :keyword identity: Input Managed Identity Details. + :paramtype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.e_tag = e_tag self.id = None self.identity = identity @@ -1891,84 +2265,99 @@ class BackupVaultResource(DppTrackedResource): All required parameters must be populated in order to send to Azure. - :param e_tag: Optional ETag. - :type e_tag: str + :ivar e_tag: Optional ETag. + :vartype e_tag: str :ivar id: Resource Id represents the complete path to the resource. :vartype id: str - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param location: Resource location. - :type location: str + :ivar identity: Input Managed Identity Details. + :vartype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :ivar location: Resource location. + :vartype location: str :ivar name: Resource name associated with the resource. :vartype name: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: Resource tags. + :vartype tags: dict[str, str] :ivar type: Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/... :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: Required. BackupVaultResource properties. - :type properties: ~azure.mgmt.dataprotection.models.BackupVault + :ivar properties: BackupVaultResource properties. Required. + :vartype properties: ~azure.mgmt.dataprotection.models.BackupVault """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'BackupVault'}, + "e_tag": {"key": "eTag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "identity": {"key": "identity", "type": "DppIdentityDetails"}, + "location": {"key": "location", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "BackupVault"}, } def __init__( self, *, - properties: "BackupVault", + properties: "_models.BackupVault", e_tag: Optional[str] = None, - identity: Optional["DppIdentityDetails"] = None, + identity: Optional["_models.DppIdentityDetails"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): - super(BackupVaultResource, self).__init__(e_tag=e_tag, identity=identity, location=location, tags=tags, **kwargs) + """ + :keyword e_tag: Optional ETag. + :paramtype e_tag: str + :keyword identity: Input Managed Identity Details. + :paramtype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: BackupVaultResource properties. Required. + :paramtype properties: ~azure.mgmt.dataprotection.models.BackupVault + """ + super().__init__(e_tag=e_tag, identity=identity, location=location, tags=tags, **kwargs) self.properties = properties class BackupVaultResourceList(DppResourceList): """List of BackupVault resources. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.BackupVaultResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.BackupVaultResource] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BackupVaultResource]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[BackupVaultResource]"}, } def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["BackupVaultResource"]] = None, - **kwargs + self, *, next_link: Optional[str] = None, value: Optional[List["_models.BackupVaultResource"]] = None, **kwargs ): - super(BackupVaultResourceList, self).__init__(next_link=next_link, **kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.BackupVaultResource] + """ + super().__init__(next_link=next_link, **kwargs) self.value = value @@ -1986,102 +2375,108 @@ class BaseBackupPolicyResource(DppResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: BaseBackupPolicyResource properties. - :type properties: ~azure.mgmt.dataprotection.models.BaseBackupPolicy + :ivar properties: BaseBackupPolicyResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.BaseBackupPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'BaseBackupPolicy'}, - } - - def __init__( - self, - *, - properties: Optional["BaseBackupPolicy"] = None, - **kwargs - ): - super(BaseBackupPolicyResource, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "BaseBackupPolicy"}, + } + + def __init__(self, *, properties: Optional["_models.BaseBackupPolicy"] = None, **kwargs): + """ + :keyword properties: BaseBackupPolicyResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.BaseBackupPolicy + """ + super().__init__(**kwargs) self.properties = properties class BaseBackupPolicyResourceList(DppResourceList): """List of BaseBackupPolicy resources. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.BaseBackupPolicyResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.BaseBackupPolicyResource] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BaseBackupPolicyResource]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[BaseBackupPolicyResource]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["BaseBackupPolicyResource"]] = None, + value: Optional[List["_models.BaseBackupPolicyResource"]] = None, **kwargs ): - super(BaseBackupPolicyResourceList, self).__init__(next_link=next_link, **kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.BaseBackupPolicyResource] + """ + super().__init__(next_link=next_link, **kwargs) self.value = value -class CheckNameAvailabilityRequest(msrest.serialization.Model): +class CheckNameAvailabilityRequest(_serialization.Model): """CheckNameAvailability Request. - :param name: Resource name for which availability needs to be checked. - :type name: str - :param type: Describes the Resource type: Microsoft.DataProtection/BackupVaults. - :type type: str + :ivar name: Resource name for which availability needs to be checked. + :vartype name: str + :ivar type: Describes the Resource type: Microsoft.DataProtection/BackupVaults. + :vartype type: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): + """ + :keyword name: Resource name for which availability needs to be checked. + :paramtype name: str + :keyword type: Describes the Resource type: Microsoft.DataProtection/BackupVaults. + :paramtype type: str + """ + super().__init__(**kwargs) self.name = name self.type = type -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """CheckNameAvailability Result. - :param message: Gets or sets the message. - :type message: str - :param name_available: Gets or sets a value indicating whether [name available]. - :type name_available: bool - :param reason: Gets or sets the reason. - :type reason: str + :ivar message: Gets or sets the message. + :vartype message: str + :ivar name_available: Gets or sets a value indicating whether [name available]. + :vartype name_available: bool + :ivar reason: Gets or sets the reason. + :vartype reason: str """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -2092,30 +2487,38 @@ def __init__( reason: Optional[str] = None, **kwargs ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + """ + :keyword message: Gets or sets the message. + :paramtype message: str + :keyword name_available: Gets or sets a value indicating whether [name available]. + :paramtype name_available: bool + :keyword reason: Gets or sets the reason. + :paramtype reason: str + """ + super().__init__(**kwargs) self.message = message self.name_available = name_available self.reason = reason -class ClientDiscoveryDisplay(msrest.serialization.Model): +class ClientDiscoveryDisplay(_serialization.Model): """Localized display information of an operation. - :param description: Description of the operation having details of what operation is about. - :type description: str - :param operation: Operations Name itself. - :type operation: str - :param provider: Name of the provider for display purposes. - :type provider: str - :param resource: ResourceType for which this Operation can be performed. - :type resource: str + :ivar description: Description of the operation having details of what operation is about. + :vartype description: str + :ivar operation: Operations Name itself. + :vartype operation: str + :ivar provider: Name of the provider for display purposes. + :vartype provider: str + :ivar resource: ResourceType for which this Operation can be performed. + :vartype resource: str """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, } def __init__( @@ -2127,28 +2530,38 @@ def __init__( resource: Optional[str] = None, **kwargs ): - super(ClientDiscoveryDisplay, self).__init__(**kwargs) + """ + :keyword description: Description of the operation having details of what operation is about. + :paramtype description: str + :keyword operation: Operations Name itself. + :paramtype operation: str + :keyword provider: Name of the provider for display purposes. + :paramtype provider: str + :keyword resource: ResourceType for which this Operation can be performed. + :paramtype resource: str + """ + super().__init__(**kwargs) self.description = description self.operation = operation self.provider = provider self.resource = resource -class ClientDiscoveryForLogSpecification(msrest.serialization.Model): +class ClientDiscoveryForLogSpecification(_serialization.Model): """Class to represent shoebox log specification in json client discovery. - :param blob_duration: blob duration of shoebox log specification. - :type blob_duration: str - :param display_name: Localized display name. - :type display_name: str - :param name: Name for shoebox log specification. - :type name: str + :ivar blob_duration: blob duration of shoebox log specification. + :vartype blob_duration: str + :ivar display_name: Localized display name. + :vartype display_name: str + :ivar name: Name for shoebox log specification. + :vartype name: str """ _attribute_map = { - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -2159,117 +2572,148 @@ def __init__( name: Optional[str] = None, **kwargs ): - super(ClientDiscoveryForLogSpecification, self).__init__(**kwargs) + """ + :keyword blob_duration: blob duration of shoebox log specification. + :paramtype blob_duration: str + :keyword display_name: Localized display name. + :paramtype display_name: str + :keyword name: Name for shoebox log specification. + :paramtype name: str + """ + super().__init__(**kwargs) self.blob_duration = blob_duration self.display_name = display_name self.name = name -class ClientDiscoveryForProperties(msrest.serialization.Model): +class ClientDiscoveryForProperties(_serialization.Model): """Class to represent shoebox properties in json client discovery. - :param service_specification: Operation properties. - :type service_specification: + :ivar service_specification: Operation properties. + :vartype service_specification: ~azure.mgmt.dataprotection.models.ClientDiscoveryForServiceSpecification """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ClientDiscoveryForServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ClientDiscoveryForServiceSpecification"}, } def __init__( - self, - *, - service_specification: Optional["ClientDiscoveryForServiceSpecification"] = None, - **kwargs + self, *, service_specification: Optional["_models.ClientDiscoveryForServiceSpecification"] = None, **kwargs ): - super(ClientDiscoveryForProperties, self).__init__(**kwargs) + """ + :keyword service_specification: Operation properties. + :paramtype service_specification: + ~azure.mgmt.dataprotection.models.ClientDiscoveryForServiceSpecification + """ + super().__init__(**kwargs) self.service_specification = service_specification -class ClientDiscoveryForServiceSpecification(msrest.serialization.Model): +class ClientDiscoveryForServiceSpecification(_serialization.Model): """Class to represent shoebox service specification in json client discovery. - :param log_specifications: List of log specifications of this operation. - :type log_specifications: + :ivar log_specifications: List of log specifications of this operation. + :vartype log_specifications: list[~azure.mgmt.dataprotection.models.ClientDiscoveryForLogSpecification] """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[ClientDiscoveryForLogSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[ClientDiscoveryForLogSpecification]"}, } def __init__( - self, - *, - log_specifications: Optional[List["ClientDiscoveryForLogSpecification"]] = None, - **kwargs + self, *, log_specifications: Optional[List["_models.ClientDiscoveryForLogSpecification"]] = None, **kwargs ): - super(ClientDiscoveryForServiceSpecification, self).__init__(**kwargs) + """ + :keyword log_specifications: List of log specifications of this operation. + :paramtype log_specifications: + list[~azure.mgmt.dataprotection.models.ClientDiscoveryForLogSpecification] + """ + super().__init__(**kwargs) self.log_specifications = log_specifications -class ClientDiscoveryResponse(msrest.serialization.Model): +class ClientDiscoveryResponse(_serialization.Model): """Operations List response which contains list of available APIs. - :param next_link: Link to the next chunk of Response. - :type next_link: str - :param value: List of available operations. - :type value: list[~azure.mgmt.dataprotection.models.ClientDiscoveryValueForSingleApi] + :ivar next_link: Link to the next chunk of Response. + :vartype next_link: str + :ivar value: List of available operations. + :vartype value: list[~azure.mgmt.dataprotection.models.ClientDiscoveryValueForSingleApi] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ClientDiscoveryValueForSingleApi]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ClientDiscoveryValueForSingleApi]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["ClientDiscoveryValueForSingleApi"]] = None, + value: Optional[List["_models.ClientDiscoveryValueForSingleApi"]] = None, **kwargs ): - super(ClientDiscoveryResponse, self).__init__(**kwargs) + """ + :keyword next_link: Link to the next chunk of Response. + :paramtype next_link: str + :keyword value: List of available operations. + :paramtype value: list[~azure.mgmt.dataprotection.models.ClientDiscoveryValueForSingleApi] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class ClientDiscoveryValueForSingleApi(msrest.serialization.Model): +class ClientDiscoveryValueForSingleApi(_serialization.Model): """Available operation details. - :param display: Contains the localized display information for this particular operation. - :type display: ~azure.mgmt.dataprotection.models.ClientDiscoveryDisplay - :param name: Name of the Operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param origin: The intended executor of the operation;governs the display of the operation in + :ivar display: Contains the localized display information for this particular operation. + :vartype display: ~azure.mgmt.dataprotection.models.ClientDiscoveryDisplay + :ivar name: Name of the Operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar origin: The intended executor of the operation;governs the display of the operation in the RBAC UX and the audit logs UX. - :type origin: str - :param properties: Properties for the given operation. - :type properties: ~azure.mgmt.dataprotection.models.ClientDiscoveryForProperties + :vartype origin: str + :ivar properties: Properties for the given operation. + :vartype properties: ~azure.mgmt.dataprotection.models.ClientDiscoveryForProperties """ _attribute_map = { - 'display': {'key': 'display', 'type': 'ClientDiscoveryDisplay'}, - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ClientDiscoveryForProperties'}, + "display": {"key": "display", "type": "ClientDiscoveryDisplay"}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "ClientDiscoveryForProperties"}, } def __init__( self, *, - display: Optional["ClientDiscoveryDisplay"] = None, + display: Optional["_models.ClientDiscoveryDisplay"] = None, name: Optional[str] = None, is_data_action: Optional[bool] = None, origin: Optional[str] = None, - properties: Optional["ClientDiscoveryForProperties"] = None, + properties: Optional["_models.ClientDiscoveryForProperties"] = None, **kwargs ): - super(ClientDiscoveryValueForSingleApi, self).__init__(**kwargs) + """ + :keyword display: Contains the localized display information for this particular operation. + :paramtype display: ~azure.mgmt.dataprotection.models.ClientDiscoveryDisplay + :keyword name: Name of the Operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword origin: The intended executor of the operation;governs the display of the operation in + the RBAC UX and the audit logs UX. + :paramtype origin: str + :keyword properties: Properties for the given operation. + :paramtype properties: ~azure.mgmt.dataprotection.models.ClientDiscoveryForProperties + """ + super().__init__(**kwargs) self.display = display self.name = name self.is_data_action = is_data_action @@ -2277,36 +2721,37 @@ def __init__( self.properties = properties -class CopyOption(msrest.serialization.Model): +class CopyOption(_serialization.Model): """Options to copy. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CopyOnExpiryOption, CustomCopyOption, ImmediateCopyOption. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CopyOnExpiryOption, CustomCopyOption, ImmediateCopyOption All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } _subtype_map = { - 'object_type': {'CopyOnExpiryOption': 'CopyOnExpiryOption', 'CustomCopyOption': 'CustomCopyOption', 'ImmediateCopyOption': 'ImmediateCopyOption'} + "object_type": { + "CopyOnExpiryOption": "CopyOnExpiryOption", + "CustomCopyOption": "CustomCopyOption", + "ImmediateCopyOption": "ImmediateCopyOption", + } } - def __init__( - self, - **kwargs - ): - super(CopyOption, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -2315,25 +2760,22 @@ class CopyOnExpiryOption(CopyOption): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(CopyOnExpiryOption, self).__init__(**kwargs) - self.object_type = 'CopyOnExpiryOption' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.object_type = "CopyOnExpiryOption" # type: str class CustomCopyOption(CopyOption): @@ -2341,67 +2783,65 @@ class CustomCopyOption(CopyOption): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param duration: Data copied after given timespan. - :type duration: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar duration: Data copied after given timespan. + :vartype duration: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } - def __init__( - self, - *, - duration: Optional[str] = None, - **kwargs - ): - super(CustomCopyOption, self).__init__(**kwargs) - self.object_type = 'CustomCopyOption' # type: str + def __init__(self, *, duration: Optional[str] = None, **kwargs): + """ + :keyword duration: Data copied after given timespan. + :paramtype duration: str + """ + super().__init__(**kwargs) + self.object_type = "CustomCopyOption" # type: str self.duration = duration -class Datasource(msrest.serialization.Model): +class Datasource(_serialization.Model): """Datasource to be backed up. All required parameters must be populated in order to send to Azure. - :param datasource_type: DatasourceType of the resource. - :type datasource_type: str - :param object_type: Type of Datasource object, used to initialize the right inherited type. - :type object_type: str - :param resource_id: Required. Full ARM ID of the resource. For azure resources, this is ARM ID. - For non azure resources, this will be the ID created by backup service via Fabric/Vault. - :type resource_id: str - :param resource_location: Location of datasource. - :type resource_location: str - :param resource_name: Unique identifier of the resource in the context of parent. - :type resource_name: str - :param resource_type: Resource Type of Datasource. - :type resource_type: str - :param resource_uri: Uri of the resource. - :type resource_uri: str + :ivar datasource_type: DatasourceType of the resource. + :vartype datasource_type: str + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + :vartype object_type: str + :ivar resource_id: Full ARM ID of the resource. For azure resources, this is ARM ID. For non + azure resources, this will be the ID created by backup service via Fabric/Vault. Required. + :vartype resource_id: str + :ivar resource_location: Location of datasource. + :vartype resource_location: str + :ivar resource_name: Unique identifier of the resource in the context of parent. + :vartype resource_name: str + :ivar resource_type: Resource Type of Datasource. + :vartype resource_type: str + :ivar resource_uri: Uri of the resource. + :vartype resource_uri: str """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'datasource_type': {'key': 'datasourceType', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'resource_id': {'key': 'resourceID', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, + "datasource_type": {"key": "datasourceType", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "resource_id": {"key": "resourceID", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, } def __init__( @@ -2416,7 +2856,24 @@ def __init__( resource_uri: Optional[str] = None, **kwargs ): - super(Datasource, self).__init__(**kwargs) + """ + :keyword datasource_type: DatasourceType of the resource. + :paramtype datasource_type: str + :keyword object_type: Type of Datasource object, used to initialize the right inherited type. + :paramtype object_type: str + :keyword resource_id: Full ARM ID of the resource. For azure resources, this is ARM ID. For non + azure resources, this will be the ID created by backup service via Fabric/Vault. Required. + :paramtype resource_id: str + :keyword resource_location: Location of datasource. + :paramtype resource_location: str + :keyword resource_name: Unique identifier of the resource in the context of parent. + :paramtype resource_name: str + :keyword resource_type: Resource Type of Datasource. + :paramtype resource_type: str + :keyword resource_uri: Uri of the resource. + :paramtype resource_uri: str + """ + super().__init__(**kwargs) self.datasource_type = datasource_type self.object_type = object_type self.resource_id = resource_id @@ -2426,40 +2883,40 @@ def __init__( self.resource_uri = resource_uri -class DatasourceSet(msrest.serialization.Model): +class DatasourceSet(_serialization.Model): """DatasourceSet details of datasource to be backed up. All required parameters must be populated in order to send to Azure. - :param datasource_type: DatasourceType of the resource. - :type datasource_type: str - :param object_type: Type of Datasource object, used to initialize the right inherited type. - :type object_type: str - :param resource_id: Required. Full ARM ID of the resource. For azure resources, this is ARM ID. - For non azure resources, this will be the ID created by backup service via Fabric/Vault. - :type resource_id: str - :param resource_location: Location of datasource. - :type resource_location: str - :param resource_name: Unique identifier of the resource in the context of parent. - :type resource_name: str - :param resource_type: Resource Type of Datasource. - :type resource_type: str - :param resource_uri: Uri of the resource. - :type resource_uri: str + :ivar datasource_type: DatasourceType of the resource. + :vartype datasource_type: str + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + :vartype object_type: str + :ivar resource_id: Full ARM ID of the resource. For azure resources, this is ARM ID. For non + azure resources, this will be the ID created by backup service via Fabric/Vault. Required. + :vartype resource_id: str + :ivar resource_location: Location of datasource. + :vartype resource_location: str + :ivar resource_name: Unique identifier of the resource in the context of parent. + :vartype resource_name: str + :ivar resource_type: Resource Type of Datasource. + :vartype resource_type: str + :ivar resource_uri: Uri of the resource. + :vartype resource_uri: str """ _validation = { - 'resource_id': {'required': True}, + "resource_id": {"required": True}, } _attribute_map = { - 'datasource_type': {'key': 'datasourceType', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'resource_id': {'key': 'resourceID', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, + "datasource_type": {"key": "datasourceType", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "resource_id": {"key": "resourceID", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, } def __init__( @@ -2474,7 +2931,24 @@ def __init__( resource_uri: Optional[str] = None, **kwargs ): - super(DatasourceSet, self).__init__(**kwargs) + """ + :keyword datasource_type: DatasourceType of the resource. + :paramtype datasource_type: str + :keyword object_type: Type of Datasource object, used to initialize the right inherited type. + :paramtype object_type: str + :keyword resource_id: Full ARM ID of the resource. For azure resources, this is ARM ID. For non + azure resources, this will be the ID created by backup service via Fabric/Vault. Required. + :paramtype resource_id: str + :keyword resource_location: Location of datasource. + :paramtype resource_location: str + :keyword resource_name: Unique identifier of the resource in the context of parent. + :paramtype resource_name: str + :keyword resource_type: Resource Type of Datasource. + :paramtype resource_type: str + :keyword resource_uri: Uri of the resource. + :paramtype resource_uri: str + """ + super().__init__(**kwargs) self.datasource_type = datasource_type self.object_type = object_type self.resource_id = resource_id @@ -2484,131 +2958,359 @@ def __init__( self.resource_uri = resource_uri -class DataStoreInfoBase(msrest.serialization.Model): +class DataStoreInfoBase(_serialization.Model): """DataStoreInfo base. All required parameters must be populated in order to send to Azure. - :param data_store_type: Required. type of datastore; Operational/Vault/Archive. Possible values - include: "OperationalStore", "VaultStore", "ArchiveStore". - :type data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type. - :type object_type: str + :ivar data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values + are: "OperationalStore", "VaultStore", and "ArchiveStore". + :vartype data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + Required. + :vartype object_type: str """ _validation = { - 'data_store_type': {'required': True}, - 'object_type': {'required': True}, + "data_store_type": {"required": True}, + "object_type": {"required": True}, } _attribute_map = { - 'data_store_type': {'key': 'dataStoreType', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - *, - data_store_type: Union[str, "DataStoreTypes"], - object_type: str, - **kwargs - ): - super(DataStoreInfoBase, self).__init__(**kwargs) + "data_store_type": {"key": "dataStoreType", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + } + + def __init__(self, *, data_store_type: Union[str, "_models.DataStoreTypes"], object_type: str, **kwargs): + """ + :keyword data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values + are: "OperationalStore", "VaultStore", and "ArchiveStore". + :paramtype data_store_type: str or ~azure.mgmt.dataprotection.models.DataStoreTypes + :keyword object_type: Type of Datasource object, used to initialize the right inherited type. + Required. + :paramtype object_type: str + """ + super().__init__(**kwargs) self.data_store_type = data_store_type self.object_type = object_type -class Day(msrest.serialization.Model): +class Day(_serialization.Model): """Day of the week. - :param date: Date of the month. - :type date: int - :param is_last: Whether Date is last date of month. - :type is_last: bool + :ivar date: Date of the month. + :vartype date: int + :ivar is_last: Whether Date is last date of month. + :vartype is_last: bool """ _attribute_map = { - 'date': {'key': 'date', 'type': 'int'}, - 'is_last': {'key': 'isLast', 'type': 'bool'}, - } - - def __init__( - self, - *, - date: Optional[int] = None, - is_last: Optional[bool] = None, - **kwargs - ): - super(Day, self).__init__(**kwargs) + "date": {"key": "date", "type": "int"}, + "is_last": {"key": "isLast", "type": "bool"}, + } + + def __init__(self, *, date: Optional[int] = None, is_last: Optional[bool] = None, **kwargs): + """ + :keyword date: Date of the month. + :paramtype date: int + :keyword is_last: Whether Date is last date of month. + :paramtype is_last: bool + """ + super().__init__(**kwargs) self.date = date self.is_last = is_last -class DppBaseResource(msrest.serialization.Model): - """Base resource under Microsoft.DataProtection provider namespace. +class DeletedBackupInstance(BackupInstance): # pylint: disable=too-many-instance-attributes + """Deleted Backup Instance. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id represents the complete path to the resource. - :vartype id: str - :ivar name: Resource name associated with the resource. - :vartype name: str - :ivar type: Resource type represents the complete path of the form + All required parameters must be populated in order to send to Azure. + + :ivar friendly_name: Gets or sets the Backup Instance friendly name. + :vartype friendly_name: str + :ivar data_source_info: Gets or sets the data source information. Required. + :vartype data_source_info: ~azure.mgmt.dataprotection.models.Datasource + :ivar data_source_set_info: Gets or sets the data source set information. + :vartype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :ivar policy_info: Gets or sets the policy information. Required. + :vartype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :ivar protection_status: Specifies the protection status of the resource. + :vartype protection_status: ~azure.mgmt.dataprotection.models.ProtectionStatusDetails + :ivar current_protection_state: Specifies the current protection state of the resource. Known + values are: "Invalid", "NotProtected", "ConfiguringProtection", "ProtectionConfigured", + "BackupSchedulesSuspended", "RetentionSchedulesSuspended", "ProtectionStopped", + "ProtectionError", "ConfiguringProtectionFailed", "SoftDeleting", "SoftDeleted", and + "UpdatingProtection". + :vartype current_protection_state: str or + ~azure.mgmt.dataprotection.models.CurrentProtectionState + :ivar protection_error_details: Specifies the protection error of the resource. + :vartype protection_error_details: ~azure.mgmt.dataprotection.models.UserFacingError + :ivar provisioning_state: Specifies the provisioning state of the resource i.e. + provisioning/updating/Succeeded/Failed. + :vartype provisioning_state: str + :ivar datasource_auth_credentials: Credentials to use to authenticate with data source + provider. + :vartype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + :ivar validation_type: Specifies the type of validation. In case of DeepValidation, all + validations from /validateForBackup API will run again. Known values are: "ShallowValidation" + and "DeepValidation". + :vartype validation_type: str or ~azure.mgmt.dataprotection.models.ValidationType + :ivar object_type: Required. + :vartype object_type: str + :ivar deletion_info: Deletion info of Backup Instance. + :vartype deletion_info: ~azure.mgmt.dataprotection.models.DeletionInfo + """ + + _validation = { + "data_source_info": {"required": True}, + "policy_info": {"required": True}, + "protection_status": {"readonly": True}, + "current_protection_state": {"readonly": True}, + "protection_error_details": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "object_type": {"required": True}, + "deletion_info": {"readonly": True}, + } + + _attribute_map = { + "friendly_name": {"key": "friendlyName", "type": "str"}, + "data_source_info": {"key": "dataSourceInfo", "type": "Datasource"}, + "data_source_set_info": {"key": "dataSourceSetInfo", "type": "DatasourceSet"}, + "policy_info": {"key": "policyInfo", "type": "PolicyInfo"}, + "protection_status": {"key": "protectionStatus", "type": "ProtectionStatusDetails"}, + "current_protection_state": {"key": "currentProtectionState", "type": "str"}, + "protection_error_details": {"key": "protectionErrorDetails", "type": "UserFacingError"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "datasource_auth_credentials": {"key": "datasourceAuthCredentials", "type": "AuthCredentials"}, + "validation_type": {"key": "validationType", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "deletion_info": {"key": "deletionInfo", "type": "DeletionInfo"}, + } + + def __init__( + self, + *, + data_source_info: "_models.Datasource", + policy_info: "_models.PolicyInfo", + object_type: str, + friendly_name: Optional[str] = None, + data_source_set_info: Optional["_models.DatasourceSet"] = None, + datasource_auth_credentials: Optional["_models.AuthCredentials"] = None, + validation_type: Optional[Union[str, "_models.ValidationType"]] = None, + **kwargs + ): + """ + :keyword friendly_name: Gets or sets the Backup Instance friendly name. + :paramtype friendly_name: str + :keyword data_source_info: Gets or sets the data source information. Required. + :paramtype data_source_info: ~azure.mgmt.dataprotection.models.Datasource + :keyword data_source_set_info: Gets or sets the data source set information. + :paramtype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :keyword policy_info: Gets or sets the policy information. Required. + :paramtype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :keyword datasource_auth_credentials: Credentials to use to authenticate with data source + provider. + :paramtype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + :keyword validation_type: Specifies the type of validation. In case of DeepValidation, all + validations from /validateForBackup API will run again. Known values are: "ShallowValidation" + and "DeepValidation". + :paramtype validation_type: str or ~azure.mgmt.dataprotection.models.ValidationType + :keyword object_type: Required. + :paramtype object_type: str + """ + super().__init__( + friendly_name=friendly_name, + data_source_info=data_source_info, + data_source_set_info=data_source_set_info, + policy_info=policy_info, + datasource_auth_credentials=datasource_auth_credentials, + validation_type=validation_type, + object_type=object_type, + **kwargs + ) + self.deletion_info = None + + +class DeletedBackupInstanceResource(DppResource): + """Deleted Backup Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id represents the complete path to the resource. + :vartype id: str + :ivar name: Resource name associated with the resource. + :vartype name: str + :ivar type: Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/... :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData + :ivar properties: DeletedBackupInstanceResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.DeletedBackupInstance """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "DeletedBackupInstance"}, + } + + def __init__(self, *, properties: Optional["_models.DeletedBackupInstance"] = None, **kwargs): + """ + :keyword properties: DeletedBackupInstanceResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.DeletedBackupInstance + """ + super().__init__(**kwargs) + self.properties = properties + + +class DeletedBackupInstanceResourceList(DppResourceList): + """List of DeletedBackupInstance resources. + + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource] + """ + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[DeletedBackupInstanceResource]"}, } def __init__( self, + *, + next_link: Optional[str] = None, + value: Optional[List["_models.DeletedBackupInstanceResource"]] = None, **kwargs ): - super(DppBaseResource, self).__init__(**kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource] + """ + super().__init__(next_link=next_link, **kwargs) + self.value = value + + +class DeletionInfo(_serialization.Model): + """Deletion Info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar deletion_time: Specifies time of deletion. + :vartype deletion_time: str + :ivar billing_end_date: Specifies billing end date. + :vartype billing_end_date: str + :ivar scheduled_purge_time: Specifies purge time. + :vartype scheduled_purge_time: str + :ivar delete_activity_id: Delete activity ID for troubleshooting purpose. + :vartype delete_activity_id: str + """ + + _validation = { + "deletion_time": {"readonly": True}, + "billing_end_date": {"readonly": True}, + "scheduled_purge_time": {"readonly": True}, + "delete_activity_id": {"readonly": True}, + } + + _attribute_map = { + "deletion_time": {"key": "deletionTime", "type": "str"}, + "billing_end_date": {"key": "billingEndDate", "type": "str"}, + "scheduled_purge_time": {"key": "scheduledPurgeTime", "type": "str"}, + "delete_activity_id": {"key": "deleteActivityID", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.deletion_time = None + self.billing_end_date = None + self.scheduled_purge_time = None + self.delete_activity_id = None + + +class DppBaseResource(_serialization.Model): + """Base resource under Microsoft.DataProtection provider namespace. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id represents the complete path to the resource. + :vartype id: str + :ivar name: Resource name associated with the resource. + :vartype name: str + :ivar type: Resource type represents the complete path of the form + Namespace/ResourceType/ResourceType/... + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class DppBaseResourceList(msrest.serialization.Model): +class DppBaseResourceList(_serialization.Model): """Base for all lists of V2 resources. - :param value: List of Dpp resources. - :type value: list[~azure.mgmt.dataprotection.models.DppBaseResource] - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str + :ivar value: List of Dpp resources. + :vartype value: list[~azure.mgmt.dataprotection.models.DppBaseResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DppBaseResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DppBaseResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DppBaseResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DppBaseResource"]] = None, next_link: Optional[str] = None, **kwargs ): - super(DppBaseResourceList, self).__init__(**kwargs) + """ + :keyword value: List of Dpp resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.DppBaseResource] + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DppIdentityDetails(msrest.serialization.Model): +class DppIdentityDetails(_serialization.Model): """Identity details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2619,56 +3321,55 @@ class DppIdentityDetails(msrest.serialization.Model): :ivar tenant_id: A Globally Unique Identifier (GUID) that represents the Azure AD tenant where the resource is now a member. :vartype tenant_id: str - :param type: The identityType which can be either SystemAssigned or None. - :type type: str + :ivar type: The identityType which can be either SystemAssigned or None. + :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): - super(DppIdentityDetails, self).__init__(**kwargs) + def __init__(self, *, type: Optional[str] = None, **kwargs): + """ + :keyword type: The identityType which can be either SystemAssigned or None. + :paramtype type: str + """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class DppTrackedResourceList(msrest.serialization.Model): +class DppTrackedResourceList(_serialization.Model): """DppTrackedResourceList. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - **kwargs - ): - super(DppTrackedResourceList, self).__init__(**kwargs) + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.next_link = next_link -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """The resource management error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2686,26 +3387,24 @@ class Error(msrest.serialization.Model): """ _validation = { - 'additional_info': {'readonly': True}, - 'code': {'readonly': True}, - 'details': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, + "additional_info": {"readonly": True}, + "code": {"readonly": True}, + "details": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, } _attribute_map = { - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + "code": {"key": "code", "type": "str"}, + "details": {"key": "details", "type": "[Error]"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Error, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.additional_info = None self.code = None self.details = None @@ -2713,37 +3412,35 @@ def __init__( self.target = None -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar info: The additional info. - :vartype info: any + :vartype info: JSON :ivar type: The additional info type. :vartype type: str """ _validation = { - 'info': {'readonly': True}, - 'type': {'readonly': True}, + "info": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'info': {'key': 'info', 'type': 'object'}, - 'type': {'key': 'type', 'type': 'str'}, + "info": {"key": "info", "type": "object"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.info = None self.type = None -class ExportJobsResult(msrest.serialization.Model): +class ExportJobsResult(_serialization.Model): """The result for export jobs containing blob details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2759,60 +3456,53 @@ class ExportJobsResult(msrest.serialization.Model): """ _validation = { - 'blob_url': {'readonly': True}, - 'blob_sas_key': {'readonly': True}, - 'excel_file_blob_url': {'readonly': True}, - 'excel_file_blob_sas_key': {'readonly': True}, + "blob_url": {"readonly": True}, + "blob_sas_key": {"readonly": True}, + "excel_file_blob_url": {"readonly": True}, + "excel_file_blob_sas_key": {"readonly": True}, } _attribute_map = { - 'blob_url': {'key': 'blobUrl', 'type': 'str'}, - 'blob_sas_key': {'key': 'blobSasKey', 'type': 'str'}, - 'excel_file_blob_url': {'key': 'excelFileBlobUrl', 'type': 'str'}, - 'excel_file_blob_sas_key': {'key': 'excelFileBlobSasKey', 'type': 'str'}, + "blob_url": {"key": "blobUrl", "type": "str"}, + "blob_sas_key": {"key": "blobSasKey", "type": "str"}, + "excel_file_blob_url": {"key": "excelFileBlobUrl", "type": "str"}, + "excel_file_blob_sas_key": {"key": "excelFileBlobSasKey", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ExportJobsResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob_url = None self.blob_sas_key = None self.excel_file_blob_url = None self.excel_file_blob_sas_key = None -class FeatureValidationRequestBase(msrest.serialization.Model): +class FeatureValidationRequestBase(_serialization.Model): """Base class for Backup Feature support. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FeatureValidationRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FeatureValidationRequest All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'FeatureValidationRequest': 'FeatureValidationRequest'} - } + _subtype_map = {"object_type": {"FeatureValidationRequest": "FeatureValidationRequest"}} - def __init__( - self, - **kwargs - ): - super(FeatureValidationRequestBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -2821,69 +3511,70 @@ class FeatureValidationRequest(FeatureValidationRequestBase): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param feature_type: backup support feature type. Possible values include: "Invalid", + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar feature_type: backup support feature type. Known values are: "Invalid" and "DataSourceType". - :type feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType - :param feature_name: backup support feature name. - :type feature_name: str + :vartype feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType + :ivar feature_name: backup support feature name. + :vartype feature_name: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'feature_type': {'key': 'featureType', 'type': 'str'}, - 'feature_name': {'key': 'featureName', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "feature_type": {"key": "featureType", "type": "str"}, + "feature_name": {"key": "featureName", "type": "str"}, } def __init__( self, *, - feature_type: Optional[Union[str, "FeatureType"]] = None, + feature_type: Optional[Union[str, "_models.FeatureType"]] = None, feature_name: Optional[str] = None, **kwargs ): - super(FeatureValidationRequest, self).__init__(**kwargs) - self.object_type = 'FeatureValidationRequest' # type: str + """ + :keyword feature_type: backup support feature type. Known values are: "Invalid" and + "DataSourceType". + :paramtype feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType + :keyword feature_name: backup support feature name. + :paramtype feature_name: str + """ + super().__init__(**kwargs) + self.object_type = "FeatureValidationRequest" # type: str self.feature_type = feature_type self.feature_name = feature_name -class FeatureValidationResponseBase(msrest.serialization.Model): +class FeatureValidationResponseBase(_serialization.Model): """Base class for Backup Feature support. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FeatureValidationResponse. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FeatureValidationResponse All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - _subtype_map = { - 'object_type': {'FeatureValidationResponse': 'FeatureValidationResponse'} - } + _subtype_map = {"object_type": {"FeatureValidationResponse": "FeatureValidationResponse"}} - def __init__( - self, - **kwargs - ): - super(FeatureValidationResponseBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -2892,35 +3583,41 @@ class FeatureValidationResponse(FeatureValidationResponseBase): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param feature_type: backup support feature type. Possible values include: "Invalid", + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar feature_type: backup support feature type. Known values are: "Invalid" and "DataSourceType". - :type feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType - :param features: Response features. - :type features: list[~azure.mgmt.dataprotection.models.SupportedFeature] + :vartype feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType + :ivar features: Response features. + :vartype features: list[~azure.mgmt.dataprotection.models.SupportedFeature] """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'feature_type': {'key': 'featureType', 'type': 'str'}, - 'features': {'key': 'features', 'type': '[SupportedFeature]'}, + "object_type": {"key": "objectType", "type": "str"}, + "feature_type": {"key": "featureType", "type": "str"}, + "features": {"key": "features", "type": "[SupportedFeature]"}, } def __init__( self, *, - feature_type: Optional[Union[str, "FeatureType"]] = None, - features: Optional[List["SupportedFeature"]] = None, + feature_type: Optional[Union[str, "_models.FeatureType"]] = None, + features: Optional[List["_models.SupportedFeature"]] = None, **kwargs ): - super(FeatureValidationResponse, self).__init__(**kwargs) - self.object_type = 'FeatureValidationResponse' # type: str + """ + :keyword feature_type: backup support feature type. Known values are: "Invalid" and + "DataSourceType". + :paramtype feature_type: str or ~azure.mgmt.dataprotection.models.FeatureType + :keyword features: Response features. + :paramtype features: list[~azure.mgmt.dataprotection.models.SupportedFeature] + """ + super().__init__(**kwargs) + self.object_type = "FeatureValidationResponse" # type: str self.feature_type = feature_type self.features = features @@ -2930,43 +3627,60 @@ class ImmediateCopyOption(CopyOption): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ImmediateCopyOption, self).__init__(**kwargs) - self.object_type = 'ImmediateCopyOption' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.object_type = "ImmediateCopyOption" # type: str + + +class ImmutabilitySettings(_serialization.Model): + """Immutability Settings at vault level. + + :ivar state: Immutability state. Known values are: "Disabled", "Unlocked", and "Locked". + :vartype state: str or ~azure.mgmt.dataprotection.models.ImmutabilityState + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, state: Optional[Union[str, "_models.ImmutabilityState"]] = None, **kwargs): + """ + :keyword state: Immutability state. Known values are: "Disabled", "Unlocked", and "Locked". + :paramtype state: str or ~azure.mgmt.dataprotection.models.ImmutabilityState + """ + super().__init__(**kwargs) + self.state = state -class InnerError(msrest.serialization.Model): +class InnerError(_serialization.Model): """Inner Error. - :param additional_info: Any Key value pairs that can be provided to the client for additional + :ivar additional_info: Any Key value pairs that can be provided to the client for additional verbose information. - :type additional_info: dict[str, str] - :param code: Unique code for this error. - :type code: str - :param embedded_inner_error: Child Inner Error, to allow Nesting. - :type embedded_inner_error: ~azure.mgmt.dataprotection.models.InnerError + :vartype additional_info: dict[str, str] + :ivar code: Unique code for this error. + :vartype code: str + :ivar embedded_inner_error: Child Inner Error, to allow Nesting. + :vartype embedded_inner_error: ~azure.mgmt.dataprotection.models.InnerError """ _attribute_map = { - 'additional_info': {'key': 'additionalInfo', 'type': '{str}'}, - 'code': {'key': 'code', 'type': 'str'}, - 'embedded_inner_error': {'key': 'embeddedInnerError', 'type': 'InnerError'}, + "additional_info": {"key": "additionalInfo", "type": "{str}"}, + "code": {"key": "code", "type": "str"}, + "embedded_inner_error": {"key": "embeddedInnerError", "type": "InnerError"}, } def __init__( @@ -2974,88 +3688,105 @@ def __init__( *, additional_info: Optional[Dict[str, str]] = None, code: Optional[str] = None, - embedded_inner_error: Optional["InnerError"] = None, + embedded_inner_error: Optional["_models.InnerError"] = None, **kwargs ): - super(InnerError, self).__init__(**kwargs) + """ + :keyword additional_info: Any Key value pairs that can be provided to the client for additional + verbose information. + :paramtype additional_info: dict[str, str] + :keyword code: Unique code for this error. + :paramtype code: str + :keyword embedded_inner_error: Child Inner Error, to allow Nesting. + :paramtype embedded_inner_error: ~azure.mgmt.dataprotection.models.InnerError + """ + super().__init__(**kwargs) self.additional_info = additional_info self.code = code self.embedded_inner_error = embedded_inner_error -class ItemLevelRestoreCriteria(msrest.serialization.Model): +class ItemLevelRestoreCriteria(_serialization.Model): """Class to contain criteria for item level restore. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RangeBasedItemLevelRestoreCriteria. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + KubernetesPVRestoreCriteria, KubernetesStorageClassRestoreCriteria, + RangeBasedItemLevelRestoreCriteria All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, } _subtype_map = { - 'object_type': {'RangeBasedItemLevelRestoreCriteria': 'RangeBasedItemLevelRestoreCriteria'} + "object_type": { + "KubernetesPVRestoreCriteria": "KubernetesPVRestoreCriteria", + "KubernetesStorageClassRestoreCriteria": "KubernetesStorageClassRestoreCriteria", + "RangeBasedItemLevelRestoreCriteria": "RangeBasedItemLevelRestoreCriteria", + } } - def __init__( - self, - **kwargs - ): - super(ItemLevelRestoreCriteria, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] -class RestoreTargetInfoBase(msrest.serialization.Model): +class RestoreTargetInfoBase(_serialization.Model): """Base class common to RestoreTargetInfo and RestoreFilesTargetInfo. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ItemLevelRestoreTargetInfo, RestoreFilesTargetInfo, RestoreTargetInfo. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ItemLevelRestoreTargetInfo, RestoreFilesTargetInfo, RestoreTargetInfo All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + Required. + :vartype object_type: str + :ivar recovery_option: Recovery Option. Required. "FailIfExists" + :vartype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :ivar restore_location: Target Restore region. + :vartype restore_location: str """ _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, + "object_type": {"required": True}, + "recovery_option": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "recovery_option": {"key": "recoveryOption", "type": "str"}, + "restore_location": {"key": "restoreLocation", "type": "str"}, } _subtype_map = { - 'object_type': {'ItemLevelRestoreTargetInfo': 'ItemLevelRestoreTargetInfo', 'RestoreFilesTargetInfo': 'RestoreFilesTargetInfo', 'RestoreTargetInfo': 'RestoreTargetInfo'} + "object_type": { + "ItemLevelRestoreTargetInfo": "ItemLevelRestoreTargetInfo", + "RestoreFilesTargetInfo": "RestoreFilesTargetInfo", + "RestoreTargetInfo": "RestoreTargetInfo", + } } def __init__( - self, - *, - recovery_option: Union[str, "RecoveryOption"], - restore_location: Optional[str] = None, - **kwargs + self, *, recovery_option: Union[str, "_models.RecoveryOption"], restore_location: Optional[str] = None, **kwargs ): - super(RestoreTargetInfoBase, self).__init__(**kwargs) + """ + :keyword recovery_option: Recovery Option. Required. "FailIfExists" + :paramtype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :keyword restore_location: Target Restore region. + :paramtype restore_location: str + """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] self.recovery_option = recovery_option self.restore_location = restore_location @@ -3066,67 +3797,82 @@ class ItemLevelRestoreTargetInfo(RestoreTargetInfoBase): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - :param restore_criteria: Required. Restore Criteria. - :type restore_criteria: list[~azure.mgmt.dataprotection.models.ItemLevelRestoreCriteria] - :param datasource_info: Required. Information of target DS. - :type datasource_info: ~azure.mgmt.dataprotection.models.Datasource - :param datasource_set_info: Information of target DS Set. - :type datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet - :param datasource_auth_credentials: Credentials to use to authenticate with data source + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + Required. + :vartype object_type: str + :ivar recovery_option: Recovery Option. Required. "FailIfExists" + :vartype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :ivar restore_location: Target Restore region. + :vartype restore_location: str + :ivar restore_criteria: Restore Criteria. Required. + :vartype restore_criteria: list[~azure.mgmt.dataprotection.models.ItemLevelRestoreCriteria] + :ivar datasource_info: Information of target DS. Required. + :vartype datasource_info: ~azure.mgmt.dataprotection.models.Datasource + :ivar datasource_set_info: Information of target DS Set. + :vartype datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :ivar datasource_auth_credentials: Credentials to use to authenticate with data source provider. - :type datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + :vartype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials """ _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - 'restore_criteria': {'required': True}, - 'datasource_info': {'required': True}, + "object_type": {"required": True}, + "recovery_option": {"required": True}, + "restore_criteria": {"required": True}, + "datasource_info": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - 'restore_criteria': {'key': 'restoreCriteria', 'type': '[ItemLevelRestoreCriteria]'}, - 'datasource_info': {'key': 'datasourceInfo', 'type': 'Datasource'}, - 'datasource_set_info': {'key': 'datasourceSetInfo', 'type': 'DatasourceSet'}, - 'datasource_auth_credentials': {'key': 'datasourceAuthCredentials', 'type': 'AuthCredentials'}, + "object_type": {"key": "objectType", "type": "str"}, + "recovery_option": {"key": "recoveryOption", "type": "str"}, + "restore_location": {"key": "restoreLocation", "type": "str"}, + "restore_criteria": {"key": "restoreCriteria", "type": "[ItemLevelRestoreCriteria]"}, + "datasource_info": {"key": "datasourceInfo", "type": "Datasource"}, + "datasource_set_info": {"key": "datasourceSetInfo", "type": "DatasourceSet"}, + "datasource_auth_credentials": {"key": "datasourceAuthCredentials", "type": "AuthCredentials"}, } def __init__( self, *, - recovery_option: Union[str, "RecoveryOption"], - restore_criteria: List["ItemLevelRestoreCriteria"], - datasource_info: "Datasource", + recovery_option: Union[str, "_models.RecoveryOption"], + restore_criteria: List["_models.ItemLevelRestoreCriteria"], + datasource_info: "_models.Datasource", restore_location: Optional[str] = None, - datasource_set_info: Optional["DatasourceSet"] = None, - datasource_auth_credentials: Optional["AuthCredentials"] = None, + datasource_set_info: Optional["_models.DatasourceSet"] = None, + datasource_auth_credentials: Optional["_models.AuthCredentials"] = None, **kwargs ): - super(ItemLevelRestoreTargetInfo, self).__init__(recovery_option=recovery_option, restore_location=restore_location, **kwargs) - self.object_type = 'ItemLevelRestoreTargetInfo' # type: str + """ + :keyword recovery_option: Recovery Option. Required. "FailIfExists" + :paramtype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :keyword restore_location: Target Restore region. + :paramtype restore_location: str + :keyword restore_criteria: Restore Criteria. Required. + :paramtype restore_criteria: list[~azure.mgmt.dataprotection.models.ItemLevelRestoreCriteria] + :keyword datasource_info: Information of target DS. Required. + :paramtype datasource_info: ~azure.mgmt.dataprotection.models.Datasource + :keyword datasource_set_info: Information of target DS Set. + :paramtype datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :keyword datasource_auth_credentials: Credentials to use to authenticate with data source + provider. + :paramtype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + """ + super().__init__(recovery_option=recovery_option, restore_location=restore_location, **kwargs) + self.object_type = "ItemLevelRestoreTargetInfo" # type: str self.restore_criteria = restore_criteria self.datasource_info = datasource_info self.datasource_set_info = datasource_set_info self.datasource_auth_credentials = datasource_auth_credentials -class JobExtendedInfo(msrest.serialization.Model): +class JobExtendedInfo(_serialization.Model): """Extended Information about the job. Variables are only populated by the server, and will be ignored when sending a request. - :param additional_details: Job's Additional Details. - :type additional_details: dict[str, str] + :ivar additional_details: Job's Additional Details. + :vartype additional_details: dict[str, str] :ivar backup_instance_state: State of the Backup Instance. :vartype backup_instance_state: str :ivar data_transferred_in_bytes: Number of bytes transferred. @@ -3142,31 +3888,30 @@ class JobExtendedInfo(msrest.serialization.Model): """ _validation = { - 'backup_instance_state': {'readonly': True}, - 'data_transferred_in_bytes': {'readonly': True}, - 'recovery_destination': {'readonly': True}, - 'source_recover_point': {'readonly': True}, - 'sub_tasks': {'readonly': True}, - 'target_recover_point': {'readonly': True}, + "backup_instance_state": {"readonly": True}, + "data_transferred_in_bytes": {"readonly": True}, + "recovery_destination": {"readonly": True}, + "source_recover_point": {"readonly": True}, + "sub_tasks": {"readonly": True}, + "target_recover_point": {"readonly": True}, } _attribute_map = { - 'additional_details': {'key': 'additionalDetails', 'type': '{str}'}, - 'backup_instance_state': {'key': 'backupInstanceState', 'type': 'str'}, - 'data_transferred_in_bytes': {'key': 'dataTransferredInBytes', 'type': 'float'}, - 'recovery_destination': {'key': 'recoveryDestination', 'type': 'str'}, - 'source_recover_point': {'key': 'sourceRecoverPoint', 'type': 'RestoreJobRecoveryPointDetails'}, - 'sub_tasks': {'key': 'subTasks', 'type': '[JobSubTask]'}, - 'target_recover_point': {'key': 'targetRecoverPoint', 'type': 'RestoreJobRecoveryPointDetails'}, - } - - def __init__( - self, - *, - additional_details: Optional[Dict[str, str]] = None, - **kwargs - ): - super(JobExtendedInfo, self).__init__(**kwargs) + "additional_details": {"key": "additionalDetails", "type": "{str}"}, + "backup_instance_state": {"key": "backupInstanceState", "type": "str"}, + "data_transferred_in_bytes": {"key": "dataTransferredInBytes", "type": "float"}, + "recovery_destination": {"key": "recoveryDestination", "type": "str"}, + "source_recover_point": {"key": "sourceRecoverPoint", "type": "RestoreJobRecoveryPointDetails"}, + "sub_tasks": {"key": "subTasks", "type": "[JobSubTask]"}, + "target_recover_point": {"key": "targetRecoverPoint", "type": "RestoreJobRecoveryPointDetails"}, + } + + def __init__(self, *, additional_details: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword additional_details: Job's Additional Details. + :paramtype additional_details: dict[str, str] + """ + super().__init__(**kwargs) self.additional_details = additional_details self.backup_instance_state = None self.data_transferred_in_bytes = None @@ -3176,38 +3921,38 @@ def __init__( self.target_recover_point = None -class JobSubTask(msrest.serialization.Model): +class JobSubTask(_serialization.Model): """Details of Job's Sub Task. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param additional_details: Additional details of Sub Tasks. - :type additional_details: dict[str, str] - :param task_id: Required. Task Id of the Sub Task. - :type task_id: int - :param task_name: Required. Name of the Sub Task. - :type task_name: str + :ivar additional_details: Additional details of Sub Tasks. + :vartype additional_details: dict[str, str] + :ivar task_id: Task Id of the Sub Task. Required. + :vartype task_id: int + :ivar task_name: Name of the Sub Task. Required. + :vartype task_name: str :ivar task_progress: Progress of the Sub Task. :vartype task_progress: str - :param task_status: Required. Status of the Sub Task. - :type task_status: str + :ivar task_status: Status of the Sub Task. Required. + :vartype task_status: str """ _validation = { - 'task_id': {'required': True}, - 'task_name': {'required': True}, - 'task_progress': {'readonly': True}, - 'task_status': {'required': True}, + "task_id": {"required": True}, + "task_name": {"required": True}, + "task_progress": {"readonly": True}, + "task_status": {"required": True}, } _attribute_map = { - 'additional_details': {'key': 'additionalDetails', 'type': '{str}'}, - 'task_id': {'key': 'taskId', 'type': 'int'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, - 'task_progress': {'key': 'taskProgress', 'type': 'str'}, - 'task_status': {'key': 'taskStatus', 'type': 'str'}, + "additional_details": {"key": "additionalDetails", "type": "{str}"}, + "task_id": {"key": "taskId", "type": "int"}, + "task_name": {"key": "taskName", "type": "str"}, + "task_progress": {"key": "taskProgress", "type": "str"}, + "task_status": {"key": "taskStatus", "type": "str"}, } def __init__( @@ -3219,7 +3964,17 @@ def __init__( additional_details: Optional[Dict[str, str]] = None, **kwargs ): - super(JobSubTask, self).__init__(**kwargs) + """ + :keyword additional_details: Additional details of Sub Tasks. + :paramtype additional_details: dict[str, str] + :keyword task_id: Task Id of the Sub Task. Required. + :paramtype task_id: int + :keyword task_name: Name of the Sub Task. Required. + :paramtype task_name: str + :keyword task_status: Status of the Sub Task. Required. + :paramtype task_status: str + """ + super().__init__(**kwargs) self.additional_details = additional_details self.task_id = task_id self.task_name = task_name @@ -3227,36 +3982,128 @@ def __init__( self.task_status = task_status -class OperationExtendedInfo(msrest.serialization.Model): - """Operation Extended Info. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: OperationJobExtendedInfo. +class KubernetesPVRestoreCriteria(ItemLevelRestoreCriteria): + """Item Level kubernetes persistent volume target info for restore operation. All required parameters must be populated in order to send to Azure. - :param object_type: Required. This property will be used as the discriminator for deciding the - specific types in the polymorphic chain of types.Constant filled by server. - :type object_type: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar name: Selected persistent volume claim name. + :vartype name: str + :ivar storage_class_name: Selected storage class name for restore operation. + :vartype storage_class_name: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "storage_class_name": {"key": "storageClassName", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, storage_class_name: Optional[str] = None, **kwargs): + """ + :keyword name: Selected persistent volume claim name. + :paramtype name: str + :keyword storage_class_name: Selected storage class name for restore operation. + :paramtype storage_class_name: str + """ + super().__init__(**kwargs) + self.object_type = "KubernetesPVRestoreCriteria" # type: str + self.name = name + self.storage_class_name = storage_class_name + + +class KubernetesStorageClassRestoreCriteria(ItemLevelRestoreCriteria): + """Item Level kubernetes storage class target info for restore operation. + + All required parameters must be populated in order to send to Azure. + + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar selected_storage_class_name: Selected storage class name. + :vartype selected_storage_class_name: str + :ivar provisioner: Provisioner of the storage class. + :vartype provisioner: str + """ + + _validation = { + "object_type": {"required": True}, } - _subtype_map = { - 'object_type': {'OperationJobExtendedInfo': 'OperationJobExtendedInfo'} + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + "selected_storage_class_name": {"key": "selectedStorageClassName", "type": "str"}, + "provisioner": {"key": "provisioner", "type": "str"}, } def __init__( - self, - **kwargs + self, *, selected_storage_class_name: Optional[str] = None, provisioner: Optional[str] = None, **kwargs ): - super(OperationExtendedInfo, self).__init__(**kwargs) + """ + :keyword selected_storage_class_name: Selected storage class name. + :paramtype selected_storage_class_name: str + :keyword provisioner: Provisioner of the storage class. + :paramtype provisioner: str + """ + super().__init__(**kwargs) + self.object_type = "KubernetesStorageClassRestoreCriteria" # type: str + self.selected_storage_class_name = selected_storage_class_name + self.provisioner = provisioner + + +class MonitoringSettings(_serialization.Model): + """Monitoring Settings. + + :ivar azure_monitor_alert_settings: Settings for Azure Monitor based alerts. + :vartype azure_monitor_alert_settings: + ~azure.mgmt.dataprotection.models.AzureMonitorAlertSettings + """ + + _attribute_map = { + "azure_monitor_alert_settings": {"key": "azureMonitorAlertSettings", "type": "AzureMonitorAlertSettings"}, + } + + def __init__(self, *, azure_monitor_alert_settings: Optional["_models.AzureMonitorAlertSettings"] = None, **kwargs): + """ + :keyword azure_monitor_alert_settings: Settings for Azure Monitor based alerts. + :paramtype azure_monitor_alert_settings: + ~azure.mgmt.dataprotection.models.AzureMonitorAlertSettings + """ + super().__init__(**kwargs) + self.azure_monitor_alert_settings = azure_monitor_alert_settings + + +class OperationExtendedInfo(_serialization.Model): + """Operation Extended Info. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + OperationJobExtendedInfo + + All required parameters must be populated in order to send to Azure. + + :ivar object_type: This property will be used as the discriminator for deciding the specific + types in the polymorphic chain of types. Required. + :vartype object_type: str + """ + + _validation = { + "object_type": {"required": True}, + } + + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + } + + _subtype_map = {"object_type": {"OperationJobExtendedInfo": "OperationJobExtendedInfo"}} + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.object_type = None # type: Optional[str] @@ -3265,79 +4112,98 @@ class OperationJobExtendedInfo(OperationExtendedInfo): All required parameters must be populated in order to send to Azure. - :param object_type: Required. This property will be used as the discriminator for deciding the - specific types in the polymorphic chain of types.Constant filled by server. - :type object_type: str - :param job_id: Arm Id of the job created for this operation. - :type job_id: str + :ivar object_type: This property will be used as the discriminator for deciding the specific + types in the polymorphic chain of types. Required. + :vartype object_type: str + :ivar job_id: Arm Id of the job created for this operation. + :vartype job_id: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'job_id': {'key': 'jobId', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "job_id": {"key": "jobId", "type": "str"}, } - def __init__( - self, - *, - job_id: Optional[str] = None, - **kwargs - ): - super(OperationJobExtendedInfo, self).__init__(**kwargs) - self.object_type = 'OperationJobExtendedInfo' # type: str + def __init__(self, *, job_id: Optional[str] = None, **kwargs): + """ + :keyword job_id: Arm Id of the job created for this operation. + :paramtype job_id: str + """ + super().__init__(**kwargs) + self.object_type = "OperationJobExtendedInfo" # type: str self.job_id = job_id -class OperationResource(msrest.serialization.Model): +class OperationResource(_serialization.Model): """Operation Resource. - :param end_time: End time of the operation. - :type end_time: ~datetime.datetime - :param error: Required if status == failed or status == canceled. This is the OData v4 error + :ivar end_time: End time of the operation. + :vartype end_time: ~datetime.datetime + :ivar error: Required if status == failed or status == canceled. This is the OData v4 error format, used by the RPC and will go into the v2.2 Azure REST API guidelines. The full set of optional properties (e.g. inner errors / details) can be found in the "Error Response" section. - :type error: ~azure.mgmt.dataprotection.models.Error - :param id: It should match what is used to GET the operation result. - :type id: str - :param name: It must match the last segment of the "id" field, and will typically be a GUID / + :vartype error: ~azure.mgmt.dataprotection.models.Error + :ivar id: It should match what is used to GET the operation result. + :vartype id: str + :ivar name: It must match the last segment of the "id" field, and will typically be a GUID / system generated value. - :type name: str - :param properties: End time of the operation. - :type properties: ~azure.mgmt.dataprotection.models.OperationExtendedInfo - :param start_time: Start time of the operation. - :type start_time: ~datetime.datetime - :param status: - :type status: str + :vartype name: str + :ivar properties: End time of the operation. + :vartype properties: ~azure.mgmt.dataprotection.models.OperationExtendedInfo + :ivar start_time: Start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar status: + :vartype status: str """ _attribute_map = { - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationExtendedInfo'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "error": {"key": "error", "type": "Error"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "OperationExtendedInfo"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, end_time: Optional[datetime.datetime] = None, - error: Optional["Error"] = None, - id: Optional[str] = None, + error: Optional["_models.Error"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, - properties: Optional["OperationExtendedInfo"] = None, + properties: Optional["_models.OperationExtendedInfo"] = None, start_time: Optional[datetime.datetime] = None, status: Optional[str] = None, **kwargs ): - super(OperationResource, self).__init__(**kwargs) + """ + :keyword end_time: End time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword error: Required if status == failed or status == canceled. This is the OData v4 error + format, used by the RPC and will go into the v2.2 Azure REST API guidelines. + The full set of optional properties (e.g. inner errors / details) can be found in the "Error + Response" section. + :paramtype error: ~azure.mgmt.dataprotection.models.Error + :keyword id: It should match what is used to GET the operation result. + :paramtype id: str + :keyword name: It must match the last segment of the "id" field, and will typically be a GUID / + system generated value. + :paramtype name: str + :keyword properties: End time of the operation. + :paramtype properties: ~azure.mgmt.dataprotection.models.OperationExtendedInfo + :keyword start_time: Start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword status: + :paramtype status: str + """ + super().__init__(**kwargs) self.end_time = end_time self.error = error self.id = id @@ -3347,116 +4213,170 @@ def __init__( self.status = status -class PatchResourceRequestInput(msrest.serialization.Model): +class PatchBackupVaultInput(_serialization.Model): + """Backup Vault Contract for Patch Backup Vault API. + + :ivar monitoring_settings: Monitoring Settings. + :vartype monitoring_settings: ~azure.mgmt.dataprotection.models.MonitoringSettings + :ivar security_settings: Security Settings. + :vartype security_settings: ~azure.mgmt.dataprotection.models.SecuritySettings + """ + + _attribute_map = { + "monitoring_settings": {"key": "monitoringSettings", "type": "MonitoringSettings"}, + "security_settings": {"key": "securitySettings", "type": "SecuritySettings"}, + } + + def __init__( + self, + *, + monitoring_settings: Optional["_models.MonitoringSettings"] = None, + security_settings: Optional["_models.SecuritySettings"] = None, + **kwargs + ): + """ + :keyword monitoring_settings: Monitoring Settings. + :paramtype monitoring_settings: ~azure.mgmt.dataprotection.models.MonitoringSettings + :keyword security_settings: Security Settings. + :paramtype security_settings: ~azure.mgmt.dataprotection.models.SecuritySettings + """ + super().__init__(**kwargs) + self.monitoring_settings = monitoring_settings + self.security_settings = security_settings + + +class PatchResourceRequestInput(_serialization.Model): """Patch Request content for Microsoft.DataProtection resources. - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar identity: Input Managed Identity Details. + :vartype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.PatchBackupVaultInput + :ivar tags: Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "identity": {"key": "identity", "type": "DppIdentityDetails"}, + "properties": {"key": "properties", "type": "PatchBackupVaultInput"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - identity: Optional["DppIdentityDetails"] = None, + identity: Optional["_models.DppIdentityDetails"] = None, + properties: Optional["_models.PatchBackupVaultInput"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): - super(PatchResourceRequestInput, self).__init__(**kwargs) + """ + :keyword identity: Input Managed Identity Details. + :paramtype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :keyword properties: Resource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.PatchBackupVaultInput + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.identity = identity + self.properties = properties self.tags = tags -class PolicyInfo(msrest.serialization.Model): +class PolicyInfo(_serialization.Model): """Policy Info in backupInstance. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param policy_id: Required. - :type policy_id: str + :ivar policy_id: Required. + :vartype policy_id: str :ivar policy_version: :vartype policy_version: str - :param policy_parameters: Policy parameters for the backup instance. - :type policy_parameters: ~azure.mgmt.dataprotection.models.PolicyParameters + :ivar policy_parameters: Policy parameters for the backup instance. + :vartype policy_parameters: ~azure.mgmt.dataprotection.models.PolicyParameters """ _validation = { - 'policy_id': {'required': True}, - 'policy_version': {'readonly': True}, + "policy_id": {"required": True}, + "policy_version": {"readonly": True}, } _attribute_map = { - 'policy_id': {'key': 'policyId', 'type': 'str'}, - 'policy_version': {'key': 'policyVersion', 'type': 'str'}, - 'policy_parameters': {'key': 'policyParameters', 'type': 'PolicyParameters'}, - } - - def __init__( - self, - *, - policy_id: str, - policy_parameters: Optional["PolicyParameters"] = None, - **kwargs - ): - super(PolicyInfo, self).__init__(**kwargs) + "policy_id": {"key": "policyId", "type": "str"}, + "policy_version": {"key": "policyVersion", "type": "str"}, + "policy_parameters": {"key": "policyParameters", "type": "PolicyParameters"}, + } + + def __init__(self, *, policy_id: str, policy_parameters: Optional["_models.PolicyParameters"] = None, **kwargs): + """ + :keyword policy_id: Required. + :paramtype policy_id: str + :keyword policy_parameters: Policy parameters for the backup instance. + :paramtype policy_parameters: ~azure.mgmt.dataprotection.models.PolicyParameters + """ + super().__init__(**kwargs) self.policy_id = policy_id self.policy_version = None self.policy_parameters = policy_parameters -class PolicyParameters(msrest.serialization.Model): +class PolicyParameters(_serialization.Model): """Parameters in Policy. - :param data_store_parameters_list: Gets or sets the DataStore Parameters. - :type data_store_parameters_list: list[~azure.mgmt.dataprotection.models.DataStoreParameters] + :ivar data_store_parameters_list: Gets or sets the DataStore Parameters. + :vartype data_store_parameters_list: + list[~azure.mgmt.dataprotection.models.DataStoreParameters] """ _attribute_map = { - 'data_store_parameters_list': {'key': 'dataStoreParametersList', 'type': '[DataStoreParameters]'}, + "data_store_parameters_list": {"key": "dataStoreParametersList", "type": "[DataStoreParameters]"}, } - def __init__( - self, - *, - data_store_parameters_list: Optional[List["DataStoreParameters"]] = None, - **kwargs - ): - super(PolicyParameters, self).__init__(**kwargs) + def __init__(self, *, data_store_parameters_list: Optional[List["_models.DataStoreParameters"]] = None, **kwargs): + """ + :keyword data_store_parameters_list: Gets or sets the DataStore Parameters. + :paramtype data_store_parameters_list: + list[~azure.mgmt.dataprotection.models.DataStoreParameters] + """ + super().__init__(**kwargs) self.data_store_parameters_list = data_store_parameters_list -class ProtectionStatusDetails(msrest.serialization.Model): +class ProtectionStatusDetails(_serialization.Model): """Protection status details. - :param error_details: Specifies the protection status error of the resource. - :type error_details: ~azure.mgmt.dataprotection.models.UserFacingError - :param status: Specifies the protection status of the resource. Possible values include: + :ivar error_details: Specifies the protection status error of the resource. + :vartype error_details: ~azure.mgmt.dataprotection.models.UserFacingError + :ivar status: Specifies the protection status of the resource. Known values are: "ConfiguringProtection", "ConfiguringProtectionFailed", "ProtectionConfigured", - "ProtectionStopped", "SoftDeleted", "SoftDeleting". - :type status: str or ~azure.mgmt.dataprotection.models.Status + "ProtectionStopped", "SoftDeleted", and "SoftDeleting". + :vartype status: str or ~azure.mgmt.dataprotection.models.Status """ _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': 'UserFacingError'}, - 'status': {'key': 'status', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "UserFacingError"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - error_details: Optional["UserFacingError"] = None, - status: Optional[Union[str, "Status"]] = None, + error_details: Optional["_models.UserFacingError"] = None, + status: Optional[Union[str, "_models.Status"]] = None, **kwargs ): - super(ProtectionStatusDetails, self).__init__(**kwargs) + """ + :keyword error_details: Specifies the protection status error of the resource. + :paramtype error_details: ~azure.mgmt.dataprotection.models.UserFacingError + :keyword status: Specifies the protection status of the resource. Known values are: + "ConfiguringProtection", "ConfiguringProtectionFailed", "ProtectionConfigured", + "ProtectionStopped", "SoftDeleted", and "SoftDeleting". + :paramtype status: str or ~azure.mgmt.dataprotection.models.Status + """ + super().__init__(**kwargs) self.error_details = error_details self.status = status @@ -3466,79 +4386,78 @@ class RangeBasedItemLevelRestoreCriteria(ItemLevelRestoreCriteria): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param min_matching_value: minimum value for range prefix match. - :type min_matching_value: str - :param max_matching_value: maximum value for range prefix match. - :type max_matching_value: str + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar min_matching_value: minimum value for range prefix match. + :vartype min_matching_value: str + :ivar max_matching_value: maximum value for range prefix match. + :vartype max_matching_value: str """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'min_matching_value': {'key': 'minMatchingValue', 'type': 'str'}, - 'max_matching_value': {'key': 'maxMatchingValue', 'type': 'str'}, - } - - def __init__( - self, - *, - min_matching_value: Optional[str] = None, - max_matching_value: Optional[str] = None, - **kwargs - ): - super(RangeBasedItemLevelRestoreCriteria, self).__init__(**kwargs) - self.object_type = 'RangeBasedItemLevelRestoreCriteria' # type: str + "object_type": {"key": "objectType", "type": "str"}, + "min_matching_value": {"key": "minMatchingValue", "type": "str"}, + "max_matching_value": {"key": "maxMatchingValue", "type": "str"}, + } + + def __init__(self, *, min_matching_value: Optional[str] = None, max_matching_value: Optional[str] = None, **kwargs): + """ + :keyword min_matching_value: minimum value for range prefix match. + :paramtype min_matching_value: str + :keyword max_matching_value: maximum value for range prefix match. + :paramtype max_matching_value: str + """ + super().__init__(**kwargs) + self.object_type = "RangeBasedItemLevelRestoreCriteria" # type: str self.min_matching_value = min_matching_value self.max_matching_value = max_matching_value -class RecoveryPointDataStoreDetails(msrest.serialization.Model): +class RecoveryPointDataStoreDetails(_serialization.Model): """RecoveryPoint datastore details. Variables are only populated by the server, and will be ignored when sending a request. - :param creation_time: - :type creation_time: ~datetime.datetime - :param expiry_time: - :type expiry_time: ~datetime.datetime - :param id: - :type id: str - :param meta_data: - :type meta_data: str - :param state: - :type state: str - :param type: - :type type: str - :param visible: - :type visible: bool + :ivar creation_time: + :vartype creation_time: ~datetime.datetime + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar id: + :vartype id: str + :ivar meta_data: + :vartype meta_data: str + :ivar state: + :vartype state: str + :ivar type: + :vartype type: str + :ivar visible: + :vartype visible: bool :ivar rehydration_expiry_time: :vartype rehydration_expiry_time: ~datetime.datetime - :ivar rehydration_status: Possible values include: "CREATE_IN_PROGRESS", "COMPLETED", - "DELETE_IN_PROGRESS", "DELETED", "FAILED". + :ivar rehydration_status: Known values are: "CREATE_IN_PROGRESS", "COMPLETED", + "DELETE_IN_PROGRESS", "DELETED", and "FAILED". :vartype rehydration_status: str or ~azure.mgmt.dataprotection.models.RehydrationStatus """ _validation = { - 'rehydration_expiry_time': {'readonly': True}, - 'rehydration_status': {'readonly': True}, + "rehydration_expiry_time": {"readonly": True}, + "rehydration_status": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'id': {'key': 'id', 'type': 'str'}, - 'meta_data': {'key': 'metaData', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'visible': {'key': 'visible', 'type': 'bool'}, - 'rehydration_expiry_time': {'key': 'rehydrationExpiryTime', 'type': 'iso-8601'}, - 'rehydration_status': {'key': 'rehydrationStatus', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "id": {"key": "id", "type": "str"}, + "meta_data": {"key": "metaData", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "visible": {"key": "visible", "type": "bool"}, + "rehydration_expiry_time": {"key": "rehydrationExpiryTime", "type": "iso-8601"}, + "rehydration_status": {"key": "rehydrationStatus", "type": "str"}, } def __init__( @@ -3546,14 +4465,30 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry_time: Optional[datetime.datetime] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin meta_data: Optional[str] = None, state: Optional[str] = None, type: Optional[str] = None, visible: Optional[bool] = None, **kwargs ): - super(RecoveryPointDataStoreDetails, self).__init__(**kwargs) + """ + :keyword creation_time: + :paramtype creation_time: ~datetime.datetime + :keyword expiry_time: + :paramtype expiry_time: ~datetime.datetime + :keyword id: + :paramtype id: str + :keyword meta_data: + :paramtype meta_data: str + :keyword state: + :paramtype state: str + :keyword type: + :paramtype type: str + :keyword visible: + :paramtype visible: bool + """ + super().__init__(**kwargs) self.creation_time = creation_time self.expiry_time = expiry_time self.id = id @@ -3565,30 +4500,30 @@ def __init__( self.rehydration_status = None -class RecoveryPointsFilters(msrest.serialization.Model): +class RecoveryPointsFilters(_serialization.Model): """RecoveryPointsFilters. - :param restore_point_data_store_id: - :type restore_point_data_store_id: str - :param is_visible: - :type is_visible: bool - :param start_date: - :type start_date: str - :param end_date: - :type end_date: str - :param extended_info: - :type extended_info: bool - :param restore_point_state: - :type restore_point_state: str + :ivar restore_point_data_store_id: + :vartype restore_point_data_store_id: str + :ivar is_visible: + :vartype is_visible: bool + :ivar start_date: + :vartype start_date: str + :ivar end_date: + :vartype end_date: str + :ivar extended_info: + :vartype extended_info: bool + :ivar restore_point_state: + :vartype restore_point_state: str """ _attribute_map = { - 'restore_point_data_store_id': {'key': 'restorePointDataStoreId', 'type': 'str'}, - 'is_visible': {'key': 'isVisible', 'type': 'bool'}, - 'start_date': {'key': 'startDate', 'type': 'str'}, - 'end_date': {'key': 'endDate', 'type': 'str'}, - 'extended_info': {'key': 'extendedInfo', 'type': 'bool'}, - 'restore_point_state': {'key': 'restorePointState', 'type': 'str'}, + "restore_point_data_store_id": {"key": "restorePointDataStoreId", "type": "str"}, + "is_visible": {"key": "isVisible", "type": "bool"}, + "start_date": {"key": "startDate", "type": "str"}, + "end_date": {"key": "endDate", "type": "str"}, + "extended_info": {"key": "extendedInfo", "type": "bool"}, + "restore_point_state": {"key": "restorePointState", "type": "str"}, } def __init__( @@ -3602,7 +4537,21 @@ def __init__( restore_point_state: Optional[str] = None, **kwargs ): - super(RecoveryPointsFilters, self).__init__(**kwargs) + """ + :keyword restore_point_data_store_id: + :paramtype restore_point_data_store_id: str + :keyword is_visible: + :paramtype is_visible: bool + :keyword start_date: + :paramtype start_date: str + :keyword end_date: + :paramtype end_date: str + :keyword extended_info: + :paramtype extended_info: bool + :keyword restore_point_state: + :paramtype restore_point_state: str + """ + super().__init__(**kwargs) self.restore_point_data_store_id = restore_point_data_store_id self.is_visible = is_visible self.start_date = start_date @@ -3611,14 +4560,15 @@ def __init__( self.restore_point_state = restore_point_state -class ResourceGuard(msrest.serialization.Model): +class ResourceGuard(_serialization.Model): """ResourceGuard. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the BackupVault resource. Possible values - include: "Failed", "Provisioning", "Succeeded", "Unknown", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.dataprotection.models.ProvisioningState + :ivar provisioning_state: Provisioning state of the BackupVault resource. Known values are: + "Failed", "Provisioning", "Succeeded", "Unknown", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.dataprotection.models.ResourceGuardProvisioningState :ivar allow_auto_approvals: This flag indicates whether auto approval is allowed or not. :vartype allow_auto_approvals: bool :ivar resource_guard_operations: {readonly} List of operation details those are protected by @@ -3633,34 +4583,35 @@ class ResourceGuard(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'allow_auto_approvals': {'readonly': True}, - 'resource_guard_operations': {'readonly': True}, - 'vault_critical_operation_exclusion_list': {'readonly': True}, - 'description': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "allow_auto_approvals": {"readonly": True}, + "resource_guard_operations": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'allow_auto_approvals': {'key': 'allowAutoApprovals', 'type': 'bool'}, - 'resource_guard_operations': {'key': 'resourceGuardOperations', 'type': '[ResourceGuardOperation]'}, - 'vault_critical_operation_exclusion_list': {'key': 'vaultCriticalOperationExclusionList', 'type': '[str]'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceGuard, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "allow_auto_approvals": {"key": "allowAutoApprovals", "type": "bool"}, + "resource_guard_operations": {"key": "resourceGuardOperations", "type": "[ResourceGuardOperation]"}, + "vault_critical_operation_exclusion_list": {"key": "vaultCriticalOperationExclusionList", "type": "[str]"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, *, vault_critical_operation_exclusion_list: Optional[List[str]] = None, **kwargs): + """ + :keyword vault_critical_operation_exclusion_list: List of critical operations which are not + protected by this resourceGuard. + :paramtype vault_critical_operation_exclusion_list: list[str] + """ + super().__init__(**kwargs) self.provisioning_state = None self.allow_auto_approvals = None self.resource_guard_operations = None - self.vault_critical_operation_exclusion_list = None + self.vault_critical_operation_exclusion_list = vault_critical_operation_exclusion_list self.description = None -class ResourceGuardOperation(msrest.serialization.Model): +class ResourceGuardOperation(_serialization.Model): """This class contains all the details about a critical operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -3672,22 +4623,178 @@ class ResourceGuardOperation(msrest.serialization.Model): """ _validation = { - 'vault_critical_operation': {'readonly': True}, - 'request_resource_type': {'readonly': True}, + "vault_critical_operation": {"readonly": True}, + "request_resource_type": {"readonly": True}, } _attribute_map = { - 'vault_critical_operation': {'key': 'vaultCriticalOperation', 'type': 'str'}, - 'request_resource_type': {'key': 'requestResourceType', 'type': 'str'}, + "vault_critical_operation": {"key": "vaultCriticalOperation", "type": "str"}, + "request_resource_type": {"key": "requestResourceType", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.vault_critical_operation = None + self.request_resource_type = None + + +class ResourceGuardOperationDetail(_serialization.Model): + """ResourceGuardOperationDetail. + + :ivar vault_critical_operation: + :vartype vault_critical_operation: str + :ivar default_resource_request: + :vartype default_resource_request: str + """ + + _attribute_map = { + "vault_critical_operation": {"key": "vaultCriticalOperation", "type": "str"}, + "default_resource_request": {"key": "defaultResourceRequest", "type": "str"}, } def __init__( self, + *, + vault_critical_operation: Optional[str] = None, + default_resource_request: Optional[str] = None, **kwargs ): - super(ResourceGuardOperation, self).__init__(**kwargs) - self.vault_critical_operation = None - self.request_resource_type = None + """ + :keyword vault_critical_operation: + :paramtype vault_critical_operation: str + :keyword default_resource_request: + :paramtype default_resource_request: str + """ + super().__init__(**kwargs) + self.vault_critical_operation = vault_critical_operation + self.default_resource_request = default_resource_request + + +class ResourceGuardProxyBase(_serialization.Model): + """ResourceGuardProxyBase. + + :ivar resource_guard_resource_id: + :vartype resource_guard_resource_id: str + :ivar resource_guard_operation_details: + :vartype resource_guard_operation_details: + list[~azure.mgmt.dataprotection.models.ResourceGuardOperationDetail] + :ivar last_updated_time: + :vartype last_updated_time: str + :ivar description: + :vartype description: str + """ + + _attribute_map = { + "resource_guard_resource_id": {"key": "resourceGuardResourceId", "type": "str"}, + "resource_guard_operation_details": { + "key": "resourceGuardOperationDetails", + "type": "[ResourceGuardOperationDetail]", + }, + "last_updated_time": {"key": "lastUpdatedTime", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + resource_guard_resource_id: Optional[str] = None, + resource_guard_operation_details: Optional[List["_models.ResourceGuardOperationDetail"]] = None, + last_updated_time: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_guard_resource_id: + :paramtype resource_guard_resource_id: str + :keyword resource_guard_operation_details: + :paramtype resource_guard_operation_details: + list[~azure.mgmt.dataprotection.models.ResourceGuardOperationDetail] + :keyword last_updated_time: + :paramtype last_updated_time: str + :keyword description: + :paramtype description: str + """ + super().__init__(**kwargs) + self.resource_guard_resource_id = resource_guard_resource_id + self.resource_guard_operation_details = resource_guard_operation_details + self.last_updated_time = last_updated_time + self.description = description + + +class ResourceGuardProxyBaseResource(DppResource): + """ResourceGuardProxyBaseResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id represents the complete path to the resource. + :vartype id: str + :ivar name: Resource name associated with the resource. + :vartype name: str + :ivar type: Resource type represents the complete path of the form + Namespace/ResourceType/ResourceType/... + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData + :ivar properties: ResourceGuardProxyBaseResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBase + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ResourceGuardProxyBase"}, + } + + def __init__(self, *, properties: Optional["_models.ResourceGuardProxyBase"] = None, **kwargs): + """ + :keyword properties: ResourceGuardProxyBaseResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBase + """ + super().__init__(**kwargs) + self.properties = properties + + +class ResourceGuardProxyBaseResourceList(DppResourceList): + """List of ResourceGuardProxyBase resources. + + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + """ + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ResourceGuardProxyBaseResource]"}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["_models.ResourceGuardProxyBaseResource"]] = None, + **kwargs + ): + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + """ + super().__init__(next_link=next_link, **kwargs) + self.value = value class ResourceGuardResource(DppTrackedResource): @@ -3695,110 +4802,129 @@ class ResourceGuardResource(DppTrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - :param e_tag: Optional ETag. - :type e_tag: str + :ivar e_tag: Optional ETag. + :vartype e_tag: str :ivar id: Resource Id represents the complete path to the resource. :vartype id: str - :param identity: Input Managed Identity Details. - :type identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails - :param location: Resource location. - :type location: str + :ivar identity: Input Managed Identity Details. + :vartype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :ivar location: Resource location. + :vartype location: str :ivar name: Resource name associated with the resource. :vartype name: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: Resource tags. + :vartype tags: dict[str, str] :ivar type: Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/... :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData - :param properties: ResourceGuardResource properties. - :type properties: ~azure.mgmt.dataprotection.models.ResourceGuard + :ivar properties: ResourceGuardResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.ResourceGuard """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'DppIdentityDetails'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'ResourceGuard'}, + "e_tag": {"key": "eTag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "identity": {"key": "identity", "type": "DppIdentityDetails"}, + "location": {"key": "location", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ResourceGuard"}, } def __init__( self, *, e_tag: Optional[str] = None, - identity: Optional["DppIdentityDetails"] = None, + identity: Optional["_models.DppIdentityDetails"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ResourceGuard"] = None, + properties: Optional["_models.ResourceGuard"] = None, **kwargs ): - super(ResourceGuardResource, self).__init__(e_tag=e_tag, identity=identity, location=location, tags=tags, **kwargs) + """ + :keyword e_tag: Optional ETag. + :paramtype e_tag: str + :keyword identity: Input Managed Identity Details. + :paramtype identity: ~azure.mgmt.dataprotection.models.DppIdentityDetails + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: ResourceGuardResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.ResourceGuard + """ + super().__init__(e_tag=e_tag, identity=identity, location=location, tags=tags, **kwargs) self.properties = properties class ResourceGuardResourceList(DppTrackedResourceList): """List of ResourceGuard resources. - :param next_link: The uri to fetch the next page of resources. Call ListNext() fetches next - page of resources. - :type next_link: str - :param value: List of resources. - :type value: list[~azure.mgmt.dataprotection.models.ResourceGuardResource] + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.ResourceGuardResource] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ResourceGuardResource]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ResourceGuardResource]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["ResourceGuardResource"]] = None, + value: Optional[List["_models.ResourceGuardResource"]] = None, **kwargs ): - super(ResourceGuardResourceList, self).__init__(next_link=next_link, **kwargs) + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.ResourceGuardResource] + """ + super().__init__(next_link=next_link, **kwargs) self.value = value -class ResourceMoveDetails(msrest.serialization.Model): +class ResourceMoveDetails(_serialization.Model): """ResourceMoveDetails will be returned in response to GetResource call from ARM. - :param operation_id: CorrelationId of latest ResourceMove operation attempted. - :type operation_id: str - :param start_time_utc: Start time in UTC of latest ResourceMove operation attempted. ISO 8601 + :ivar operation_id: CorrelationId of latest ResourceMove operation attempted. + :vartype operation_id: str + :ivar start_time_utc: Start time in UTC of latest ResourceMove operation attempted. ISO 8601 format. - :type start_time_utc: str - :param completion_time_utc: Completion time in UTC of latest ResourceMove operation attempted. + :vartype start_time_utc: str + :ivar completion_time_utc: Completion time in UTC of latest ResourceMove operation attempted. ISO 8601 format. - :type completion_time_utc: str - :param source_resource_path: ARM resource path of source resource. - :type source_resource_path: str - :param target_resource_path: ARM resource path of target resource used in latest ResourceMove + :vartype completion_time_utc: str + :ivar source_resource_path: ARM resource path of source resource. + :vartype source_resource_path: str + :ivar target_resource_path: ARM resource path of target resource used in latest ResourceMove operation. - :type target_resource_path: str + :vartype target_resource_path: str """ _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'start_time_utc': {'key': 'startTimeUtc', 'type': 'str'}, - 'completion_time_utc': {'key': 'completionTimeUtc', 'type': 'str'}, - 'source_resource_path': {'key': 'sourceResourcePath', 'type': 'str'}, - 'target_resource_path': {'key': 'targetResourcePath', 'type': 'str'}, + "operation_id": {"key": "operationId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "str"}, + "completion_time_utc": {"key": "completionTimeUtc", "type": "str"}, + "source_resource_path": {"key": "sourceResourcePath", "type": "str"}, + "target_resource_path": {"key": "targetResourcePath", "type": "str"}, } def __init__( @@ -3811,7 +4937,22 @@ def __init__( target_resource_path: Optional[str] = None, **kwargs ): - super(ResourceMoveDetails, self).__init__(**kwargs) + """ + :keyword operation_id: CorrelationId of latest ResourceMove operation attempted. + :paramtype operation_id: str + :keyword start_time_utc: Start time in UTC of latest ResourceMove operation attempted. ISO 8601 + format. + :paramtype start_time_utc: str + :keyword completion_time_utc: Completion time in UTC of latest ResourceMove operation + attempted. ISO 8601 format. + :paramtype completion_time_utc: str + :keyword source_resource_path: ARM resource path of source resource. + :paramtype source_resource_path: str + :keyword target_resource_path: ARM resource path of target resource used in latest ResourceMove + operation. + :paramtype target_resource_path: str + """ + super().__init__(**kwargs) self.operation_id = operation_id self.start_time_utc = start_time_utc self.completion_time_utc = completion_time_utc @@ -3819,39 +4960,40 @@ def __init__( self.target_resource_path = target_resource_path -class RestorableTimeRange(msrest.serialization.Model): +class RestorableTimeRange(_serialization.Model): """RestorableTimeRange. All required parameters must be populated in order to send to Azure. - :param start_time: Required. Start time for the available restore range. - :type start_time: str - :param end_time: Required. End time for the available restore range. - :type end_time: str - :param object_type: - :type object_type: str + :ivar start_time: Start time for the available restore range. Required. + :vartype start_time: str + :ivar end_time: End time for the available restore range. Required. + :vartype end_time: str + :ivar object_type: + :vartype object_type: str """ _validation = { - 'start_time': {'required': True}, - 'end_time': {'required': True}, + "start_time": {"required": True}, + "end_time": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - } - - def __init__( - self, - *, - start_time: str, - end_time: str, - object_type: Optional[str] = None, - **kwargs - ): - super(RestorableTimeRange, self).__init__(**kwargs) + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + } + + def __init__(self, *, start_time: str, end_time: str, object_type: Optional[str] = None, **kwargs): + """ + :keyword start_time: Start time for the available restore range. Required. + :paramtype start_time: str + :keyword end_time: End time for the available restore range. Required. + :paramtype end_time: str + :keyword object_type: + :paramtype object_type: str + """ + super().__init__(**kwargs) self.start_time = start_time self.end_time = end_time self.object_type = object_type @@ -3862,56 +5004,65 @@ class RestoreFilesTargetInfo(RestoreTargetInfoBase): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - :param target_details: Required. Destination of RestoreAsFiles operation, when destination is - not a datasource. - :type target_details: ~azure.mgmt.dataprotection.models.TargetDetails + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + Required. + :vartype object_type: str + :ivar recovery_option: Recovery Option. Required. "FailIfExists" + :vartype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :ivar restore_location: Target Restore region. + :vartype restore_location: str + :ivar target_details: Destination of RestoreAsFiles operation, when destination is not a + datasource. Required. + :vartype target_details: ~azure.mgmt.dataprotection.models.TargetDetails """ _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - 'target_details': {'required': True}, + "object_type": {"required": True}, + "recovery_option": {"required": True}, + "target_details": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - 'target_details': {'key': 'targetDetails', 'type': 'TargetDetails'}, + "object_type": {"key": "objectType", "type": "str"}, + "recovery_option": {"key": "recoveryOption", "type": "str"}, + "restore_location": {"key": "restoreLocation", "type": "str"}, + "target_details": {"key": "targetDetails", "type": "TargetDetails"}, } def __init__( self, *, - recovery_option: Union[str, "RecoveryOption"], - target_details: "TargetDetails", + recovery_option: Union[str, "_models.RecoveryOption"], + target_details: "_models.TargetDetails", restore_location: Optional[str] = None, **kwargs ): - super(RestoreFilesTargetInfo, self).__init__(recovery_option=recovery_option, restore_location=restore_location, **kwargs) - self.object_type = 'RestoreFilesTargetInfo' # type: str + """ + :keyword recovery_option: Recovery Option. Required. "FailIfExists" + :paramtype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :keyword restore_location: Target Restore region. + :paramtype restore_location: str + :keyword target_details: Destination of RestoreAsFiles operation, when destination is not a + datasource. Required. + :paramtype target_details: ~azure.mgmt.dataprotection.models.TargetDetails + """ + super().__init__(recovery_option=recovery_option, restore_location=restore_location, **kwargs) + self.object_type = "RestoreFilesTargetInfo" # type: str self.target_details = target_details -class RestoreJobRecoveryPointDetails(msrest.serialization.Model): +class RestoreJobRecoveryPointDetails(_serialization.Model): """RestoreJobRecoveryPointDetails. - :param recovery_point_id: - :type recovery_point_id: str - :param recovery_point_time: - :type recovery_point_time: ~datetime.datetime + :ivar recovery_point_id: + :vartype recovery_point_id: str + :ivar recovery_point_time: + :vartype recovery_point_time: ~datetime.datetime """ _attribute_map = { - 'recovery_point_id': {'key': 'recoveryPointID', 'type': 'str'}, - 'recovery_point_time': {'key': 'recoveryPointTime', 'type': 'iso-8601'}, + "recovery_point_id": {"key": "recoveryPointID", "type": "str"}, + "recovery_point_time": {"key": "recoveryPointTime", "type": "iso-8601"}, } def __init__( @@ -3921,7 +5072,13 @@ def __init__( recovery_point_time: Optional[datetime.datetime] = None, **kwargs ): - super(RestoreJobRecoveryPointDetails, self).__init__(**kwargs) + """ + :keyword recovery_point_id: + :paramtype recovery_point_id: str + :keyword recovery_point_time: + :paramtype recovery_point_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.recovery_point_id = recovery_point_id self.recovery_point_time = recovery_point_time @@ -3931,55 +5088,68 @@ class RestoreTargetInfo(RestoreTargetInfoBase): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of Datasource object, used to initialize the right inherited - type.Constant filled by server. - :type object_type: str - :param recovery_option: Required. Recovery Option. Possible values include: "FailIfExists". - :type recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption - :param restore_location: Target Restore region. - :type restore_location: str - :param datasource_info: Required. Information of target DS. - :type datasource_info: ~azure.mgmt.dataprotection.models.Datasource - :param datasource_set_info: Information of target DS Set. - :type datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet - :param datasource_auth_credentials: Credentials to use to authenticate with data source + :ivar object_type: Type of Datasource object, used to initialize the right inherited type. + Required. + :vartype object_type: str + :ivar recovery_option: Recovery Option. Required. "FailIfExists" + :vartype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :ivar restore_location: Target Restore region. + :vartype restore_location: str + :ivar datasource_info: Information of target DS. Required. + :vartype datasource_info: ~azure.mgmt.dataprotection.models.Datasource + :ivar datasource_set_info: Information of target DS Set. + :vartype datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :ivar datasource_auth_credentials: Credentials to use to authenticate with data source provider. - :type datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + :vartype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials """ _validation = { - 'object_type': {'required': True}, - 'recovery_option': {'required': True}, - 'datasource_info': {'required': True}, + "object_type": {"required": True}, + "recovery_option": {"required": True}, + "datasource_info": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'recovery_option': {'key': 'recoveryOption', 'type': 'str'}, - 'restore_location': {'key': 'restoreLocation', 'type': 'str'}, - 'datasource_info': {'key': 'datasourceInfo', 'type': 'Datasource'}, - 'datasource_set_info': {'key': 'datasourceSetInfo', 'type': 'DatasourceSet'}, - 'datasource_auth_credentials': {'key': 'datasourceAuthCredentials', 'type': 'AuthCredentials'}, + "object_type": {"key": "objectType", "type": "str"}, + "recovery_option": {"key": "recoveryOption", "type": "str"}, + "restore_location": {"key": "restoreLocation", "type": "str"}, + "datasource_info": {"key": "datasourceInfo", "type": "Datasource"}, + "datasource_set_info": {"key": "datasourceSetInfo", "type": "DatasourceSet"}, + "datasource_auth_credentials": {"key": "datasourceAuthCredentials", "type": "AuthCredentials"}, } def __init__( self, *, - recovery_option: Union[str, "RecoveryOption"], - datasource_info: "Datasource", + recovery_option: Union[str, "_models.RecoveryOption"], + datasource_info: "_models.Datasource", restore_location: Optional[str] = None, - datasource_set_info: Optional["DatasourceSet"] = None, - datasource_auth_credentials: Optional["AuthCredentials"] = None, + datasource_set_info: Optional["_models.DatasourceSet"] = None, + datasource_auth_credentials: Optional["_models.AuthCredentials"] = None, **kwargs ): - super(RestoreTargetInfo, self).__init__(recovery_option=recovery_option, restore_location=restore_location, **kwargs) - self.object_type = 'RestoreTargetInfo' # type: str + """ + :keyword recovery_option: Recovery Option. Required. "FailIfExists" + :paramtype recovery_option: str or ~azure.mgmt.dataprotection.models.RecoveryOption + :keyword restore_location: Target Restore region. + :paramtype restore_location: str + :keyword datasource_info: Information of target DS. Required. + :paramtype datasource_info: ~azure.mgmt.dataprotection.models.Datasource + :keyword datasource_set_info: Information of target DS Set. + :paramtype datasource_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet + :keyword datasource_auth_credentials: Credentials to use to authenticate with data source + provider. + :paramtype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials + """ + super().__init__(recovery_option=recovery_option, restore_location=restore_location, **kwargs) + self.object_type = "RestoreTargetInfo" # type: str self.datasource_info = datasource_info self.datasource_set_info = datasource_set_info self.datasource_auth_credentials = datasource_auth_credentials -class RetentionTag(msrest.serialization.Model): +class RetentionTag(_serialization.Model): """Retention tag. Variables are only populated by the server, and will be ignored when sending a request. @@ -3990,29 +5160,28 @@ class RetentionTag(msrest.serialization.Model): :vartype e_tag: str :ivar id: Retention Tag version. :vartype id: str - :param tag_name: Required. Retention Tag Name to relate it to retention rule. - :type tag_name: str + :ivar tag_name: Retention Tag Name to relate it to retention rule. Required. + :vartype tag_name: str """ _validation = { - 'e_tag': {'readonly': True}, - 'id': {'readonly': True}, - 'tag_name': {'required': True}, + "e_tag": {"readonly": True}, + "id": {"readonly": True}, + "tag_name": {"required": True}, } _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, + "e_tag": {"key": "eTag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, } - def __init__( - self, - *, - tag_name: str, - **kwargs - ): - super(RetentionTag, self).__init__(**kwargs) + def __init__(self, *, tag_name: str, **kwargs): + """ + :keyword tag_name: Retention Tag Name to relate it to retention rule. Required. + :paramtype tag_name: str + """ + super().__init__(**kwargs) self.e_tag = None self.id = None self.tag_name = tag_name @@ -4023,52 +5192,67 @@ class ScheduleBasedBackupCriteria(BackupCriteria): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param absolute_criteria: it contains absolute values like "AllBackup" / "FirstOfDay" / + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar absolute_criteria: it contains absolute values like "AllBackup" / "FirstOfDay" / "FirstOfWeek" / "FirstOfMonth" and should be part of AbsoluteMarker enum. - :type absolute_criteria: list[str or ~azure.mgmt.dataprotection.models.AbsoluteMarker] - :param days_of_month: This is day of the month from 1 to 28 other wise last of month. - :type days_of_month: list[~azure.mgmt.dataprotection.models.Day] - :param days_of_the_week: It should be Sunday/Monday/T..../Saturday. - :type days_of_the_week: list[str or ~azure.mgmt.dataprotection.models.DayOfWeek] - :param months_of_year: It should be January/February/....../December. - :type months_of_year: list[str or ~azure.mgmt.dataprotection.models.Month] - :param schedule_times: List of schedule times for backup. - :type schedule_times: list[~datetime.datetime] - :param weeks_of_the_month: It should be First/Second/Third/Fourth/Last. - :type weeks_of_the_month: list[str or ~azure.mgmt.dataprotection.models.WeekNumber] + :vartype absolute_criteria: list[str or ~azure.mgmt.dataprotection.models.AbsoluteMarker] + :ivar days_of_month: This is day of the month from 1 to 28 other wise last of month. + :vartype days_of_month: list[~azure.mgmt.dataprotection.models.Day] + :ivar days_of_the_week: It should be Sunday/Monday/T..../Saturday. + :vartype days_of_the_week: list[str or ~azure.mgmt.dataprotection.models.DayOfWeek] + :ivar months_of_year: It should be January/February/....../December. + :vartype months_of_year: list[str or ~azure.mgmt.dataprotection.models.Month] + :ivar schedule_times: List of schedule times for backup. + :vartype schedule_times: list[~datetime.datetime] + :ivar weeks_of_the_month: It should be First/Second/Third/Fourth/Last. + :vartype weeks_of_the_month: list[str or ~azure.mgmt.dataprotection.models.WeekNumber] """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'absolute_criteria': {'key': 'absoluteCriteria', 'type': '[str]'}, - 'days_of_month': {'key': 'daysOfMonth', 'type': '[Day]'}, - 'days_of_the_week': {'key': 'daysOfTheWeek', 'type': '[str]'}, - 'months_of_year': {'key': 'monthsOfYear', 'type': '[str]'}, - 'schedule_times': {'key': 'scheduleTimes', 'type': '[iso-8601]'}, - 'weeks_of_the_month': {'key': 'weeksOfTheMonth', 'type': '[str]'}, + "object_type": {"key": "objectType", "type": "str"}, + "absolute_criteria": {"key": "absoluteCriteria", "type": "[str]"}, + "days_of_month": {"key": "daysOfMonth", "type": "[Day]"}, + "days_of_the_week": {"key": "daysOfTheWeek", "type": "[str]"}, + "months_of_year": {"key": "monthsOfYear", "type": "[str]"}, + "schedule_times": {"key": "scheduleTimes", "type": "[iso-8601]"}, + "weeks_of_the_month": {"key": "weeksOfTheMonth", "type": "[str]"}, } def __init__( self, *, - absolute_criteria: Optional[List[Union[str, "AbsoluteMarker"]]] = None, - days_of_month: Optional[List["Day"]] = None, - days_of_the_week: Optional[List[Union[str, "DayOfWeek"]]] = None, - months_of_year: Optional[List[Union[str, "Month"]]] = None, + absolute_criteria: Optional[List[Union[str, "_models.AbsoluteMarker"]]] = None, + days_of_month: Optional[List["_models.Day"]] = None, + days_of_the_week: Optional[List[Union[str, "_models.DayOfWeek"]]] = None, + months_of_year: Optional[List[Union[str, "_models.Month"]]] = None, schedule_times: Optional[List[datetime.datetime]] = None, - weeks_of_the_month: Optional[List[Union[str, "WeekNumber"]]] = None, + weeks_of_the_month: Optional[List[Union[str, "_models.WeekNumber"]]] = None, **kwargs ): - super(ScheduleBasedBackupCriteria, self).__init__(**kwargs) - self.object_type = 'ScheduleBasedBackupCriteria' # type: str + """ + :keyword absolute_criteria: it contains absolute values like "AllBackup" / "FirstOfDay" / + "FirstOfWeek" / "FirstOfMonth" + and should be part of AbsoluteMarker enum. + :paramtype absolute_criteria: list[str or ~azure.mgmt.dataprotection.models.AbsoluteMarker] + :keyword days_of_month: This is day of the month from 1 to 28 other wise last of month. + :paramtype days_of_month: list[~azure.mgmt.dataprotection.models.Day] + :keyword days_of_the_week: It should be Sunday/Monday/T..../Saturday. + :paramtype days_of_the_week: list[str or ~azure.mgmt.dataprotection.models.DayOfWeek] + :keyword months_of_year: It should be January/February/....../December. + :paramtype months_of_year: list[str or ~azure.mgmt.dataprotection.models.Month] + :keyword schedule_times: List of schedule times for backup. + :paramtype schedule_times: list[~datetime.datetime] + :keyword weeks_of_the_month: It should be First/Second/Third/Fourth/Last. + :paramtype weeks_of_the_month: list[str or ~azure.mgmt.dataprotection.models.WeekNumber] + """ + super().__init__(**kwargs) + self.object_type = "ScheduleBasedBackupCriteria" # type: str self.absolute_criteria = absolute_criteria self.days_of_month = days_of_month self.days_of_the_week = days_of_the_week @@ -4082,36 +5266,37 @@ class ScheduleBasedTriggerContext(TriggerContext): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param schedule: Required. Schedule for this backup. - :type schedule: ~azure.mgmt.dataprotection.models.BackupSchedule - :param tagging_criteria: Required. List of tags that can be applicable for given schedule. - :type tagging_criteria: list[~azure.mgmt.dataprotection.models.TaggingCriteria] + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar schedule: Schedule for this backup. Required. + :vartype schedule: ~azure.mgmt.dataprotection.models.BackupSchedule + :ivar tagging_criteria: List of tags that can be applicable for given schedule. Required. + :vartype tagging_criteria: list[~azure.mgmt.dataprotection.models.TaggingCriteria] """ _validation = { - 'object_type': {'required': True}, - 'schedule': {'required': True}, - 'tagging_criteria': {'required': True}, + "object_type": {"required": True}, + "schedule": {"required": True}, + "tagging_criteria": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'BackupSchedule'}, - 'tagging_criteria': {'key': 'taggingCriteria', 'type': '[TaggingCriteria]'}, + "object_type": {"key": "objectType", "type": "str"}, + "schedule": {"key": "schedule", "type": "BackupSchedule"}, + "tagging_criteria": {"key": "taggingCriteria", "type": "[TaggingCriteria]"}, } def __init__( - self, - *, - schedule: "BackupSchedule", - tagging_criteria: List["TaggingCriteria"], - **kwargs + self, *, schedule: "_models.BackupSchedule", tagging_criteria: List["_models.TaggingCriteria"], **kwargs ): - super(ScheduleBasedTriggerContext, self).__init__(**kwargs) - self.object_type = 'ScheduleBasedTriggerContext' # type: str + """ + :keyword schedule: Schedule for this backup. Required. + :paramtype schedule: ~azure.mgmt.dataprotection.models.BackupSchedule + :keyword tagging_criteria: List of tags that can be applicable for given schedule. Required. + :paramtype tagging_criteria: list[~azure.mgmt.dataprotection.models.TaggingCriteria] + """ + super().__init__(**kwargs) + self.object_type = "ScheduleBasedTriggerContext" # type: str self.schedule = schedule self.tagging_criteria = tagging_criteria @@ -4121,205 +5306,345 @@ class SecretStoreBasedAuthCredentials(AuthCredentials): All required parameters must be populated in order to send to Azure. - :param object_type: Required. Type of the specific object - used for deserializing.Constant - filled by server. - :type object_type: str - :param secret_store_resource: Secret store resource. - :type secret_store_resource: ~azure.mgmt.dataprotection.models.SecretStoreResource + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar secret_store_resource: Secret store resource. + :vartype secret_store_resource: ~azure.mgmt.dataprotection.models.SecretStoreResource """ _validation = { - 'object_type': {'required': True}, + "object_type": {"required": True}, } _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'secret_store_resource': {'key': 'secretStoreResource', 'type': 'SecretStoreResource'}, + "object_type": {"key": "objectType", "type": "str"}, + "secret_store_resource": {"key": "secretStoreResource", "type": "SecretStoreResource"}, } - def __init__( - self, - *, - secret_store_resource: Optional["SecretStoreResource"] = None, - **kwargs - ): - super(SecretStoreBasedAuthCredentials, self).__init__(**kwargs) - self.object_type = 'SecretStoreBasedAuthCredentials' # type: str + def __init__(self, *, secret_store_resource: Optional["_models.SecretStoreResource"] = None, **kwargs): + """ + :keyword secret_store_resource: Secret store resource. + :paramtype secret_store_resource: ~azure.mgmt.dataprotection.models.SecretStoreResource + """ + super().__init__(**kwargs) + self.object_type = "SecretStoreBasedAuthCredentials" # type: str self.secret_store_resource = secret_store_resource -class SecretStoreResource(msrest.serialization.Model): +class SecretStoreResource(_serialization.Model): """Class representing a secret store resource. All required parameters must be populated in order to send to Azure. - :param uri: Uri to get to the resource. - :type uri: str - :param secret_store_type: Required. Gets or sets the type of secret store. Possible values - include: "Invalid", "AzureKeyVault". - :type secret_store_type: str or ~azure.mgmt.dataprotection.models.SecretStoreType + :ivar uri: Uri to get to the resource. + :vartype uri: str + :ivar secret_store_type: Gets or sets the type of secret store. Required. Known values are: + "Invalid" and "AzureKeyVault". + :vartype secret_store_type: str or ~azure.mgmt.dataprotection.models.SecretStoreType + :ivar value: Gets or sets value stored in secret store resource. + :vartype value: str """ _validation = { - 'secret_store_type': {'required': True}, + "secret_store_type": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'secret_store_type': {'key': 'secretStoreType', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "secret_store_type": {"key": "secretStoreType", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( self, *, - secret_store_type: Union[str, "SecretStoreType"], + secret_store_type: Union[str, "_models.SecretStoreType"], uri: Optional[str] = None, + value: Optional[str] = None, **kwargs ): - super(SecretStoreResource, self).__init__(**kwargs) + """ + :keyword uri: Uri to get to the resource. + :paramtype uri: str + :keyword secret_store_type: Gets or sets the type of secret store. Required. Known values are: + "Invalid" and "AzureKeyVault". + :paramtype secret_store_type: str or ~azure.mgmt.dataprotection.models.SecretStoreType + :keyword value: Gets or sets value stored in secret store resource. + :paramtype value: str + """ + super().__init__(**kwargs) self.uri = uri self.secret_store_type = secret_store_type + self.value = value + + +class SecuritySettings(_serialization.Model): + """Class containing security settings of vault. + + :ivar soft_delete_settings: Soft delete related settings. + :vartype soft_delete_settings: ~azure.mgmt.dataprotection.models.SoftDeleteSettings + :ivar immutability_settings: Immutability Settings at vault level. + :vartype immutability_settings: ~azure.mgmt.dataprotection.models.ImmutabilitySettings + """ + + _attribute_map = { + "soft_delete_settings": {"key": "softDeleteSettings", "type": "SoftDeleteSettings"}, + "immutability_settings": {"key": "immutabilitySettings", "type": "ImmutabilitySettings"}, + } + + def __init__( + self, + *, + soft_delete_settings: Optional["_models.SoftDeleteSettings"] = None, + immutability_settings: Optional["_models.ImmutabilitySettings"] = None, + **kwargs + ): + """ + :keyword soft_delete_settings: Soft delete related settings. + :paramtype soft_delete_settings: ~azure.mgmt.dataprotection.models.SoftDeleteSettings + :keyword immutability_settings: Immutability Settings at vault level. + :paramtype immutability_settings: ~azure.mgmt.dataprotection.models.ImmutabilitySettings + """ + super().__init__(**kwargs) + self.soft_delete_settings = soft_delete_settings + self.immutability_settings = immutability_settings + + +class SoftDeleteSettings(_serialization.Model): + """Soft delete related settings. + + :ivar state: State of soft delete. Known values are: "Off", "On", and "AlwaysOn". + :vartype state: str or ~azure.mgmt.dataprotection.models.SoftDeleteState + :ivar retention_duration_in_days: Soft delete retention duration. + :vartype retention_duration_in_days: float + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "retention_duration_in_days": {"key": "retentionDurationInDays", "type": "float"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.SoftDeleteState"]] = None, + retention_duration_in_days: Optional[float] = None, + **kwargs + ): + """ + :keyword state: State of soft delete. Known values are: "Off", "On", and "AlwaysOn". + :paramtype state: str or ~azure.mgmt.dataprotection.models.SoftDeleteState + :keyword retention_duration_in_days: Soft delete retention duration. + :paramtype retention_duration_in_days: float + """ + super().__init__(**kwargs) + self.state = state + self.retention_duration_in_days = retention_duration_in_days -class SourceLifeCycle(msrest.serialization.Model): +class SourceLifeCycle(_serialization.Model): """Source LifeCycle. All required parameters must be populated in order to send to Azure. - :param delete_after: Required. Delete Option. - :type delete_after: ~azure.mgmt.dataprotection.models.DeleteOption - :param source_data_store: Required. DataStoreInfo base. - :type source_data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase - :param target_data_store_copy_settings: - :type target_data_store_copy_settings: + :ivar delete_after: Delete Option. Required. + :vartype delete_after: ~azure.mgmt.dataprotection.models.DeleteOption + :ivar source_data_store: DataStoreInfo base. Required. + :vartype source_data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase + :ivar target_data_store_copy_settings: + :vartype target_data_store_copy_settings: list[~azure.mgmt.dataprotection.models.TargetCopySetting] """ _validation = { - 'delete_after': {'required': True}, - 'source_data_store': {'required': True}, + "delete_after": {"required": True}, + "source_data_store": {"required": True}, } _attribute_map = { - 'delete_after': {'key': 'deleteAfter', 'type': 'DeleteOption'}, - 'source_data_store': {'key': 'sourceDataStore', 'type': 'DataStoreInfoBase'}, - 'target_data_store_copy_settings': {'key': 'targetDataStoreCopySettings', 'type': '[TargetCopySetting]'}, + "delete_after": {"key": "deleteAfter", "type": "DeleteOption"}, + "source_data_store": {"key": "sourceDataStore", "type": "DataStoreInfoBase"}, + "target_data_store_copy_settings": {"key": "targetDataStoreCopySettings", "type": "[TargetCopySetting]"}, } def __init__( self, *, - delete_after: "DeleteOption", - source_data_store: "DataStoreInfoBase", - target_data_store_copy_settings: Optional[List["TargetCopySetting"]] = None, + delete_after: "_models.DeleteOption", + source_data_store: "_models.DataStoreInfoBase", + target_data_store_copy_settings: Optional[List["_models.TargetCopySetting"]] = None, **kwargs ): - super(SourceLifeCycle, self).__init__(**kwargs) + """ + :keyword delete_after: Delete Option. Required. + :paramtype delete_after: ~azure.mgmt.dataprotection.models.DeleteOption + :keyword source_data_store: DataStoreInfo base. Required. + :paramtype source_data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase + :keyword target_data_store_copy_settings: + :paramtype target_data_store_copy_settings: + list[~azure.mgmt.dataprotection.models.TargetCopySetting] + """ + super().__init__(**kwargs) self.delete_after = delete_after self.source_data_store = source_data_store self.target_data_store_copy_settings = target_data_store_copy_settings -class StorageSetting(msrest.serialization.Model): +class StorageSetting(_serialization.Model): """Storage setting. - :param datastore_type: Gets or sets the type of the datastore. Possible values include: - "ArchiveStore", "SnapshotStore", "VaultStore". - :type datastore_type: str or ~azure.mgmt.dataprotection.models.StorageSettingStoreTypes - :param type: Gets or sets the type. Possible values include: "GeoRedundant", - "LocallyRedundant". - :type type: str or ~azure.mgmt.dataprotection.models.StorageSettingTypes + :ivar datastore_type: Gets or sets the type of the datastore. Known values are: "ArchiveStore", + "SnapshotStore", and "VaultStore". + :vartype datastore_type: str or ~azure.mgmt.dataprotection.models.StorageSettingStoreTypes + :ivar type: Gets or sets the type. Known values are: "GeoRedundant", "LocallyRedundant", and + "ZoneRedundant". + :vartype type: str or ~azure.mgmt.dataprotection.models.StorageSettingTypes """ _attribute_map = { - 'datastore_type': {'key': 'datastoreType', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "datastore_type": {"key": "datastoreType", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, - datastore_type: Optional[Union[str, "StorageSettingStoreTypes"]] = None, - type: Optional[Union[str, "StorageSettingTypes"]] = None, + datastore_type: Optional[Union[str, "_models.StorageSettingStoreTypes"]] = None, + type: Optional[Union[str, "_models.StorageSettingTypes"]] = None, **kwargs ): - super(StorageSetting, self).__init__(**kwargs) + """ + :keyword datastore_type: Gets or sets the type of the datastore. Known values are: + "ArchiveStore", "SnapshotStore", and "VaultStore". + :paramtype datastore_type: str or ~azure.mgmt.dataprotection.models.StorageSettingStoreTypes + :keyword type: Gets or sets the type. Known values are: "GeoRedundant", "LocallyRedundant", and + "ZoneRedundant". + :paramtype type: str or ~azure.mgmt.dataprotection.models.StorageSettingTypes + """ + super().__init__(**kwargs) self.datastore_type = datastore_type self.type = type -class SupportedFeature(msrest.serialization.Model): +class SupportedFeature(_serialization.Model): """Elements class for feature request. - :param feature_name: support feature type. - :type feature_name: str - :param support_status: feature support status. Possible values include: "Invalid", - "NotSupported", "AlphaPreview", "PrivatePreview", "PublicPreview", "GenerallyAvailable". - :type support_status: str or ~azure.mgmt.dataprotection.models.FeatureSupportStatus - :param exposure_controlled_features: support feature type. - :type exposure_controlled_features: list[str] + :ivar feature_name: support feature type. + :vartype feature_name: str + :ivar support_status: feature support status. Known values are: "Invalid", "NotSupported", + "AlphaPreview", "PrivatePreview", "PublicPreview", and "GenerallyAvailable". + :vartype support_status: str or ~azure.mgmt.dataprotection.models.FeatureSupportStatus + :ivar exposure_controlled_features: support feature type. + :vartype exposure_controlled_features: list[str] """ _attribute_map = { - 'feature_name': {'key': 'featureName', 'type': 'str'}, - 'support_status': {'key': 'supportStatus', 'type': 'str'}, - 'exposure_controlled_features': {'key': 'exposureControlledFeatures', 'type': '[str]'}, + "feature_name": {"key": "featureName", "type": "str"}, + "support_status": {"key": "supportStatus", "type": "str"}, + "exposure_controlled_features": {"key": "exposureControlledFeatures", "type": "[str]"}, } def __init__( self, *, feature_name: Optional[str] = None, - support_status: Optional[Union[str, "FeatureSupportStatus"]] = None, + support_status: Optional[Union[str, "_models.FeatureSupportStatus"]] = None, exposure_controlled_features: Optional[List[str]] = None, **kwargs ): - super(SupportedFeature, self).__init__(**kwargs) + """ + :keyword feature_name: support feature type. + :paramtype feature_name: str + :keyword support_status: feature support status. Known values are: "Invalid", "NotSupported", + "AlphaPreview", "PrivatePreview", "PublicPreview", and "GenerallyAvailable". + :paramtype support_status: str or ~azure.mgmt.dataprotection.models.FeatureSupportStatus + :keyword exposure_controlled_features: support feature type. + :paramtype exposure_controlled_features: list[str] + """ + super().__init__(**kwargs) self.feature_name = feature_name self.support_status = support_status self.exposure_controlled_features = exposure_controlled_features -class SystemData(msrest.serialization.Model): +class SyncBackupInstanceRequest(_serialization.Model): + """Sync BackupInstance Request. + + :ivar sync_type: Field indicating sync type e.g. to sync only in case of failure or in all + cases. Known values are: "Default" and "ForceResync". + :vartype sync_type: str or ~azure.mgmt.dataprotection.models.SyncType + """ + + _attribute_map = { + "sync_type": {"key": "syncType", "type": "str"}, + } + + def __init__(self, *, sync_type: Optional[Union[str, "_models.SyncType"]] = None, **kwargs): + """ + :keyword sync_type: Field indicating sync type e.g. to sync only in case of failure or in all + cases. Known values are: "Default" and "ForceResync". + :paramtype sync_type: str or ~azure.mgmt.dataprotection.models.SyncType + """ + super().__init__(**kwargs) + self.sync_type = sync_type + + +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType + :ivar last_modified_at: The type of identity that last modified the resource. + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**kwargs) + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.dataprotection.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4328,32 +5653,32 @@ def __init__( self.last_modified_at = last_modified_at -class TaggingCriteria(msrest.serialization.Model): +class TaggingCriteria(_serialization.Model): """Tagging criteria. All required parameters must be populated in order to send to Azure. - :param criteria: Criteria which decides whether the tag can be applied to a triggered backup. - :type criteria: list[~azure.mgmt.dataprotection.models.BackupCriteria] - :param is_default: Required. Specifies if tag is default. - :type is_default: bool - :param tagging_priority: Required. Retention Tag priority. - :type tagging_priority: long - :param tag_info: Required. Retention tag information. - :type tag_info: ~azure.mgmt.dataprotection.models.RetentionTag + :ivar criteria: Criteria which decides whether the tag can be applied to a triggered backup. + :vartype criteria: list[~azure.mgmt.dataprotection.models.BackupCriteria] + :ivar is_default: Specifies if tag is default. Required. + :vartype is_default: bool + :ivar tagging_priority: Retention Tag priority. Required. + :vartype tagging_priority: int + :ivar tag_info: Retention tag information. Required. + :vartype tag_info: ~azure.mgmt.dataprotection.models.RetentionTag """ _validation = { - 'is_default': {'required': True}, - 'tagging_priority': {'required': True}, - 'tag_info': {'required': True}, + "is_default": {"required": True}, + "tagging_priority": {"required": True}, + "tag_info": {"required": True}, } _attribute_map = { - 'criteria': {'key': 'criteria', 'type': '[BackupCriteria]'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'tagging_priority': {'key': 'taggingPriority', 'type': 'long'}, - 'tag_info': {'key': 'tagInfo', 'type': 'RetentionTag'}, + "criteria": {"key": "criteria", "type": "[BackupCriteria]"}, + "is_default": {"key": "isDefault", "type": "bool"}, + "tagging_priority": {"key": "taggingPriority", "type": "int"}, + "tag_info": {"key": "tagInfo", "type": "RetentionTag"}, } def __init__( @@ -4361,166 +5686,245 @@ def __init__( *, is_default: bool, tagging_priority: int, - tag_info: "RetentionTag", - criteria: Optional[List["BackupCriteria"]] = None, + tag_info: "_models.RetentionTag", + criteria: Optional[List["_models.BackupCriteria"]] = None, **kwargs ): - super(TaggingCriteria, self).__init__(**kwargs) + """ + :keyword criteria: Criteria which decides whether the tag can be applied to a triggered backup. + :paramtype criteria: list[~azure.mgmt.dataprotection.models.BackupCriteria] + :keyword is_default: Specifies if tag is default. Required. + :paramtype is_default: bool + :keyword tagging_priority: Retention Tag priority. Required. + :paramtype tagging_priority: int + :keyword tag_info: Retention tag information. Required. + :paramtype tag_info: ~azure.mgmt.dataprotection.models.RetentionTag + """ + super().__init__(**kwargs) self.criteria = criteria self.is_default = is_default self.tagging_priority = tagging_priority self.tag_info = tag_info -class TargetCopySetting(msrest.serialization.Model): +class TargetCopySetting(_serialization.Model): """Target copy settings. All required parameters must be populated in order to send to Azure. - :param copy_after: Required. It can be CustomCopyOption or ImmediateCopyOption. - :type copy_after: ~azure.mgmt.dataprotection.models.CopyOption - :param data_store: Required. Info of target datastore. - :type data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase + :ivar copy_after: It can be CustomCopyOption or ImmediateCopyOption. Required. + :vartype copy_after: ~azure.mgmt.dataprotection.models.CopyOption + :ivar data_store: Info of target datastore. Required. + :vartype data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase """ _validation = { - 'copy_after': {'required': True}, - 'data_store': {'required': True}, + "copy_after": {"required": True}, + "data_store": {"required": True}, } _attribute_map = { - 'copy_after': {'key': 'copyAfter', 'type': 'CopyOption'}, - 'data_store': {'key': 'dataStore', 'type': 'DataStoreInfoBase'}, - } - - def __init__( - self, - *, - copy_after: "CopyOption", - data_store: "DataStoreInfoBase", - **kwargs - ): - super(TargetCopySetting, self).__init__(**kwargs) + "copy_after": {"key": "copyAfter", "type": "CopyOption"}, + "data_store": {"key": "dataStore", "type": "DataStoreInfoBase"}, + } + + def __init__(self, *, copy_after: "_models.CopyOption", data_store: "_models.DataStoreInfoBase", **kwargs): + """ + :keyword copy_after: It can be CustomCopyOption or ImmediateCopyOption. Required. + :paramtype copy_after: ~azure.mgmt.dataprotection.models.CopyOption + :keyword data_store: Info of target datastore. Required. + :paramtype data_store: ~azure.mgmt.dataprotection.models.DataStoreInfoBase + """ + super().__init__(**kwargs) self.copy_after = copy_after self.data_store = data_store -class TargetDetails(msrest.serialization.Model): +class TargetDetails(_serialization.Model): """Class encapsulating target details, used where the destination is not a datasource. All required parameters must be populated in order to send to Azure. - :param file_prefix: Required. Restore operation may create multiple files inside location - pointed by Url - Below will be the common prefix for all of them. - :type file_prefix: str - :param restore_target_location_type: Required. Denotes the target location where the data will - be restored, + :ivar file_prefix: Restore operation may create multiple files inside location pointed by Url + Below will be the common prefix for all of them. Required. + :vartype file_prefix: str + :ivar restore_target_location_type: Denotes the target location where the data will be + restored, string value for the enum {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}. - Possible values include: "Invalid", "AzureBlobs", "AzureFiles". - :type restore_target_location_type: str or + Required. Known values are: "Invalid", "AzureBlobs", and "AzureFiles". + :vartype restore_target_location_type: str or ~azure.mgmt.dataprotection.models.RestoreTargetLocationType - :param url: Required. Url denoting the restore destination. It can point to container / file - share etc. - :type url: str + :ivar url: Url denoting the restore destination. It can point to container / file share etc. + Required. + :vartype url: str """ _validation = { - 'file_prefix': {'required': True}, - 'restore_target_location_type': {'required': True}, - 'url': {'required': True}, + "file_prefix": {"required": True}, + "restore_target_location_type": {"required": True}, + "url": {"required": True}, } _attribute_map = { - 'file_prefix': {'key': 'filePrefix', 'type': 'str'}, - 'restore_target_location_type': {'key': 'restoreTargetLocationType', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, + "file_prefix": {"key": "filePrefix", "type": "str"}, + "restore_target_location_type": {"key": "restoreTargetLocationType", "type": "str"}, + "url": {"key": "url", "type": "str"}, } def __init__( self, *, file_prefix: str, - restore_target_location_type: Union[str, "RestoreTargetLocationType"], + restore_target_location_type: Union[str, "_models.RestoreTargetLocationType"], url: str, **kwargs ): - super(TargetDetails, self).__init__(**kwargs) + """ + :keyword file_prefix: Restore operation may create multiple files inside location pointed by + Url + Below will be the common prefix for all of them. Required. + :paramtype file_prefix: str + :keyword restore_target_location_type: Denotes the target location where the data will be + restored, + string value for the enum + {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}. + Required. Known values are: "Invalid", "AzureBlobs", and "AzureFiles". + :paramtype restore_target_location_type: str or + ~azure.mgmt.dataprotection.models.RestoreTargetLocationType + :keyword url: Url denoting the restore destination. It can point to container / file share etc. + Required. + :paramtype url: str + """ + super().__init__(**kwargs) self.file_prefix = file_prefix self.restore_target_location_type = restore_target_location_type self.url = url -class TriggerBackupRequest(msrest.serialization.Model): +class TriggerBackupRequest(_serialization.Model): """Trigger backup request. All required parameters must be populated in order to send to Azure. - :param backup_rule_options: Required. Name for the Rule of the Policy which needs to be applied - for this backup. - :type backup_rule_options: ~azure.mgmt.dataprotection.models.AdHocBackupRuleOptions + :ivar backup_rule_options: Name for the Rule of the Policy which needs to be applied for this + backup. Required. + :vartype backup_rule_options: ~azure.mgmt.dataprotection.models.AdHocBackupRuleOptions """ _validation = { - 'backup_rule_options': {'required': True}, + "backup_rule_options": {"required": True}, } _attribute_map = { - 'backup_rule_options': {'key': 'backupRuleOptions', 'type': 'AdHocBackupRuleOptions'}, + "backup_rule_options": {"key": "backupRuleOptions", "type": "AdHocBackupRuleOptions"}, + } + + def __init__(self, *, backup_rule_options: "_models.AdHocBackupRuleOptions", **kwargs): + """ + :keyword backup_rule_options: Name for the Rule of the Policy which needs to be applied for + this backup. Required. + :paramtype backup_rule_options: ~azure.mgmt.dataprotection.models.AdHocBackupRuleOptions + """ + super().__init__(**kwargs) + self.backup_rule_options = backup_rule_options + + +class UnlockDeleteRequest(_serialization.Model): + """Request body of unlock delete API. + + :ivar resource_guard_operation_requests: + :vartype resource_guard_operation_requests: list[str] + :ivar resource_to_be_deleted: + :vartype resource_to_be_deleted: str + """ + + _attribute_map = { + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, + "resource_to_be_deleted": {"key": "resourceToBeDeleted", "type": "str"}, } def __init__( self, *, - backup_rule_options: "AdHocBackupRuleOptions", + resource_guard_operation_requests: Optional[List[str]] = None, + resource_to_be_deleted: Optional[str] = None, **kwargs ): - super(TriggerBackupRequest, self).__init__(**kwargs) - self.backup_rule_options = backup_rule_options + """ + :keyword resource_guard_operation_requests: + :paramtype resource_guard_operation_requests: list[str] + :keyword resource_to_be_deleted: + :paramtype resource_to_be_deleted: str + """ + super().__init__(**kwargs) + self.resource_guard_operation_requests = resource_guard_operation_requests + self.resource_to_be_deleted = resource_to_be_deleted + + +class UnlockDeleteResponse(_serialization.Model): + """Response of Unlock Delete API. + + :ivar unlock_delete_expiry_time: This is the time when unlock delete privileges will get + expired. + :vartype unlock_delete_expiry_time: str + """ + + _attribute_map = { + "unlock_delete_expiry_time": {"key": "unlockDeleteExpiryTime", "type": "str"}, + } + + def __init__(self, *, unlock_delete_expiry_time: Optional[str] = None, **kwargs): + """ + :keyword unlock_delete_expiry_time: This is the time when unlock delete privileges will get + expired. + :paramtype unlock_delete_expiry_time: str + """ + super().__init__(**kwargs) + self.unlock_delete_expiry_time = unlock_delete_expiry_time -class UserFacingError(msrest.serialization.Model): +class UserFacingError(_serialization.Model): """Error object used by layers that have access to localized content, and propagate that to user. - :param code: Unique code for this error. - :type code: str - :param details: Additional related Errors. - :type details: list[~azure.mgmt.dataprotection.models.UserFacingError] - :param inner_error: Inner Error. - :type inner_error: ~azure.mgmt.dataprotection.models.InnerError - :param is_retryable: Whether the operation will be retryable or not. - :type is_retryable: bool - :param is_user_error: Whether the operation is due to a user error or service error. - :type is_user_error: bool - :param properties: Any key value pairs that can be injected inside error object. - :type properties: dict[str, str] - :param message: - :type message: str - :param recommended_action: RecommendedAction � localized. - :type recommended_action: list[str] - :param target: Target of the error. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[UserFacingError]'}, - 'inner_error': {'key': 'innerError', 'type': 'InnerError'}, - 'is_retryable': {'key': 'isRetryable', 'type': 'bool'}, - 'is_user_error': {'key': 'isUserError', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'message': {'key': 'message', 'type': 'str'}, - 'recommended_action': {'key': 'recommendedAction', 'type': '[str]'}, - 'target': {'key': 'target', 'type': 'str'}, + :ivar code: Unique code for this error. + :vartype code: str + :ivar details: Additional related Errors. + :vartype details: list[~azure.mgmt.dataprotection.models.UserFacingError] + :ivar inner_error: Inner Error. + :vartype inner_error: ~azure.mgmt.dataprotection.models.InnerError + :ivar is_retryable: Whether the operation will be retryable or not. + :vartype is_retryable: bool + :ivar is_user_error: Whether the operation is due to a user error or service error. + :vartype is_user_error: bool + :ivar properties: Any key value pairs that can be injected inside error object. + :vartype properties: dict[str, str] + :ivar message: + :vartype message: str + :ivar recommended_action: RecommendedAction � localized. + :vartype recommended_action: list[str] + :ivar target: Target of the error. + :vartype target: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "details": {"key": "details", "type": "[UserFacingError]"}, + "inner_error": {"key": "innerError", "type": "InnerError"}, + "is_retryable": {"key": "isRetryable", "type": "bool"}, + "is_user_error": {"key": "isUserError", "type": "bool"}, + "properties": {"key": "properties", "type": "{str}"}, + "message": {"key": "message", "type": "str"}, + "recommended_action": {"key": "recommendedAction", "type": "[str]"}, + "target": {"key": "target", "type": "str"}, } def __init__( self, *, code: Optional[str] = None, - details: Optional[List["UserFacingError"]] = None, - inner_error: Optional["InnerError"] = None, + details: Optional[List["_models.UserFacingError"]] = None, + inner_error: Optional["_models.InnerError"] = None, is_retryable: Optional[bool] = None, is_user_error: Optional[bool] = None, properties: Optional[Dict[str, str]] = None, @@ -4529,7 +5933,27 @@ def __init__( target: Optional[str] = None, **kwargs ): - super(UserFacingError, self).__init__(**kwargs) + """ + :keyword code: Unique code for this error. + :paramtype code: str + :keyword details: Additional related Errors. + :paramtype details: list[~azure.mgmt.dataprotection.models.UserFacingError] + :keyword inner_error: Inner Error. + :paramtype inner_error: ~azure.mgmt.dataprotection.models.InnerError + :keyword is_retryable: Whether the operation will be retryable or not. + :paramtype is_retryable: bool + :keyword is_user_error: Whether the operation is due to a user error or service error. + :paramtype is_user_error: bool + :keyword properties: Any key value pairs that can be injected inside error object. + :paramtype properties: dict[str, str] + :keyword message: + :paramtype message: str + :keyword recommended_action: RecommendedAction � localized. + :paramtype recommended_action: list[str] + :keyword target: Target of the error. + :paramtype target: str + """ + super().__init__(**kwargs) self.code = code self.details = details self.inner_error = inner_error @@ -4541,55 +5965,53 @@ def __init__( self.target = target -class ValidateForBackupRequest(msrest.serialization.Model): +class ValidateForBackupRequest(_serialization.Model): """Validate for backup request. All required parameters must be populated in order to send to Azure. - :param backup_instance: Required. Backup Instance. - :type backup_instance: ~azure.mgmt.dataprotection.models.BackupInstance + :ivar backup_instance: Backup Instance. Required. + :vartype backup_instance: ~azure.mgmt.dataprotection.models.BackupInstance """ _validation = { - 'backup_instance': {'required': True}, + "backup_instance": {"required": True}, } _attribute_map = { - 'backup_instance': {'key': 'backupInstance', 'type': 'BackupInstance'}, + "backup_instance": {"key": "backupInstance", "type": "BackupInstance"}, } - def __init__( - self, - *, - backup_instance: "BackupInstance", - **kwargs - ): - super(ValidateForBackupRequest, self).__init__(**kwargs) + def __init__(self, *, backup_instance: "_models.BackupInstance", **kwargs): + """ + :keyword backup_instance: Backup Instance. Required. + :paramtype backup_instance: ~azure.mgmt.dataprotection.models.BackupInstance + """ + super().__init__(**kwargs) self.backup_instance = backup_instance -class ValidateRestoreRequestObject(msrest.serialization.Model): +class ValidateRestoreRequestObject(_serialization.Model): """Validate restore request object. All required parameters must be populated in order to send to Azure. - :param restore_request_object: Required. Gets or sets the restore request object. - :type restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :ivar restore_request_object: Gets or sets the restore request object. Required. + :vartype restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest """ _validation = { - 'restore_request_object': {'required': True}, + "restore_request_object": {"required": True}, } _attribute_map = { - 'restore_request_object': {'key': 'restoreRequestObject', 'type': 'AzureBackupRestoreRequest'}, + "restore_request_object": {"key": "restoreRequestObject", "type": "AzureBackupRestoreRequest"}, } - def __init__( - self, - *, - restore_request_object: "AzureBackupRestoreRequest", - **kwargs - ): - super(ValidateRestoreRequestObject, self).__init__(**kwargs) + def __init__(self, *, restore_request_object: "_models.AzureBackupRestoreRequest", **kwargs): + """ + :keyword restore_request_object: Gets or sets the restore request object. Required. + :paramtype restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + """ + super().__init__(**kwargs) self.restore_request_object = restore_request_object diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_patch.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py index f9c765bb82a0..0685deeec279 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py @@ -9,31 +9,47 @@ from ._backup_vaults_operations import BackupVaultsOperations from ._operation_result_operations import OperationResultOperations from ._operation_status_operations import OperationStatusOperations +from ._operation_status_backup_vault_context_operations import OperationStatusBackupVaultContextOperations +from ._operation_status_resource_group_context_operations import OperationStatusResourceGroupContextOperations from ._backup_vault_operation_results_operations import BackupVaultOperationResultsOperations from ._data_protection_operations import DataProtectionOperations from ._data_protection_operations_operations import DataProtectionOperationsOperations from ._backup_policies_operations import BackupPoliciesOperations from ._backup_instances_operations import BackupInstancesOperations +from ._backup_instances_extension_routing_operations import BackupInstancesExtensionRoutingOperations from ._recovery_points_operations import RecoveryPointsOperations from ._jobs_operations import JobsOperations from ._restorable_time_ranges_operations import RestorableTimeRangesOperations from ._export_jobs_operations import ExportJobsOperations from ._export_jobs_operation_result_operations import ExportJobsOperationResultOperations +from ._deleted_backup_instances_operations import DeletedBackupInstancesOperations from ._resource_guards_operations import ResourceGuardsOperations +from ._dpp_resource_guard_proxy_operations import DppResourceGuardProxyOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'BackupVaultsOperations', - 'OperationResultOperations', - 'OperationStatusOperations', - 'BackupVaultOperationResultsOperations', - 'DataProtectionOperations', - 'DataProtectionOperationsOperations', - 'BackupPoliciesOperations', - 'BackupInstancesOperations', - 'RecoveryPointsOperations', - 'JobsOperations', - 'RestorableTimeRangesOperations', - 'ExportJobsOperations', - 'ExportJobsOperationResultOperations', - 'ResourceGuardsOperations', + "BackupVaultsOperations", + "OperationResultOperations", + "OperationStatusOperations", + "OperationStatusBackupVaultContextOperations", + "OperationStatusResourceGroupContextOperations", + "BackupVaultOperationResultsOperations", + "DataProtectionOperations", + "DataProtectionOperationsOperations", + "BackupPoliciesOperations", + "BackupInstancesOperations", + "BackupInstancesExtensionRoutingOperations", + "RecoveryPointsOperations", + "JobsOperations", + "RestorableTimeRangesOperations", + "ExportJobsOperations", + "ExportJobsOperationResultOperations", + "DeletedBackupInstancesOperations", + "ResourceGuardsOperations", + "DppResourceGuardProxyOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_extension_routing_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_extension_routing_operations.py new file mode 100644 index 000000000000..9e78b6dae6e0 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_extension_routing_operations.py @@ -0,0 +1,156 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.DataProtection/backupInstances") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupInstancesExtensionRoutingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`backup_instances_extension_routing` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_id: str, **kwargs: Any) -> Iterable["_models.BackupInstanceResource"]: + """Gets a list backup instances associated with a tracked resource. + + :param resource_id: ARM path of the resource to be protected using Microsoft.DataProtection. + Required. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BackupInstanceResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResourceList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceId}/providers/Microsoft.DataProtection/backupInstances"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py index 68829a4eb021..216b1acabc95 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,619 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_adhoc_backup_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_for_backup_request( + resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_backup_instance_operation_result_request( + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/operationResults/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_trigger_rehydrate_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_trigger_restore_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resume_backups_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resume_protection_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_protection_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_suspend_backups_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_backup_instance_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class BackupInstancesOperations(object): - """BackupInstancesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_for_restore_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupInstancesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`backup_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( - self, - vault_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BackupInstanceResourceList"] + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.BackupInstanceResource"]: """Gets a backup instances belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupInstanceResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupInstanceResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BackupInstanceResourceList', pipeline_response) + deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,7 +627,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,376 +638,1590 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances"} # type: ignore + @distributed_trace def get( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BackupInstanceResource" + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> _models.BackupInstanceResource: """Gets a backup instance with name in a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupInstanceResource, or the result of cls(response) + :return: BackupInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore def _create_or_update_initial( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.BackupInstanceResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.BackupInstanceResource" - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResource"] + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.BackupInstanceResource, IO], + **kwargs: Any + ) -> Optional[_models.BackupInstanceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupInstanceResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInstanceResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackupInstanceResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.BackupInstanceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupInstanceResource]: + """Create or update a backup instance in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupInstanceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupInstanceResource]: + """Create or update a backup instance in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupInstanceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.BackupInstanceResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BackupInstanceResource]: + """Create or update a backup instance in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupInstanceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInstanceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a backup instance in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}"} # type: ignore + + def _adhoc_backup_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.TriggerBackupRequest, IO], + **kwargs: Any + ) -> Optional[_models.OperationJobExtendedInfo]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TriggerBackupRequest") + + request = build_adhoc_backup_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._adhoc_backup_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore - def begin_create_or_update( + _adhoc_backup_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup"} # type: ignore + + @overload + def begin_adhoc_backup( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.TriggerBackupRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Trigger adhoc backup. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_adhoc_backup( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Trigger adhoc backup. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_adhoc_backup( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.TriggerBackupRequest, IO], + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Trigger adhoc backup. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._adhoc_backup_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_adhoc_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup"} # type: ignore + + def _validate_for_backup_initial( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.ValidateForBackupRequest, IO], + **kwargs: Any + ) -> Optional[_models.OperationJobExtendedInfo]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ValidateForBackupRequest") + + request = build_validate_for_backup_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_for_backup_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _validate_for_backup_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup"} # type: ignore + + @overload + def begin_validate_for_backup( + self, + resource_group_name: str, + vault_name: str, + parameters: _models.ValidateForBackupRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Validate whether adhoc backup will be successful or not. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_for_backup( + self, + resource_group_name: str, + vault_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Validate whether adhoc backup will be successful or not. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_for_backup( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.ValidateForBackupRequest, IO], + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Validate whether adhoc backup will be successful or not. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_for_backup_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_validate_for_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup"} # type: ignore + + @distributed_trace + def get_backup_instance_operation_result( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.BackupInstanceResource]: + """Get result of backup instance creation operation. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param operation_id: Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BackupInstanceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInstanceResource]] + + request = build_get_backup_instance_operation_result_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_backup_instance_operation_result.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_backup_instance_operation_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/operationResults/{operationId}"} # type: ignore + + def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRehydrationRequest, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureBackupRehydrationRequest") + + request = build_trigger_rehydrate_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._trigger_rehydrate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _trigger_rehydrate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate"} # type: ignore + + @overload + def begin_trigger_rehydrate( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.AzureBackupRehydrationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """rehydrate recovery point for restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_trigger_rehydrate( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """rehydrate recovery point for restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_trigger_rehydrate( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRehydrationRequest, IO], + **kwargs: Any + ) -> LROPoller[None]: + """rehydrate recovery point for restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._trigger_rehydrate_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_trigger_rehydrate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate"} # type: ignore + + def _trigger_restore_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRestoreRequest, IO], + **kwargs: Any + ) -> Optional[_models.OperationJobExtendedInfo]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureBackupRestoreRequest") + + request = build_trigger_restore_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._trigger_restore_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _trigger_restore_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore"} # type: ignore + + @overload + def begin_trigger_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.AzureBackupRestoreRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Triggers restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_trigger_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Triggers restore for a BackupInstance. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_trigger_restore( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.BackupInstanceResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupInstanceResource"] - """Create or update a backup instance in a backup vault. + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupRestoreRequest, IO], + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Triggers restore for a BackupInstance. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BackupInstanceResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupInstanceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( - vault_name=vault_name, + raw_result = self._trigger_restore_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInstanceResource', pipeline_response) - + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_trigger_restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore"} # type: ignore + + def _resume_backups_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resume_backups_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._resume_backups_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, None, response_headers) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + _resume_backups_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups"} # type: ignore - def begin_delete( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Delete a backup instance in a backup vault. + @distributed_trace + def begin_resume_backups( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """This operation will resume backups for backup instance. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. :type backup_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( - vault_name=vault_name, + raw_result = self._resume_backups_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _adhoc_backup_initial( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.TriggerBackupRequest" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationJobExtendedInfo"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + begin_resume_backups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups"} # type: ignore + + def _resume_protection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._adhoc_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TriggerBackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resume_protection_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._resume_protection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -494,138 +2229,119 @@ def _adhoc_backup_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, None, response_headers) - return deserialized - _adhoc_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup'} # type: ignore + _resume_protection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection"} # type: ignore - def begin_adhoc_backup( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.TriggerBackupRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationJobExtendedInfo"] - """Trigger adhoc backup. + @distributed_trace + def begin_resume_protection( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """This operation will resume protection for a stopped backup instance. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._adhoc_backup_initial( - vault_name=vault_name, + raw_result = self._resume_protection_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, - parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } + return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_adhoc_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _validate_for_backup_initial( - self, - vault_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.ValidateForBackupRequest" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationJobExtendedInfo"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + begin_resume_protection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection"} # type: ignore + + def _stop_protection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_for_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ValidateForBackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_protection_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._stop_protection_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -633,268 +2349,257 @@ def _validate_for_backup_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, None, response_headers) - return deserialized - _validate_for_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup'} # type: ignore + _stop_protection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection"} # type: ignore - def begin_validate_for_backup( - self, - vault_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.ValidateForBackupRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationJobExtendedInfo"] - """Validate whether adhoc backup will be successful or not. + @distributed_trace + def begin_stop_protection( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """This operation will stop protection of a backup instance and data will be held forever. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_for_backup_initial( - vault_name=vault_name, + raw_result = self._stop_protection_initial( # type: ignore resource_group_name=resource_group_name, - parameters=parameters, - cls=lambda x,y,z: x, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } + return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_for_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _trigger_rehydrate_initial( - self, - resource_group_name, # type: str - vault_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.AzureBackupRehydrationRequest" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_stop_protection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection"} # type: ignore + + def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_rehydrate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureBackupRehydrationRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_suspend_backups_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._suspend_backups_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, None, response_headers) - _trigger_rehydrate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate'} # type: ignore + _suspend_backups_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups"} # type: ignore - def begin_trigger_rehydrate( - self, - resource_group_name, # type: str - vault_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.AzureBackupRehydrationRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """rehydrate recovery point for restore for a BackupInstance. + @distributed_trace + def begin_suspend_backups( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """This operation will stop backup for a backup instance and retains the backup data as per the + policy (except latest Recovery point, which will be retained forever). :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str - :param backup_instance_name: + :param backup_instance_name: Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._trigger_rehydrate_initial( + raw_result = self._suspend_backups_initial( # type: ignore resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, - parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_trigger_rehydrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _trigger_restore_initial( + begin_suspend_backups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups"} # type: ignore + + def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statements self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.AzureBackupRestoreRequest" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationJobExtendedInfo"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.SyncBackupInstanceRequest, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureBackupRestoreRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncBackupInstanceRequest") + + request = build_sync_backup_instance_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._sync_backup_instance_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -902,235 +2607,413 @@ def _trigger_restore_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, None, response_headers) - return deserialized - _trigger_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore'} # type: ignore + _sync_backup_instance_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync"} # type: ignore - def begin_trigger_restore( + @overload + def begin_sync_backup_instance( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.AzureBackupRestoreRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationJobExtendedInfo"] - """Triggers restore for a BackupInstance. + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.SyncBackupInstanceRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Sync backup instance again in case of failure + This action will retry last failed operation and will bring backup instance to valid state. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_sync_backup_instance( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Sync backup instance again in case of failure + This action will retry last failed operation and will bring backup instance to valid state. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_sync_backup_instance( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.SyncBackupInstanceRequest, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Sync backup instance again in case of failure + This action will retry last failed operation and will bring backup instance to valid state. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: Required. :type backup_instance_name: str - :param parameters: Request body for operation. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._trigger_restore_initial( - vault_name=vault_name, + raw_result = self._sync_backup_instance_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } + return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_trigger_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_sync_backup_instance.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync"} # type: ignore def _validate_for_restore_initial( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.ValidateRestoreRequestObject" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationJobExtendedInfo"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.ValidateRestoreRequestObject, IO], + **kwargs: Any + ) -> Optional[_models.OperationJobExtendedInfo]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_for_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ValidateRestoreRequestObject') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ValidateRestoreRequestObject") + + request = build_validate_for_restore_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_for_restore_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _validate_for_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore'} # type: ignore + _validate_for_restore_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore"} # type: ignore + + @overload def begin_validate_for_restore( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.ValidateRestoreRequestObject" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationJobExtendedInfo"] + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.ValidateRestoreRequestObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: """Validates if Restore can be triggered for a DataSource. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationJobExtendedInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_for_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Validates if Restore can be triggered for a DataSource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_for_restore( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.ValidateRestoreRequestObject, IO], + **kwargs: Any + ) -> LROPoller[_models.OperationJobExtendedInfo]: + """Validates if Restore can be triggered for a DataSource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.OperationJobExtendedInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationJobExtendedInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_for_restore_initial( - vault_name=vault_name, + raw_result = self._validate_for_restore_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) - + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_for_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_validate_for_restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py index 66ec3395e92e..22ea2028deb7 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,243 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, vault_name: str, backup_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupPolicyName": _SERIALIZER.url("backup_policy_name", backup_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, vault_name: str, backup_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupPolicyName": _SERIALIZER.url("backup_policy_name", backup_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class BackupPoliciesOperations(object): - """BackupPoliciesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_delete_request( + resource_group_name: str, vault_name: str, backup_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupPolicyName": _SERIALIZER.url("backup_policy_name", backup_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`backup_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( - self, - vault_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BaseBackupPolicyResourceList"] + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.BaseBackupPolicyResource"]: """Returns list of backup policies belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BaseBackupPolicyResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BaseBackupPolicyResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BaseBackupPolicyResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BaseBackupPolicyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaseBackupPolicyResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BaseBackupPolicyResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BaseBackupPolicyResourceList', pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +251,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,200 +262,281 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies"} # type: ignore + + @distributed_trace def get( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BaseBackupPolicyResource" + self, resource_group_name: str, vault_name: str, backup_policy_name: str, **kwargs: Any + ) -> _models.BaseBackupPolicyResource: """Gets a backup policy belonging to a backup vault. Gets a backup policy belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_policy_name: + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Required. :type backup_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaseBackupPolicyResource, or the result of cls(response) + :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaseBackupPolicyResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupPolicyName': self._serialize.url("backup_policy_name", backup_policy_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BaseBackupPolicyResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_policy_name=backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BaseBackupPolicyResource', pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}"} # type: ignore + + @overload def create_or_update( self, - vault_name, # type: str - resource_group_name, # type: str - backup_policy_name, # type: str - parameters, # type: "_models.BaseBackupPolicyResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.BaseBackupPolicyResource" + resource_group_name: str, + vault_name: str, + backup_policy_name: str, + parameters: _models.BaseBackupPolicyResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BaseBackupPolicyResource: """Creates or Updates a backup policy belonging to a backup vault. Creates or Updates a backup policy belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_policy_name: Name of the policy. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Name of the policy. Required. :type backup_policy_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BaseBackupPolicyResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BaseBackupPolicyResource: + """Creates or Updates a backup policy belonging to a backup vault. + + Creates or Updates a backup policy belonging to a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Name of the policy. Required. + :type backup_policy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaseBackupPolicyResource, or the result of cls(response) + :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + backup_policy_name: str, + parameters: Union[_models.BaseBackupPolicyResource, IO], + **kwargs: Any + ) -> _models.BaseBackupPolicyResource: + """Creates or Updates a backup policy belonging to a backup vault. + + Creates or Updates a backup policy belonging to a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Name of the policy. Required. + :type backup_policy_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BaseBackupPolicyResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaseBackupPolicyResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupPolicyName': self._serialize.url("backup_policy_name", backup_policy_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BaseBackupPolicyResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BaseBackupPolicyResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BaseBackupPolicyResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_policy_name=backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BaseBackupPolicyResource', pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}'} # type: ignore - def delete( - self, - vault_name, # type: str - resource_group_name, # type: str - backup_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_policy_name: str, **kwargs: Any + ) -> None: """Deletes a backup policy belonging to a backup vault. Deletes a backup policy belonging to a backup vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_policy_name: + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_policy_name: Required. :type backup_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupPolicyName': self._serialize.url("backup_policy_name", backup_policy_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_policy_name=backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -318,4 +546,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py index a04e8c5e27a8..1fafff55677a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, vault_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class BackupVaultOperationResultsOperations(object): - """BackupVaultOperationResultsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackupVaultOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`backup_vault_operation_results` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( - self, - vault_name, # type: str - resource_group_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BackupVaultResource"] + self, resource_group_name: str, vault_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.BackupVaultResource]: """get. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param operation_id: + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param operation_id: Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupVaultResource, or the result of cls(response) + :return: BackupVaultResource or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupVaultResource"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupVaultResource]] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py index d7894a30a873..b6f194921f22 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,316 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_in_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_in_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class BackupVaultsOperations(object): - """BackupVaultsOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request( + resource_group_name: str, location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupVaultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`backup_vaults` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get_in_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BackupVaultResourceList"] + @distributed_trace + def get_in_subscription(self, **kwargs: Any) -> Iterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupVaultResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupVaultResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_in_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BackupVaultResourceList', pipeline_response) + deserialized = self._deserialize("BackupVaultResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,7 +324,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,60 +335,63 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults'} # type: ignore + return ItemPaged(get_next, extract_data) - def get_in_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BackupVaultResourceList"] + get_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults"} # type: ignore + + @distributed_trace + def get_in_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackupVaultResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupVaultResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_in_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_in_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BackupVaultResourceList', pipeline_response) + deserialized = self._deserialize("BackupVaultResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -171,7 +400,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,110 +411,118 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_in_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - vault_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BackupVaultResource" + get_in_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.BackupVaultResource: """Returns a resource belonging to a resource group. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupVaultResource, or the result of cls(response) + :return: BackupVaultResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore def _create_or_update_initial( self, - vault_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BackupVaultResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.BackupVaultResource" - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] + resource_group_name: str, + vault_name: str, + parameters: Union[_models.BackupVaultResource, IO], + **kwargs: Any + ) -> _models.BackupVaultResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupVaultResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackupVaultResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -291,134 +530,215 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @overload def begin_create_or_update( self, - vault_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BackupVaultResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupVaultResource"] + resource_group_name: str, + vault_name: str, + parameters: _models.BackupVaultResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVaultResource]: """Creates or updates a BackupVault resource belonging to a resource group. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param parameters: Request body for operation. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupVaultResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVaultResource]: + """Creates or updates a BackupVault resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.BackupVaultResource, IO], + **kwargs: Any + ) -> LROPoller[_models.BackupVaultResource]: + """Creates or updates a BackupVault resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( - vault_name=vault_name, + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupVaultResource', pipeline_response) - + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def delete( - self, - vault_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> None: """Deletes a BackupVault resource from the resource group. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -428,48 +748,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore def _update_initial( self, - vault_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.PatchResourceRequestInput" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BackupVaultResource"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BackupVaultResource"]] + resource_group_name: str, + vault_name: str, + parameters: Union[_models.PatchResourceRequestInput, IO], + **kwargs: Any + ) -> Optional[_models.BackupVaultResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PatchResourceRequestInput') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupVaultResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PatchResourceRequestInput") + + request = build_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -478,152 +807,310 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupVaultResource', pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @overload def begin_update( self, - vault_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.PatchResourceRequestInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BackupVaultResource"] + resource_group_name: str, + vault_name: str, + parameters: _models.PatchResourceRequestInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVaultResource]: """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a resource. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param parameters: Request body for operation. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupVaultResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackupVaultResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + vault_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVaultResource]: + """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a + resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.PatchResourceRequestInput, IO], + **kwargs: Any + ) -> LROPoller[_models.BackupVaultResource]: + """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a + resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BackupVaultResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupVaultResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( - vault_name=vault_name, + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, + vault_name=vault_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupVaultResource', pipeline_response) - + deserialized = self._deserialize("BackupVaultResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}"} # type: ignore + + @overload def check_name_availability( self, - resource_group_name, # type: str - location, # type: str - parameters, # type: "_models.CheckNameAvailabilityRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + resource_group_name: str, + location: str, + parameters: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: """API to check for resource name availability. API to check for resource name availability. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param location: The location in which uniqueness will be verified. + :param location: The location in which uniqueness will be verified. Required. :type location: str - :param parameters: Check name availability request. + :param parameters: Check name availability request. Required. :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + location: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """API to check for resource name availability. + + API to check for resource name availability. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param parameters: Check name availability request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + location: str, + parameters: Union[_models.CheckNameAvailabilityRequest, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """API to check for resource name availability. + + API to check for resource name availability. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param location: The location in which uniqueness will be verified. Required. + :type location: str + :param parameters: Check name availability request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailabilityRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability'} # type: ignore + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py index 47420332c4c3..a82198ee8114 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_check_feature_support_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } -class DataProtectionOperations(object): - """DataProtectionOperations operations. + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DataProtectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`data_protection` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload def check_feature_support( self, - location, # type: str - parameters, # type: "_models.FeatureValidationRequestBase" - **kwargs # type: Any - ): - # type: (...) -> "_models.FeatureValidationResponseBase" + location: str, + parameters: _models.FeatureValidationRequestBase, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FeatureValidationResponseBase: """Validates if a feature is supported. Validates if a feature is supported. - :param location: + :param location: Required. :type location: str - :param parameters: Feature support request object. + :param parameters: Feature support request object. Required. :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureValidationResponseBase, or the result of cls(response) + :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_feature_support( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FeatureValidationResponseBase: + """Validates if a feature is supported. + + Validates if a feature is supported. + + :param location: Required. + :type location: str + :param parameters: Feature support request object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureValidationResponseBase or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_feature_support( + self, location: str, parameters: Union[_models.FeatureValidationRequestBase, IO], **kwargs: Any + ) -> _models.FeatureValidationResponseBase: + """Validates if a feature is supported. + + Validates if a feature is supported. + + :param location: Required. + :type location: str + :param parameters: Feature support request object. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureValidationResponseBase or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureValidationResponseBase"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_feature_support.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'FeatureValidationRequestBase') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureValidationResponseBase] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FeatureValidationRequestBase") + + request = build_check_feature_support_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_feature_support.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureValidationResponseBase', pipeline_response) + deserialized = self._deserialize("FeatureValidationResponseBase", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_feature_support.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport'} # type: ignore + + check_feature_support.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py index aa0b0343c117..645f9aeb40c2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,124 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -class DataProtectionOperationsOperations(object): - """DataProtectionOperationsOperations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataProtection/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DataProtectionOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`data_protection_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClientDiscoveryResponse"] + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ClientDiscoveryValueForSingleApi"]: """Returns the list of available operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClientDiscoveryResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ClientDiscoveryResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClientDiscoveryValueForSingleApi or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ClientDiscoveryValueForSingleApi] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientDiscoveryResponse"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientDiscoveryResponse] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClientDiscoveryResponse', pipeline_response) + deserialized = self._deserialize("ClientDiscoveryResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,7 +132,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +143,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataProtection/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataProtection/operations"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_operations.py new file mode 100644 index 000000000000..81b59c816d69 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_operations.py @@ -0,0 +1,410 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_undelete_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeletedBackupInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`deleted_backup_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.DeletedBackupInstanceResource"]: + """Gets deleted backup instances belonging to a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedBackupInstanceResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedBackupInstanceResourceList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedBackupInstanceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> _models.DeletedBackupInstanceResource: + """Gets a deleted backup instance with name in a backup vault. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the deleted backup instance. Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedBackupInstanceResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedBackupInstanceResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedBackupInstanceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}"} # type: ignore + + def _undelete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_undelete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._undelete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _undelete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete"} # type: ignore + + @distributed_trace + def begin_undelete( + self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """undelete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the deleted backup instance. Required. + :type backup_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._undelete_initial( # type: ignore + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_undelete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py new file mode 100644 index 000000000000..f638be14b0a9 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py @@ -0,0 +1,722 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url("resource_guard_proxy_name", resource_guard_proxy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request( + resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url("resource_guard_proxy_name", resource_guard_proxy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url("resource_guard_proxy_name", resource_guard_proxy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_unlock_delete_request( + resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url("resource_guard_proxy_name", resource_guard_proxy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DppResourceGuardProxyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`dpp_resource_guard_proxy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.ResourceGuardProxyBaseResource"]: + """list. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceGuardProxyBaseResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardProxyBaseResourceList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceGuardProxyBaseResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """get. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardProxyBaseResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"} # type: ignore + + @overload + def put( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.ResourceGuardProxyBaseResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """put. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """put. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.ResourceGuardProxyBaseResource, IO], + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """put. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardProxyBaseResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGuardProxyBaseResource") + + request = build_put_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> None: + """delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"} # type: ignore + + @overload + def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.UnlockDeleteRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """unlock_delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """unlock_delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.UnlockDeleteRequest, IO], + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """unlock_delete. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param resource_guard_proxy_name: Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UnlockDeleteResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UnlockDeleteRequest") + + request = build_unlock_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.unlock_delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + unlock_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py index a22827dafd75..3b96bc806ad1 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, vault_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + _url = _format_url_section(_url, **path_format_arguments) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class ExportJobsOperationResultOperations(object): - """ExportJobsOperationResultOperations operations. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + +class ExportJobsOperationResultOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`export_jobs_operation_result` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( - self, - resource_group_name, # type: str - vault_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ExportJobsResult"] + self, resource_group_name: str, vault_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.ExportJobsResult]: """Gets the operation result of operation triggered by Export Jobs API. If the operation is successful, then it also contains URL of a Blob and a SAS key to access the same. The blob contains exported jobs in JSON serialized format. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str - :param operation_id: OperationID which represents the export job. + :param operation_id: OperationID which represents the export job. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportJobsResult, or the result of cls(response) + :return: ExportJobsResult or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ExportJobsResult or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExportJobsResult"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExportJobsResult]] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -103,10 +144,11 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ExportJobsResult', pipeline_response) + deserialized = self._deserialize("ExportJobsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py index 9fd4f08a874e..6baab11c9cde 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,119 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_trigger_request( + resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class ExportJobsOperations(object): - """ExportJobsOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ExportJobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`export_jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def _trigger_initial( - self, - resource_group_name, # type: str - vault_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _trigger_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._trigger_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_trigger_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._trigger_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -88,75 +127,74 @@ def _trigger_initial( response_headers = {} if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, None, response_headers) - _trigger_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs'} # type: ignore + _trigger_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs"} # type: ignore - def begin_trigger( - self, - resource_group_name, # type: str - vault_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> LROPoller[None]: """Triggers export of jobs and returns an OperationID to track. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._trigger_initial( + raw_result = self._trigger_initial( # type: ignore resource_group_name=resource_group_name, vault_name=vault_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_trigger.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py index 1e7e0d74d189..e86cdc496442 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class JobsOperations(object): - """JobsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, vault_name: str, job_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( - self, - resource_group_name, # type: str - vault_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureBackupJobResourceList"] + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.AzureBackupJobResource"]: """Returns list of jobs belonging to a backup vault. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBackupJobResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureBackupJobResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupJobResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupJobResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBackupJobResourceList', pipeline_response) + deserialized = self._deserialize("AzureBackupJobResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +183,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,71 +194,71 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - vault_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureBackupJobResource" + self, resource_group_name: str, vault_name: str, job_id: str, **kwargs: Any + ) -> _models.AzureBackupJobResource: """Gets a job with id in a backup vault. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param vault_name: The name of the backup vault. + :param vault_name: The name of the backup vault. Required. :type vault_name: str :param job_id: The Job ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureBackupJobResource, or the result of cls(response) + :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupJobResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupJobResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureBackupJobResource', pipeline_response) + deserialized = self._deserialize("AzureBackupJobResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py index cd2604a8468c..4870e11386a9 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,148 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(operation_id: str, location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } -class OperationResultOperations(object): - """OperationResultOperations operations. + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationResultOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`operation_result` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - operation_id, # type: str - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationJobExtendedInfo"] + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional[_models.OperationJobExtendedInfo]: """Gets the operation status for a resource. Gets the operation result for a resource. - :param operation_id: + :param operation_id: Required. :type operation_id: str - :param location: + :param location: Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationJobExtendedInfo, or the result of cls(response) + :return: OperationJobExtendedInfo or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationJobExtendedInfo or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationJobExtendedInfo"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationJobExtendedInfo]] + + request = build_get_request( + operation_id=operation_id, + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationJobExtendedInfo', pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_operations.py new file mode 100644 index 000000000000..4d78549ae4cb --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_operations.py @@ -0,0 +1,152 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, vault_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationStatus/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationStatusBackupVaultContextOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`operation_status_backup_vault_context` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, operation_id: str, **kwargs: Any + ) -> _models.OperationResource: + """Gets the operation status for an operation over a BackupVault's context. + + Gets the operation status for an operation over a BackupVault's context. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param operation_id: Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.OperationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResource] + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationStatus/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py index 0bc8bf9eacab..35f3a5c6b441 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,138 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(location: str, operation_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationStatusOperations(object): - """OperationStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - location, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationResource" + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationResource: """Gets the operation status for a resource. Gets the operation status for a resource. - :param location: + :param location: Required. :type location: str - :param operation_id: + :param operation_id: Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResource, or the result of cls(response) + :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResource] + + request = build_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationResource', pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_operations.py new file mode 100644 index 000000000000..baaed93e801e --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_operations.py @@ -0,0 +1,144 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, operation_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/operationStatus/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationStatusResourceGroupContextOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`operation_status_resource_group_context` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _models.OperationResource: + """Gets the operation status for an operation over a ResourceGroup's context. + + Gets the operation status for an operation over a ResourceGroup's context. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param operation_id: Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.OperationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResource] + + request = build_get_request( + resource_group_name=resource_group_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/operationStatus/{operationId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_patch.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py index 935b39fd586f..973323aa06c1 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,113 +6,211 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class RecoveryPointsOperations(object): - """RecoveryPointsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request( + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + recovery_point_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + "recoveryPointId": _SERIALIZER.url("recovery_point_id", recovery_point_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RecoveryPointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`recovery_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - filter=None, # type: Optional[str] - skip_token=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureBackupRecoveryPointResourceList"] + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + filter: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AzureBackupRecoveryPointResource"]: """Returns a list of Recovery Points for a DataSource in a vault. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param filter: OData filter options. + :param filter: OData filter options. Default value is None. :type filter: str - :param skip_token: skipToken Filter. + :param skip_token: skipToken Filter. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBackupRecoveryPointResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupRecoveryPointResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupRecoveryPointResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + skip_token=skip_token, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBackupRecoveryPointResourceList', pipeline_response) + deserialized = self._deserialize("AzureBackupRecoveryPointResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,7 +219,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,74 +230,78 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints"} # type: ignore + @distributed_trace def get( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - recovery_point_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureBackupRecoveryPointResource" + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + recovery_point_id: str, + **kwargs: Any + ) -> _models.AzureBackupRecoveryPointResource: """Gets a Recovery Point using recoveryPointId for a Datasource. - :param vault_name: The name of the backup vault. - :type vault_name: str :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param recovery_point_id: + :param recovery_point_id: Required. :type recovery_point_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureBackupRecoveryPointResource, or the result of cls(response) + :return: AzureBackupRecoveryPointResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupRecoveryPointResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), - 'recoveryPointId': self._serialize.url("recovery_point_id", recovery_point_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupRecoveryPointResource] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + recovery_point_id=recovery_point_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureBackupRecoveryPointResource', pipeline_response) + deserialized = self._deserialize("AzureBackupRecoveryPointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py index a6502b9277ab..339e165dc55d 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,671 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_resources_in_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_resources_in_resource_group_request( + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_patch_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_disable_soft_delete_requests_objects_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_delete_resource_guard_proxy_requests_objects_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_backup_security_pin_requests_objects_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_delete_protected_item_requests_objects_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_get_update_protection_policy_requests_objects_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -class ResourceGuardsOperations(object): - """ResourceGuardsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url = _format_url_section(_url, **path_format_arguments) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_update_protected_item_requests_objects_request( + resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_disable_soft_delete_requests_object_request( + resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + "requestName": _SERIALIZER.url("request_name", request_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_delete_resource_guard_proxy_requests_object_request( + resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + "requestName": _SERIALIZER.url("request_name", request_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_backup_security_pin_requests_object_request( + resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + "requestName": _SERIALIZER.url("request_name", request_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_delete_protected_item_requests_object_request( + resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + "requestName": _SERIALIZER.url("request_name", request_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_update_protection_policy_requests_object_request( + resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + "requestName": _SERIALIZER.url("request_name", request_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_update_protected_item_requests_object_request( + resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGuardsName": _SERIALIZER.url("resource_guards_name", resource_guards_name, "str"), + "requestName": _SERIALIZER.url("request_name", request_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceGuardsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`resource_guards` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get_resources_in_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceGuardResourceList"] + @distributed_trace + def get_resources_in_subscription(self, **kwargs: Any) -> Iterable["_models.ResourceGuardResource"]: """Returns ResourceGuards collection belonging to a subscription. Returns ResourceGuards collection belonging to a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGuardResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceGuardResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_resources_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_resources_in_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resources_in_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceGuardResourceList', pipeline_response) + deserialized = self._deserialize("ResourceGuardResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,7 +679,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,62 +690,68 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_resources_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards'} # type: ignore + return ItemPaged(get_next, extract_data) + get_resources_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards"} # type: ignore + + @distributed_trace def get_resources_in_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceGuardResourceList"] + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ResourceGuardResource"]: """Returns ResourceGuards collection belonging to a ResourceGroup. Returns ResourceGuards collection belonging to a ResourceGroup. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGuardResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceGuardResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_resources_in_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_resources_in_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_resources_in_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceGuardResourceList', pipeline_response) + deserialized = self._deserialize("ResourceGuardResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -173,7 +760,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,188 +771,263 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_resources_in_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards'} # type: ignore + return ItemPaged(get_next, extract_data) + get_resources_in_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards"} # type: ignore + + @overload def put( self, - resource_group_name, # type: str - resource_guards_name, # type: str - parameters, # type: "_models.ResourceGuardResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceGuardResource" + resource_group_name: str, + resource_guards_name: str, + parameters: _models.ResourceGuardResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardResource: """Creates or updates a ResourceGuard resource belonging to a resource group. Creates or updates a ResourceGuard resource belonging to a resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Creates or updates a ResourceGuard resource belonging to a resource group. + + Creates or updates a ResourceGuard resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGuardResource, or the result of cls(response) + :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: Union[_models.ResourceGuardResource, IO], + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Creates or updates a ResourceGuard resource belonging to a resource group. + + Creates or updates a ResourceGuard resource belonging to a resource group. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGuardResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGuardResource") + + request = build_put_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGuardResource', pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore - def get( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceGuardResource" + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, resource_guards_name: str, **kwargs: Any) -> _models.ResourceGuardResource: """Returns a ResourceGuard belonging to a resource group. Returns a ResourceGuard belonging to a resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGuardResource, or the result of cls(response) + :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResource] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGuardResource', pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> None: """Deletes a ResourceGuard resource from the resource group. Deletes a ResourceGuard resource from the resource group. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -373,134 +1037,220 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + @overload def patch( self, - resource_group_name, # type: str - resource_guards_name, # type: str - parameters, # type: "_models.PatchResourceRequestInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceGuardResource" - """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for a resource. + resource_group_name: str, + resource_guards_name: str, + parameters: _models.PatchResourceRequestInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for a resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: The name of ResourceGuard. + :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + resource_guards_name: str, + parameters: Union[_models.PatchResourceRequestInput, IO], + **kwargs: Any + ) -> _models.ResourceGuardResource: + """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for + a resource. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param resource_guards_name: The name of ResourceGuard. Required. + :type resource_guards_name: str + :param parameters: Request body for operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGuardResource, or the result of cls(response) + :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGuardResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PatchResourceRequestInput') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGuardResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PatchResourceRequestInput") + + request = build_patch_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGuardResource', pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}'} # type: ignore + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}"} # type: ignore + + @distributed_trace def get_disable_soft_delete_requests_objects( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DppBaseResourceList"] - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> Iterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_disable_soft_delete_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_disable_soft_delete_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_disable_soft_delete_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -509,7 +1259,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -518,67 +1270,72 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_disable_soft_delete_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests'} # type: ignore + return ItemPaged(get_next, extract_data) + + get_disable_soft_delete_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests"} # type: ignore + @distributed_trace def get_delete_resource_guard_proxy_requests_objects( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DppBaseResourceList"] - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> Iterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_delete_resource_guard_proxy_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_delete_resource_guard_proxy_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_delete_resource_guard_proxy_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -587,7 +1344,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -596,67 +1355,72 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_delete_resource_guard_proxy_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests'} # type: ignore + return ItemPaged(get_next, extract_data) + + get_delete_resource_guard_proxy_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests"} # type: ignore + @distributed_trace def get_backup_security_pin_requests_objects( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DppBaseResourceList"] - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> Iterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_backup_security_pin_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_backup_security_pin_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_backup_security_pin_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -665,7 +1429,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -674,67 +1440,72 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_backup_security_pin_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests'} # type: ignore + return ItemPaged(get_next, extract_data) + get_backup_security_pin_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests"} # type: ignore + + @distributed_trace def get_delete_protected_item_requests_objects( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DppBaseResourceList"] - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> Iterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_delete_protected_item_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_delete_protected_item_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_delete_protected_item_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -743,7 +1514,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -752,67 +1525,72 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_delete_protected_item_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests'} # type: ignore + return ItemPaged(get_next, extract_data) + + get_delete_protected_item_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests"} # type: ignore + @distributed_trace def get_update_protection_policy_requests_objects( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DppBaseResourceList"] - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> Iterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_update_protection_policy_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_update_protection_policy_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_protection_policy_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -821,7 +1599,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -830,67 +1610,72 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_update_protection_policy_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests'} # type: ignore + return ItemPaged(get_next, extract_data) + get_update_protection_policy_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests"} # type: ignore + + @distributed_trace def get_update_protected_item_requests_objects( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DppBaseResourceList"] - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, **kwargs: Any + ) -> Iterable["_models.DppBaseResource"]: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DppBaseResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DppBaseResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_update_protected_item_requests_objects.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_update_protected_item_requests_objects_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_protected_item_requests_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DppBaseResourceList', pipeline_response) + deserialized = self._deserialize("DppBaseResourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -899,7 +1684,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -908,403 +1695,414 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - get_update_protected_item_requests_objects.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests'} # type: ignore + return ItemPaged(get_next, extract_data) + + get_update_protected_item_requests_objects.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests"} # type: ignore + @distributed_trace def get_default_disable_soft_delete_requests_object( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DppBaseResource" - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_disable_soft_delete_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_disable_soft_delete_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_disable_soft_delete_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_disable_soft_delete_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}'} # type: ignore + get_default_disable_soft_delete_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}"} # type: ignore + + @distributed_trace def get_default_delete_resource_guard_proxy_requests_object( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DppBaseResource" - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_delete_resource_guard_proxy_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_delete_resource_guard_proxy_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_delete_resource_guard_proxy_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_delete_resource_guard_proxy_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}'} # type: ignore + get_default_delete_resource_guard_proxy_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}"} # type: ignore + + @distributed_trace def get_default_backup_security_pin_requests_object( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DppBaseResource" - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_backup_security_pin_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_backup_security_pin_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_backup_security_pin_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_backup_security_pin_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}'} # type: ignore + get_default_backup_security_pin_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}"} # type: ignore + + @distributed_trace def get_default_delete_protected_item_requests_object( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DppBaseResource" - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_delete_protected_item_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_delete_protected_item_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_delete_protected_item_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_delete_protected_item_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}'} # type: ignore + get_default_delete_protected_item_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}"} # type: ignore + + @distributed_trace def get_default_update_protection_policy_requests_object( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DppBaseResource" - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_update_protection_policy_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_update_protection_policy_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_update_protection_policy_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_update_protection_policy_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}'} # type: ignore + get_default_update_protection_policy_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}"} # type: ignore + + @distributed_trace def get_default_update_protected_item_requests_object( - self, - resource_group_name, # type: str - resource_guards_name, # type: str - request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DppBaseResource" - """Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. + self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any + ) -> _models.DppBaseResource: + """Returns collection of operation request objects for a critical operation protected by the given + ResourceGuard resource. Returns collection of operation request objects for a critical operation protected by the given ResourceGuard resource. :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param resource_guards_name: + :param resource_guards_name: Required. :type resource_guards_name: str - :param request_name: + :param request_name: Required. :type request_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DppBaseResource, or the result of cls(response) + :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DppBaseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_default_update_protected_item_requests_object.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGuardsName': self._serialize.url("resource_guards_name", resource_guards_name, 'str'), - 'requestName': self._serialize.url("request_name", request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DppBaseResource] + + request = build_get_default_update_protected_item_requests_object_request( + resource_group_name=resource_group_name, + resource_guards_name=resource_guards_name, + request_name=request_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_default_update_protected_item_requests_object.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DppBaseResource', pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_default_update_protected_item_requests_object.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}'} # type: ignore + + get_default_update_protected_item_requests_object.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}"} # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py index c35009b32d98..7acf0bb5ab8a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,233 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_find_request( + resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"), + } -class RestorableTimeRangesOperations(object): - """RestorableTimeRangesOperations operations. + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class RestorableTimeRangesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.dataprotection.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionClient`'s + :attr:`restorable_time_ranges` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def find( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: _models.AzureBackupFindRestorableTimeRangesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: + """find. + + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload def find( self, - vault_name, # type: str - resource_group_name, # type: str - backup_instance_name, # type: str - parameters, # type: "_models.AzureBackupFindRestorableTimeRangesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureBackupFindRestorableTimeRangesResponseResource" + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: """find. - :param vault_name: The name of the backup vault. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def find( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + parameters: Union[_models.AzureBackupFindRestorableTimeRangesRequest, IO], + **kwargs: Any + ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: + """find. + :param resource_group_name: The name of the resource group where the backup vault is present. + Required. :type resource_group_name: str - :param backup_instance_name: The name of the backup instance. + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. + :param parameters: Request body for operation. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureBackupFindRestorableTimeRangesResponseResource, or the result of cls(response) + :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBackupFindRestorableTimeRangesResponseResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.find.metadata['url'] # type: ignore - path_format_arguments = { - 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'backupInstanceName': self._serialize.url("backup_instance_name", backup_instance_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureBackupFindRestorableTimeRangesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBackupFindRestorableTimeRangesResponseResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureBackupFindRestorableTimeRangesRequest") + + request = build_find_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + backup_instance_name=backup_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.find.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureBackupFindRestorableTimeRangesResponseResource', pipeline_response) + deserialized = self._deserialize("AzureBackupFindRestorableTimeRangesResponseResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - find.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges'} # type: ignore + + find.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges"} # type: ignore