diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json b/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json index 8d7e363a7fc9..d1f2951beb2c 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json +++ b/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json @@ -1,11 +1,11 @@ { - "commit": "96c583e9d5d09c51fe8a21843180c51b98b4a7db", + "commit": "9cc2523e91a4fe261489884a7a44d033afcb7c29", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ "@autorest/python@6.4.0", "@autorest/modelerfour@4.24.3" ], - "autorest_command": "autorest specification/dataprotection/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/dataprotection/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/dataprotection/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py index 04b5edb89829..c7e9401d4d78 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py @@ -23,6 +23,7 @@ DataProtectionOperations, DataProtectionOperationsOperations, DeletedBackupInstancesOperations, + DppResourceGuardProxyOperations, ExportJobsOperationResultOperations, ExportJobsOperations, JobsOperations, @@ -86,6 +87,9 @@ class DataProtectionMgmtClient: # pylint: disable=client-accepts-api-version-ke azure.mgmt.dataprotection.operations.DeletedBackupInstancesOperations :ivar resource_guards: ResourceGuardsOperations operations :vartype resource_guards: azure.mgmt.dataprotection.operations.ResourceGuardsOperations + :ivar dpp_resource_guard_proxy: DppResourceGuardProxyOperations operations + :vartype dpp_resource_guard_proxy: + azure.mgmt.dataprotection.operations.DppResourceGuardProxyOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -152,6 +156,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.resource_guards = ResourceGuardsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dpp_resource_guard_proxy = DppResourceGuardProxyOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py index 8a67b75527b2..96bd8ead2dd0 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py @@ -23,6 +23,7 @@ DataProtectionOperations, DataProtectionOperationsOperations, DeletedBackupInstancesOperations, + DppResourceGuardProxyOperations, ExportJobsOperationResultOperations, ExportJobsOperations, JobsOperations, @@ -86,6 +87,9 @@ class DataProtectionMgmtClient: # pylint: disable=client-accepts-api-version-ke azure.mgmt.dataprotection.aio.operations.DeletedBackupInstancesOperations :ivar resource_guards: ResourceGuardsOperations operations :vartype resource_guards: azure.mgmt.dataprotection.aio.operations.ResourceGuardsOperations + :ivar dpp_resource_guard_proxy: DppResourceGuardProxyOperations operations + :vartype dpp_resource_guard_proxy: + azure.mgmt.dataprotection.aio.operations.DppResourceGuardProxyOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -152,6 +156,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.resource_guards = ResourceGuardsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dpp_resource_guard_proxy = DppResourceGuardProxyOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py index 6775e75af5a7..0bf84afef994 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py @@ -23,6 +23,7 @@ from ._export_jobs_operation_result_operations import ExportJobsOperationResultOperations from ._deleted_backup_instances_operations import DeletedBackupInstancesOperations from ._resource_guards_operations import ResourceGuardsOperations +from ._dpp_resource_guard_proxy_operations import DppResourceGuardProxyOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -46,6 +47,7 @@ "ExportJobsOperationResultOperations", "DeletedBackupInstancesOperations", "ResourceGuardsOperations", + "DppResourceGuardProxyOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py new file mode 100644 index 000000000000..5713002b3c46 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py @@ -0,0 +1,617 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dpp_resource_guard_proxy_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_unlock_delete_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DppResourceGuardProxyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionMgmtClient`'s + :attr:`dpp_resource_guard_proxy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGuardProxyBaseResource"]: + """Returns the list of ResourceGuardProxies associated with the vault. + + Returns the list of ResourceGuardProxies associated with the 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceGuardProxyBaseResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ResourceGuardProxyBaseResourceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceGuardProxyBaseResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Returns the ResourceGuardProxy object associated with the vault, and that matches the name in + the request. + + Returns the ResourceGuardProxy object associated with the vault, and that matches the name in + the request. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ResourceGuardProxyBaseResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.ResourceGuardProxyBaseResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Creates or Updates a ResourceGuardProxy. + + Creates or Updates a ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Creates or Updates a ResourceGuardProxy. + + Creates or Updates a ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.ResourceGuardProxyBaseResource, IO], + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Creates or Updates a ResourceGuardProxy. + + Creates or Updates a ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a ResourceGuardProxyBaseResource type + or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = 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.ResourceGuardProxyBaseResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGuardProxyBaseResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> None: + """Deletes the ResourceGuardProxy. + + Deletes the ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = 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, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + } + + @overload + async def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.UnlockDeleteRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.UnlockDeleteRequest, IO], + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a UnlockDeleteRequest type or a IO + type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = 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.UnlockDeleteResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UnlockDeleteRequest") + + request = build_unlock_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.unlock_delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + unlock_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete" + } diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py index 68927a1a9dad..4a0514d629e5 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py @@ -116,6 +116,10 @@ from ._models_py3 import RecoveryPointsFilters from ._models_py3 import ResourceGuard from ._models_py3 import ResourceGuardOperation +from ._models_py3 import ResourceGuardOperationDetail +from ._models_py3 import ResourceGuardProxyBase +from ._models_py3 import ResourceGuardProxyBaseResource +from ._models_py3 import ResourceGuardProxyBaseResourceList from ._models_py3 import ResourceGuardResource from ._models_py3 import ResourceGuardResourceList from ._models_py3 import ResourceMoveDetails @@ -141,6 +145,8 @@ from ._models_py3 import TargetDetails from ._models_py3 import TriggerBackupRequest from ._models_py3 import TriggerContext +from ._models_py3 import UnlockDeleteRequest +from ._models_py3 import UnlockDeleteResponse from ._models_py3 import UserFacingError from ._models_py3 import ValidateForBackupRequest from ._models_py3 import ValidateRestoreRequestObject @@ -289,6 +295,10 @@ "RecoveryPointsFilters", "ResourceGuard", "ResourceGuardOperation", + "ResourceGuardOperationDetail", + "ResourceGuardProxyBase", + "ResourceGuardProxyBaseResource", + "ResourceGuardProxyBaseResourceList", "ResourceGuardResource", "ResourceGuardResourceList", "ResourceMoveDetails", @@ -314,6 +324,8 @@ "TargetDetails", "TriggerBackupRequest", "TriggerContext", + "UnlockDeleteRequest", + "UnlockDeleteResponse", "UserFacingError", "ValidateForBackupRequest", "ValidateRestoreRequestObject", diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py index adddde516415..55016d6e0d6a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py @@ -5169,6 +5169,165 @@ def __init__(self, **kwargs: Any) -> None: self.request_resource_type = None +class ResourceGuardOperationDetail(_serialization.Model): + """VaultCritical Operation protected by a resource guard. + + :ivar vault_critical_operation: + :vartype vault_critical_operation: str + :ivar default_resource_request: + :vartype default_resource_request: str + """ + + _attribute_map = { + "vault_critical_operation": {"key": "vaultCriticalOperation", "type": "str"}, + "default_resource_request": {"key": "defaultResourceRequest", "type": "str"}, + } + + def __init__( + self, + *, + vault_critical_operation: Optional[str] = None, + default_resource_request: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword vault_critical_operation: + :paramtype vault_critical_operation: str + :keyword default_resource_request: + :paramtype default_resource_request: str + """ + super().__init__(**kwargs) + self.vault_critical_operation = vault_critical_operation + self.default_resource_request = default_resource_request + + +class ResourceGuardProxyBase(_serialization.Model): + """ResourceGuardProxyBase object, used in ResourceGuardProxyBaseResource. + + :ivar resource_guard_resource_id: + :vartype resource_guard_resource_id: str + :ivar resource_guard_operation_details: + :vartype resource_guard_operation_details: + list[~azure.mgmt.dataprotection.models.ResourceGuardOperationDetail] + :ivar last_updated_time: + :vartype last_updated_time: str + :ivar description: + :vartype description: str + """ + + _attribute_map = { + "resource_guard_resource_id": {"key": "resourceGuardResourceId", "type": "str"}, + "resource_guard_operation_details": { + "key": "resourceGuardOperationDetails", + "type": "[ResourceGuardOperationDetail]", + }, + "last_updated_time": {"key": "lastUpdatedTime", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + resource_guard_resource_id: Optional[str] = None, + resource_guard_operation_details: Optional[List["_models.ResourceGuardOperationDetail"]] = None, + last_updated_time: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_guard_resource_id: + :paramtype resource_guard_resource_id: str + :keyword resource_guard_operation_details: + :paramtype resource_guard_operation_details: + list[~azure.mgmt.dataprotection.models.ResourceGuardOperationDetail] + :keyword last_updated_time: + :paramtype last_updated_time: str + :keyword description: + :paramtype description: str + """ + super().__init__(**kwargs) + self.resource_guard_resource_id = resource_guard_resource_id + self.resource_guard_operation_details = resource_guard_operation_details + self.last_updated_time = last_updated_time + self.description = description + + +class ResourceGuardProxyBaseResource(DppResource): + """ResourceGuardProxyBaseResource object, used for response and request bodies for + ResourceGuardProxy APIs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id represents the complete path to the resource. + :vartype id: str + :ivar name: Resource name associated with the resource. + :vartype name: str + :ivar type: Resource type represents the complete path of the form + Namespace/ResourceType/ResourceType/... + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.dataprotection.models.SystemData + :ivar properties: ResourceGuardProxyBaseResource properties. + :vartype properties: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBase + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ResourceGuardProxyBase"}, + } + + def __init__(self, *, properties: Optional["_models.ResourceGuardProxyBase"] = None, **kwargs: Any) -> None: + """ + :keyword properties: ResourceGuardProxyBaseResource properties. + :paramtype properties: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBase + """ + super().__init__(**kwargs) + self.properties = properties + + +class ResourceGuardProxyBaseResourceList(DppResourceList): + """List of ResourceGuardProxyBase resources. + + :ivar next_link: The uri to fetch the next page of resources. Call ListNext() fetches next page + of resources. + :vartype next_link: str + :ivar value: List of resources. + :vartype value: list[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + """ + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ResourceGuardProxyBaseResource]"}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["_models.ResourceGuardProxyBaseResource"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword next_link: The uri to fetch the next page of resources. Call ListNext() fetches next + page of resources. + :paramtype next_link: str + :keyword value: List of resources. + :paramtype value: list[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + """ + super().__init__(next_link=next_link, **kwargs) + self.value = value + + class ResourceGuardResource(DppBaseTrackedResource): """ResourceGuardResource. @@ -6213,6 +6372,60 @@ def __init__(self, *, backup_rule_options: "_models.AdHocBackupRuleOptions", **k self.backup_rule_options = backup_rule_options +class UnlockDeleteRequest(_serialization.Model): + """Request body of unlock delete API. + + :ivar resource_guard_operation_requests: + :vartype resource_guard_operation_requests: list[str] + :ivar resource_to_be_deleted: + :vartype resource_to_be_deleted: str + """ + + _attribute_map = { + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, + "resource_to_be_deleted": {"key": "resourceToBeDeleted", "type": "str"}, + } + + def __init__( + self, + *, + resource_guard_operation_requests: Optional[List[str]] = None, + resource_to_be_deleted: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_guard_operation_requests: + :paramtype resource_guard_operation_requests: list[str] + :keyword resource_to_be_deleted: + :paramtype resource_to_be_deleted: str + """ + super().__init__(**kwargs) + self.resource_guard_operation_requests = resource_guard_operation_requests + self.resource_to_be_deleted = resource_to_be_deleted + + +class UnlockDeleteResponse(_serialization.Model): + """Response of Unlock Delete API. + + :ivar unlock_delete_expiry_time: This is the time when unlock delete privileges will get + expired. + :vartype unlock_delete_expiry_time: str + """ + + _attribute_map = { + "unlock_delete_expiry_time": {"key": "unlockDeleteExpiryTime", "type": "str"}, + } + + def __init__(self, *, unlock_delete_expiry_time: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword unlock_delete_expiry_time: This is the time when unlock delete privileges will get + expired. + :paramtype unlock_delete_expiry_time: str + """ + super().__init__(**kwargs) + self.unlock_delete_expiry_time = unlock_delete_expiry_time + + class UserFacingError(_serialization.Model): """Error object used by layers that have access to localized content, and propagate that to user. diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py index 6775e75af5a7..0bf84afef994 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py @@ -23,6 +23,7 @@ from ._export_jobs_operation_result_operations import ExportJobsOperationResultOperations from ._deleted_backup_instances_operations import DeletedBackupInstancesOperations from ._resource_guards_operations import ResourceGuardsOperations +from ._dpp_resource_guard_proxy_operations import DppResourceGuardProxyOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -46,6 +47,7 @@ "ExportJobsOperationResultOperations", "DeletedBackupInstancesOperations", "ResourceGuardsOperations", + "DppResourceGuardProxyOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py new file mode 100644 index 000000000000..7cccc3d31d46 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py @@ -0,0 +1,794 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, 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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # 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: Literal["2023-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _format_url_section(_url, **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, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url( + "resource_guard_proxy_name", resource_guard_proxy_name, "str", pattern=r"^[A-Za-z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **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, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-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}/backupResourceGuardProxies/{resourceGuardProxyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url( + "resource_guard_proxy_name", resource_guard_proxy_name, "str", pattern=r"^[A-Za-z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url( + "resource_guard_proxy_name", resource_guard_proxy_name, "str", pattern=r"^[A-Za-z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_unlock_delete_request( + resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2023-01-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}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "resourceGuardProxyName": _SERIALIZER.url( + "resource_guard_proxy_name", resource_guard_proxy_name, "str", pattern=r"^[A-Za-z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **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) + + +class DppResourceGuardProxyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionMgmtClient`'s + :attr:`dpp_resource_guard_proxy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.ResourceGuardProxyBaseResource"]: + """Returns the list of ResourceGuardProxies associated with the vault. + + Returns the list of ResourceGuardProxies associated with the 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceGuardProxyBaseResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ResourceGuardProxyBaseResourceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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("ResourceGuardProxyBaseResourceList", 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies" + } + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Returns the ResourceGuardProxy object associated with the vault, and that matches the name in + the request. + + Returns the ResourceGuardProxy object associated with the vault, and that matches the name in + the request. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[_models.ResourceGuardProxyBaseResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.ResourceGuardProxyBaseResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Creates or Updates a ResourceGuardProxy. + + Creates or Updates a ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Creates or Updates a ResourceGuardProxy. + + Creates or Updates a ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.ResourceGuardProxyBaseResource, IO], + **kwargs: Any + ) -> _models.ResourceGuardProxyBaseResource: + """Creates or Updates a ResourceGuardProxy. + + Creates or Updates a ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a ResourceGuardProxyBaseResource type + or a IO type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGuardProxyBaseResource or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = 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.ResourceGuardProxyBaseResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGuardProxyBaseResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any + ) -> None: + """Deletes the ResourceGuardProxy. + + Deletes the ResourceGuardProxy. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = 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, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + } + + @overload + def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: _models.UnlockDeleteRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def unlock_delete( + self, + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + parameters: Union[_models.UnlockDeleteRequest, IO], + **kwargs: Any + ) -> _models.UnlockDeleteResponse: + """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + + :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 resource_guard_proxy_name: name of the resource guard proxy. Required. + :type resource_guard_proxy_name: str + :param parameters: Request body for operation. Is either a UnlockDeleteRequest type or a IO + type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UnlockDeleteResponse or the result of cls(response) + :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01"] = 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.UnlockDeleteResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UnlockDeleteRequest") + + request = build_unlock_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + resource_guard_proxy_name=resource_guard_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.unlock_delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + unlock_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete" + } diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/delete_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/delete_resource_guard_proxy.py new file mode 100644 index 000000000000..a23c8fc07030 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/delete_resource_guard_proxy.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python delete_resource_guard_proxy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="5e13b949-1218-4d18-8b99-7e12155ec4f7", + ) + + response = client.dpp_resource_guard_proxy.delete( + resource_group_name="SampleResourceGroup", + vault_name="sampleVault", + resource_guard_proxy_name="swaggerExample", + ) + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-01-01/examples/ResourceGuardProxyCRUD/DeleteResourceGuardProxy.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_resource_guard_proxy.py new file mode 100644 index 000000000000..cc15253a4d20 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_resource_guard_proxy.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python get_resource_guard_proxy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="5e13b949-1218-4d18-8b99-7e12155ec4f7", + ) + + response = client.dpp_resource_guard_proxy.get( + resource_group_name="SampleResourceGroup", + vault_name="sampleVault", + resource_guard_proxy_name="swaggerExample", + ) + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-01-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/list_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/list_resource_guard_proxy.py new file mode 100644 index 000000000000..cfc54c86e1d2 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/list_resource_guard_proxy.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python list_resource_guard_proxy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="5e13b949-1218-4d18-8b99-7e12155ec4f7", + ) + + response = client.dpp_resource_guard_proxy.list( + resource_group_name="SampleResourceGroup", + vault_name="sampleVault", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-01-01/examples/ResourceGuardProxyCRUD/ListResourceGuardProxy.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/put_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/put_resource_guard_proxy.py new file mode 100644 index 000000000000..0954f7186439 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/put_resource_guard_proxy.py @@ -0,0 +1,47 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python put_resource_guard_proxy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="5e13b949-1218-4d18-8b99-7e12155ec4f7", + ) + + response = client.dpp_resource_guard_proxy.create_or_update( + resource_group_name="SampleResourceGroup", + vault_name="sampleVault", + resource_guard_proxy_name="swaggerExample", + parameters={ + "properties": { + "resourceGuardResourceId": "/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-01-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/unlock_delete_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/unlock_delete_resource_guard_proxy.py new file mode 100644 index 000000000000..530485cfeedc --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/unlock_delete_resource_guard_proxy.py @@ -0,0 +1,48 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python unlock_delete_resource_guard_proxy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="5e13b949-1218-4d18-8b99-7e12155ec4f7", + ) + + response = client.dpp_resource_guard_proxy.unlock_delete( + resource_group_name="SampleResourceGroup", + vault_name="sampleVault", + resource_guard_proxy_name="swaggerExample", + parameters={ + "resourceGuardOperationRequests": [ + "/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteBackupInstanceRequests/default" + ], + "resourceToBeDeleted": "/subscriptions/5e13b949-1218-4d18-8b99-7e12155ec4f7/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/sampleVault/backupInstances/TestBI9779f4de", + }, + ) + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-01-01/examples/ResourceGuardProxyCRUD/UnlockDeleteResourceGuardProxy.json +if __name__ == "__main__": + main()