# pylint: disable=too-many-lines,too-many-statements
# 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 io import IOBase
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload
import urllib.parse
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
if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
else:
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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,
*,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if x_ms_authorization_auxiliary is not None:
_headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header(
"x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str"
)
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,
*,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if x_ms_authorization_auxiliary is not None:
_headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header(
"x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str"
)
_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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( # pylint: disable=name-too-long
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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
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", max_length=90, min_length=1
),
"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: str = _url.format(**path_format_arguments) # type: ignore
# 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_cross_region_restore_request( # pylint: disable=name-too-long
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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/crossRegionRestore",
) # 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", max_length=90, min_length=1
),
"location": _SERIALIZER.url("location", location, "str", min_length=1),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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_cross_region_restore_request( # pylint: disable=name-too-long
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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/validateCrossRegionRestore",
) # 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", max_length=90, min_length=1
),
"location": _SERIALIZER.url("location", location, "str", min_length=1),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"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: str = _url.format(**path_format_arguments) # type: ignore
# 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,
*,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if x_ms_authorization_auxiliary is not None:
_headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header(
"x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str"
)
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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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,
*,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if x_ms_authorization_auxiliary is not None:
_headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header(
"x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str"
)
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_suspend_backups_request(
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
subscription_id: str,
*,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if x_ms_authorization_auxiliary is not None:
_headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header(
"x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str"
)
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_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# 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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
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", max_length=90, min_length=1
),
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
}
_url: str = _url.format(**path_format_arguments) # type: ignore
# 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)
[docs]
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.DataProtectionMgmtClient`'s
:attr:`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")
[docs]
@distributed_trace
def list(
self, resource_group_name: str, vault_name: str, **kwargs: Any
) -> Iterable["_models.BackupInstanceResource"]:
"""Gets a backup instances belonging to a backup vault.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param vault_name: The name of the backup vault. Required.
:type vault_name: str
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[_models.BackupInstanceResourceList] = kwargs.pop("cls", None)
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
_request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_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) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
_request = prepare_request(next_link)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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)
[docs]
@distributed_trace
def get(
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 resource_group_name: The name of the resource group. The name is case insensitive.
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
:return: BackupInstanceResource or the result of cls(response)
:rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[_models.BackupInstanceResource] = kwargs.pop("cls", None)
_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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
def _create_or_update_initial(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.BackupInstanceResource, IO[bytes]],
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> Optional[_models.BackupInstanceResource]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.BackupInstanceResource]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)
response = pipeline_response.http_response
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)
if response.status_code == 201:
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, response_headers) # type: ignore
return deserialized # type: ignore
@overload
def begin_create_or_update(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: _models.BackupInstanceResource,
x_ms_authorization_auxiliary: Optional[str] = None,
*,
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. The name is case insensitive.
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
:param x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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[bytes],
x_ms_authorization_auxiliary: Optional[str] = None,
*,
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. The name is case insensitive.
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[bytes]
:param x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.BackupInstanceResource, IO[bytes]],
x_ms_authorization_auxiliary: Optional[str] = None,
**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. The name is case insensitive.
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 BackupInstanceResource type or a
IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO[bytes]
:param x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.BackupInstanceResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
vault_name=vault_name,
backup_instance_name=backup_instance_name,
parameters=parameters,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.BackupInstanceResource].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.BackupInstanceResource](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)
def _delete_initial( # pylint: disable=inconsistent-return-statements
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> None:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", 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,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
api_version=api_version,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
[docs]
@distributed_trace
def begin_delete(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> LROPoller[None]:
"""Delete a backup instance in a backup vault.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
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,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _adhoc_backup_initial(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.TriggerBackupRequest, IO[bytes]],
**kwargs: Any
) -> Optional[_models.OperationJobExtendedInfo]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
return deserialized # 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. The name is case insensitive.
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
: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[bytes],
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Trigger adhoc backup.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_adhoc_backup(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.TriggerBackupRequest, IO[bytes]],
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Trigger adhoc backup.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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 TriggerBackupRequest type or a
IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.OperationJobExtendedInfo] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._adhoc_backup_initial(
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.OperationJobExtendedInfo](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)
def _validate_for_backup_initial(
self,
resource_group_name: str,
vault_name: str,
parameters: Union[_models.ValidateForBackupRequest, IO[bytes]],
**kwargs: Any
) -> Optional[_models.OperationJobExtendedInfo]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
return deserialized # 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. The name is case insensitive.
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
: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[bytes],
*,
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. The name is case insensitive.
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[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_validate_for_backup(
self,
resource_group_name: str,
vault_name: str,
parameters: Union[_models.ValidateForBackupRequest, IO[bytes]],
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Validate whether adhoc backup will be successful or not.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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 ValidateForBackupRequest type or a
IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.OperationJobExtendedInfo] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._validate_for_backup_initial(
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.OperationJobExtendedInfo](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)
[docs]
@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. The name is case insensitive.
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 operation_id: Required.
:type operation_id: str
: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: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[Optional[_models.BackupInstanceResource]] = kwargs.pop("cls", None)
_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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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, {}) # type: ignore
return deserialized # type: ignore
def _trigger_cross_region_restore_initial(
self,
resource_group_name: str,
location: str,
parameters: Union[_models.CrossRegionRestoreRequestObject, IO[bytes]],
**kwargs: Any
) -> Optional[_models.OperationJobExtendedInfo]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "CrossRegionRestoreRequestObject")
_request = build_trigger_cross_region_restore_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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, 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) # type: ignore
return deserialized # type: ignore
@overload
def begin_trigger_cross_region_restore(
self,
resource_group_name: str,
location: str,
parameters: _models.CrossRegionRestoreRequestObject,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Triggers Cross Region Restore for BackupInstance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param location: The name of the Azure region. Required.
:type location: str
:param parameters: Request body for trigger CRR operation. Required.
:type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreRequestObject
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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_cross_region_restore(
self,
resource_group_name: str,
location: str,
parameters: IO[bytes],
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Triggers Cross Region Restore for BackupInstance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param location: The name of the Azure region. Required.
:type location: str
:param parameters: Request body for trigger CRR operation. Required.
:type parameters: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_trigger_cross_region_restore(
self,
resource_group_name: str,
location: str,
parameters: Union[_models.CrossRegionRestoreRequestObject, IO[bytes]],
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Triggers Cross Region Restore for BackupInstance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param location: The name of the Azure region. Required.
:type location: str
:param parameters: Request body for trigger CRR operation. Is either a
CrossRegionRestoreRequestObject type or a IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreRequestObject or
IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.OperationJobExtendedInfo] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._trigger_cross_region_restore_initial(
resource_group_name=resource_group_name,
location=location,
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.OperationJobExtendedInfo](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)
def _validate_cross_region_restore_initial(
self,
resource_group_name: str,
location: str,
parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO[bytes]],
**kwargs: Any
) -> Optional[_models.OperationJobExtendedInfo]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "ValidateCrossRegionRestoreRequestObject")
_request = build_validate_cross_region_restore_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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, 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) # type: ignore
return deserialized # type: ignore
@overload
def begin_validate_cross_region_restore(
self,
resource_group_name: str,
location: str,
parameters: _models.ValidateCrossRegionRestoreRequestObject,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Validates whether Cross Region Restore can be triggered for DataSource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param location: The name of the Azure region. Required.
:type location: str
:param parameters: Request body for operation. Required.
:type parameters: ~azure.mgmt.dataprotection.models.ValidateCrossRegionRestoreRequestObject
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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_cross_region_restore(
self,
resource_group_name: str,
location: str,
parameters: IO[bytes],
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Validates whether Cross Region Restore can be triggered for DataSource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param location: The name of the Azure region. Required.
:type location: str
:param parameters: Request body for operation. Required.
:type parameters: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_validate_cross_region_restore(
self,
resource_group_name: str,
location: str,
parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO[bytes]],
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Validates whether Cross Region Restore can be triggered for DataSource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param location: The name of the Azure region. Required.
:type location: str
:param parameters: Request body for operation. Is either a
ValidateCrossRegionRestoreRequestObject type or a IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.ValidateCrossRegionRestoreRequestObject or
IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.OperationJobExtendedInfo] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._validate_cross_region_restore_initial(
resource_group_name=resource_group_name,
location=location,
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.OperationJobExtendedInfo](
self._client, raw_result, get_long_running_output, polling_method # 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[bytes]],
**kwargs: Any
) -> None:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # 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. The name is case insensitive.
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.AzureBackupRehydrationRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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[bytes],
*,
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. The name is case insensitive.
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[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_trigger_rehydrate(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.AzureBackupRehydrationRequest, IO[bytes]],
**kwargs: Any
) -> LROPoller[None]:
"""rehydrate recovery point for restore for a BackupInstance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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 AzureBackupRehydrationRequest type
or a IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _trigger_restore_initial(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.AzureBackupRestoreRequest, IO[bytes]],
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> Optional[_models.OperationJobExtendedInfo]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
return deserialized # type: ignore
@overload
def begin_trigger_restore(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: _models.AzureBackupRestoreRequest,
x_ms_authorization_auxiliary: Optional[str] = None,
*,
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. The name is case insensitive.
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
:param x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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[bytes],
x_ms_authorization_auxiliary: Optional[str] = None,
*,
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. The name is case insensitive.
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[bytes]
:param x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_trigger_restore(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.AzureBackupRestoreRequest, IO[bytes]],
x_ms_authorization_auxiliary: Optional[str] = None,
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Triggers restore for a BackupInstance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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 AzureBackupRestoreRequest type or a
IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO[bytes]
:param x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.OperationJobExtendedInfo] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._trigger_restore_initial(
resource_group_name=resource_group_name,
vault_name=vault_name,
backup_instance_name=backup_instance_name,
parameters=parameters,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.OperationJobExtendedInfo](
self._client, raw_result, get_long_running_output, polling_method # 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: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
[docs]
@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 resource_group_name: The name of the resource group. The name is case insensitive.
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
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = 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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
[docs]
@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 resource_group_name: The name of the resource group. The name is case insensitive.
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
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = 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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _stop_protection_initial( # pylint: disable=inconsistent-return-statements
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[Union[_models.StopProtectionRequest, IO[bytes]]] = None,
**kwargs: Any
) -> None:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, bytes)):
_content = parameters
else:
if parameters is not None:
_json = self._serialize.body(parameters, "StopProtectionRequest")
else:
_json = 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,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
@overload
def begin_stop_protection(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[_models.StopProtectionRequest] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[None]:
"""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. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:param parameters: Request body for operation. Default value is None.
:type parameters: ~azure.mgmt.dataprotection.models.StopProtectionRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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_stop_protection(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[IO[bytes]] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[None]:
"""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. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:param parameters: Request body for operation. Default value is None.
:type parameters: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_stop_protection(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[Union[_models.StopProtectionRequest, IO[bytes]]] = None,
**kwargs: Any
) -> LROPoller[None]:
"""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. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:param parameters: Request body for operation. Is either a StopProtectionRequest type or a
IO[bytes] type. Default value is None.
:type parameters: ~azure.mgmt.dataprotection.models.StopProtectionRequest or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._stop_protection_initial( # type: ignore
resource_group_name=resource_group_name,
vault_name=vault_name,
backup_instance_name=backup_instance_name,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[Union[_models.SuspendBackupRequest, IO[bytes]]] = None,
**kwargs: Any
) -> None:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, bytes)):
_content = parameters
else:
if parameters is not None:
_json = self._serialize.body(parameters, "SuspendBackupRequest")
else:
_json = 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,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
@overload
def begin_suspend_backups(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[_models.SuspendBackupRequest] = None,
*,
content_type: str = "application/json",
**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. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:param parameters: Request body for operation. Default value is None.
:type parameters: ~azure.mgmt.dataprotection.models.SuspendBackupRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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_suspend_backups(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[IO[bytes]] = None,
*,
content_type: str = "application/json",
**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. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:param parameters: Request body for operation. Default value is None.
:type parameters: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_suspend_backups(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
x_ms_authorization_auxiliary: Optional[str] = None,
parameters: Optional[Union[_models.SuspendBackupRequest, IO[bytes]]] = None,
**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. The name is case insensitive.
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 x_ms_authorization_auxiliary: Default value is None.
:type x_ms_authorization_auxiliary: str
:param parameters: Request body for operation. Is either a SuspendBackupRequest type or a
IO[bytes] type. Default value is None.
:type parameters: ~azure.mgmt.dataprotection.models.SuspendBackupRequest or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._suspend_backups_initial( # type: ignore
resource_group_name=resource_group_name,
vault_name=vault_name,
backup_instance_name=backup_instance_name,
x_ms_authorization_auxiliary=x_ms_authorization_auxiliary,
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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statements
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.SyncBackupInstanceRequest, IO[bytes]],
**kwargs: Any
) -> None:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
@overload
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
) -> 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. The name is case insensitive.
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.SyncBackupInstanceRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
: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[bytes],
*,
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. The name is case insensitive.
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[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_sync_backup_instance(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.SyncBackupInstanceRequest, IO[bytes]],
**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. The name is case insensitive.
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 SyncBackupInstanceRequest type or a
IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
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,
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, {}) # type: ignore
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[None].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _validate_for_restore_initial(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.ValidateRestoreRequestObject, IO[bytes]],
**kwargs: Any
) -> Optional[_models.OperationJobExtendedInfo]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IOBase, 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,
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **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) # type: ignore
return deserialized # type: ignore
@overload
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
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Validates if Restore can be triggered for a DataSource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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
: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_restore(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: IO[bytes],
*,
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. The name is case insensitive.
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[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
: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:
"""
[docs]
@distributed_trace
def begin_validate_for_restore(
self,
resource_group_name: str,
vault_name: str,
backup_instance_name: str,
parameters: Union[_models.ValidateRestoreRequestObject, IO[bytes]],
**kwargs: Any
) -> LROPoller[_models.OperationJobExtendedInfo]:
"""Validates if Restore can be triggered for a DataSource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
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 ValidateRestoreRequestObject type or
a IO[bytes] type. Required.
:type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO[bytes]
: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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.OperationJobExtendedInfo] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._validate_for_restore_initial(
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, {}) # type: ignore
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[_models.OperationJobExtendedInfo](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)