diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md b/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md index 2c3d59f8ad60..82c19438e0d6 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md +++ b/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.0b3 (2025-05-12) + +change log generation failed!!! + ## 1.2.0b2 (2025-04-21) ### Features Added diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/README.md b/sdk/elasticsan/azure-mgmt-elasticsan/README.md index 55760d2835db..c463537c17c3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/README.md +++ b/sdk/elasticsan/azure-mgmt-elasticsan/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Elasticsan Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json index b32c182f4777..9e01df27cdac 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json +++ b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json @@ -1,11 +1,6 @@ { - "commit": "b0a48bcbffead733affe03944ef09f5e8d12f8c8", + "commit": "0e8a60212052dc13f9d071cbc573dedf07234699", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.27.4", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/elasticsan/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/elasticsan/resource-manager/readme.md" + "typespec_src": "specification/elasticsan/ElasticSan.Management", + "@azure-tools/typespec-python": "0.44.2" } \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/apiview-properties.json b/sdk/elasticsan/azure-mgmt-elasticsan/apiview-properties.json new file mode 100644 index 000000000000..4b243084c552 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/apiview-properties.json @@ -0,0 +1,135 @@ +{ + "CrossLanguagePackageId": "Microsoft.ElasticSan", + "CrossLanguageDefinitionId": { + "azure.mgmt.elasticsan.models.AutoScaleProperties": "Microsoft.ElasticSan.AutoScaleProperties", + "azure.mgmt.elasticsan.models.DeleteRetentionPolicy": "Microsoft.ElasticSan.DeleteRetentionPolicy", + "azure.mgmt.elasticsan.models.DiskSnapshotList": "Microsoft.ElasticSan.DiskSnapshotList", + "azure.mgmt.elasticsan.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.elasticsan.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.elasticsan.models.ElasticSan": "Microsoft.ElasticSan.ElasticSan", + "azure.mgmt.elasticsan.models.ElasticSanProperties": "Microsoft.ElasticSan.ElasticSanProperties", + "azure.mgmt.elasticsan.models.ElasticSanUpdate": "Microsoft.ElasticSan.ElasticSanUpdate", + "azure.mgmt.elasticsan.models.ElasticSanUpdateProperties": "Microsoft.ElasticSan.ElasticSanUpdateProperties", + "azure.mgmt.elasticsan.models.EncryptionIdentity": "Microsoft.ElasticSan.EncryptionIdentity", + "azure.mgmt.elasticsan.models.EncryptionProperties": "Microsoft.ElasticSan.EncryptionProperties", + "azure.mgmt.elasticsan.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.elasticsan.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.elasticsan.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.elasticsan.models.Identity": "Microsoft.ElasticSan.Identity", + "azure.mgmt.elasticsan.models.IscsiTargetInfo": "Microsoft.ElasticSan.IscsiTargetInfo", + "azure.mgmt.elasticsan.models.KeyVaultProperties": "Microsoft.ElasticSan.KeyVaultProperties", + "azure.mgmt.elasticsan.models.ManagedByInfo": "Microsoft.ElasticSan.ManagedByInfo", + "azure.mgmt.elasticsan.models.NetworkRuleSet": "Microsoft.ElasticSan.NetworkRuleSet", + "azure.mgmt.elasticsan.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.elasticsan.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.elasticsan.models.PreValidationResponse": "Microsoft.ElasticSan.PreValidationResponse", + "azure.mgmt.elasticsan.models.PrivateEndpoint": "Microsoft.ElasticSan.PrivateEndpoint", + "azure.mgmt.elasticsan.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.elasticsan.models.PrivateEndpointConnection": "Microsoft.ElasticSan.PrivateEndpointConnection", + "azure.mgmt.elasticsan.models.PrivateEndpointConnectionProperties": "Microsoft.ElasticSan.PrivateEndpointConnectionProperties", + "azure.mgmt.elasticsan.models.PrivateLinkResource": "Microsoft.ElasticSan.PrivateLinkResource", + "azure.mgmt.elasticsan.models.PrivateLinkResourceProperties": "Microsoft.ElasticSan.PrivateLinkResourceProperties", + "azure.mgmt.elasticsan.models.PrivateLinkServiceConnectionState": "Microsoft.ElasticSan.PrivateLinkServiceConnectionState", + "azure.mgmt.elasticsan.models.ScaleUpProperties": "Microsoft.ElasticSan.ScaleUpProperties", + "azure.mgmt.elasticsan.models.Sku": "Microsoft.ElasticSan.Sku", + "azure.mgmt.elasticsan.models.SKUCapability": "Microsoft.ElasticSan.SKUCapability", + "azure.mgmt.elasticsan.models.SkuInformation": "Microsoft.ElasticSan.SkuInformation", + "azure.mgmt.elasticsan.models.SkuLocationInfo": "Microsoft.ElasticSan.SkuLocationInfo", + "azure.mgmt.elasticsan.models.Snapshot": "Microsoft.ElasticSan.Snapshot", + "azure.mgmt.elasticsan.models.SnapshotCreationData": "Microsoft.ElasticSan.SnapshotCreationData", + "azure.mgmt.elasticsan.models.SnapshotProperties": "Microsoft.ElasticSan.SnapshotProperties", + "azure.mgmt.elasticsan.models.SourceCreationData": "Microsoft.ElasticSan.SourceCreationData", + "azure.mgmt.elasticsan.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.elasticsan.models.UserAssignedIdentity": "Microsoft.ElasticSan.UserAssignedIdentity", + "azure.mgmt.elasticsan.models.VirtualNetworkRule": "Microsoft.ElasticSan.VirtualNetworkRule", + "azure.mgmt.elasticsan.models.Volume": "Microsoft.ElasticSan.Volume", + "azure.mgmt.elasticsan.models.VolumeGroup": "Microsoft.ElasticSan.VolumeGroup", + "azure.mgmt.elasticsan.models.VolumeGroupProperties": "Microsoft.ElasticSan.VolumeGroupProperties", + "azure.mgmt.elasticsan.models.VolumeGroupUpdate": "Microsoft.ElasticSan.VolumeGroupUpdate", + "azure.mgmt.elasticsan.models.VolumeGroupUpdateProperties": "Microsoft.ElasticSan.VolumeGroupUpdateProperties", + "azure.mgmt.elasticsan.models.VolumeNameList": "Microsoft.ElasticSan.VolumeNameList", + "azure.mgmt.elasticsan.models.VolumeProperties": "Microsoft.ElasticSan.VolumeProperties", + "azure.mgmt.elasticsan.models.VolumeUpdate": "Microsoft.ElasticSan.VolumeUpdate", + "azure.mgmt.elasticsan.models.VolumeUpdateProperties": "Microsoft.ElasticSan.VolumeUpdateProperties", + "azure.mgmt.elasticsan.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.elasticsan.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.elasticsan.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.elasticsan.models.SkuName": "Microsoft.ElasticSan.SkuName", + "azure.mgmt.elasticsan.models.SkuTier": "Microsoft.ElasticSan.SkuTier", + "azure.mgmt.elasticsan.models.ProvisioningStates": "Microsoft.ElasticSan.ProvisioningStates", + "azure.mgmt.elasticsan.models.PrivateEndpointServiceConnectionStatus": "Microsoft.ElasticSan.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.elasticsan.models.PublicNetworkAccess": "Microsoft.ElasticSan.PublicNetworkAccess", + "azure.mgmt.elasticsan.models.AutoScalePolicyEnforcement": "Microsoft.ElasticSan.AutoScalePolicyEnforcement", + "azure.mgmt.elasticsan.models.IdentityType": "Microsoft.ElasticSan.IdentityType", + "azure.mgmt.elasticsan.models.StorageTargetType": "Microsoft.ElasticSan.StorageTargetType", + "azure.mgmt.elasticsan.models.EncryptionType": "Microsoft.ElasticSan.EncryptionType", + "azure.mgmt.elasticsan.models.Action": "Microsoft.ElasticSan.Action", + "azure.mgmt.elasticsan.models.PolicyState": "Microsoft.ElasticSan.PolicyState", + "azure.mgmt.elasticsan.models.X_ms_access_soft_deleted_resources": "Microsoft.ElasticSan.x-ms-access-soft-deleted-resources", + "azure.mgmt.elasticsan.models.VolumeCreateOption": "Microsoft.ElasticSan.VolumeCreateOption", + "azure.mgmt.elasticsan.models.OperationalStatus": "Microsoft.ElasticSan.OperationalStatus", + "azure.mgmt.elasticsan.models.X_ms_delete_snapshots": "Microsoft.ElasticSan.x-ms-delete-snapshots", + "azure.mgmt.elasticsan.models.X_ms_force_delete": "Microsoft.ElasticSan.x-ms-force-delete", + "azure.mgmt.elasticsan.models.DeleteType": "Microsoft.ElasticSan.DeleteType", + "azure.mgmt.elasticsan.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.elasticsan.aio.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.get": "Microsoft.ElasticSan.ElasticSans.get", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.get": "Microsoft.ElasticSan.ElasticSans.get", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.begin_create": "Microsoft.ElasticSan.ElasticSans.create", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.begin_create": "Microsoft.ElasticSan.ElasticSans.create", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.begin_update": "Microsoft.ElasticSan.ElasticSans.update", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.begin_update": "Microsoft.ElasticSan.ElasticSans.update", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.begin_delete": "Microsoft.ElasticSan.ElasticSans.delete", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.begin_delete": "Microsoft.ElasticSan.ElasticSans.delete", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.list_by_resource_group": "Microsoft.ElasticSan.ElasticSans.listByResourceGroup", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.list_by_resource_group": "Microsoft.ElasticSan.ElasticSans.listByResourceGroup", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.list_by_subscription": "Microsoft.ElasticSan.ElasticSans.listBySubscription", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.list_by_subscription": "Microsoft.ElasticSan.ElasticSans.listBySubscription", + "azure.mgmt.elasticsan.operations.ElasticSansOperations.list_by_elastic_san": "Microsoft.ElasticSan.ElasticSans.listByElasticSan", + "azure.mgmt.elasticsan.aio.operations.ElasticSansOperations.list_by_elastic_san": "Microsoft.ElasticSan.ElasticSans.listByElasticSan", + "azure.mgmt.elasticsan.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.ElasticSan.PrivateEndpointConnections.get", + "azure.mgmt.elasticsan.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.ElasticSan.PrivateEndpointConnections.get", + "azure.mgmt.elasticsan.operations.PrivateEndpointConnectionsOperations.begin_create": "Microsoft.ElasticSan.PrivateEndpointConnections.create", + "azure.mgmt.elasticsan.aio.operations.PrivateEndpointConnectionsOperations.begin_create": "Microsoft.ElasticSan.PrivateEndpointConnections.create", + "azure.mgmt.elasticsan.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.ElasticSan.PrivateEndpointConnections.delete", + "azure.mgmt.elasticsan.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.ElasticSan.PrivateEndpointConnections.delete", + "azure.mgmt.elasticsan.operations.PrivateEndpointConnectionsOperations.list": "Microsoft.ElasticSan.PrivateEndpointConnections.list", + "azure.mgmt.elasticsan.aio.operations.PrivateEndpointConnectionsOperations.list": "Microsoft.ElasticSan.PrivateEndpointConnections.list", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.get": "Microsoft.ElasticSan.VolumeGroups.get", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.get": "Microsoft.ElasticSan.VolumeGroups.get", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.begin_create": "Microsoft.ElasticSan.VolumeGroups.create", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.begin_create": "Microsoft.ElasticSan.VolumeGroups.create", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.begin_update": "Microsoft.ElasticSan.VolumeGroups.update", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.begin_update": "Microsoft.ElasticSan.VolumeGroups.update", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.begin_delete": "Microsoft.ElasticSan.VolumeGroups.delete", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.begin_delete": "Microsoft.ElasticSan.VolumeGroups.delete", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.list_by_elastic_san": "Microsoft.ElasticSan.VolumeGroups.listByElasticSan", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.list_by_elastic_san": "Microsoft.ElasticSan.VolumeGroups.listByElasticSan", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.begin_pre_backup": "Microsoft.ElasticSan.VolumeGroups.preBackup", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.begin_pre_backup": "Microsoft.ElasticSan.VolumeGroups.preBackup", + "azure.mgmt.elasticsan.operations.VolumeGroupsOperations.begin_pre_restore": "Microsoft.ElasticSan.VolumeGroups.preRestore", + "azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations.begin_pre_restore": "Microsoft.ElasticSan.VolumeGroups.preRestore", + "azure.mgmt.elasticsan.operations.VolumesOperations.get": "Microsoft.ElasticSan.Volumes.get", + "azure.mgmt.elasticsan.aio.operations.VolumesOperations.get": "Microsoft.ElasticSan.Volumes.get", + "azure.mgmt.elasticsan.operations.VolumesOperations.begin_create": "Microsoft.ElasticSan.Volumes.create", + "azure.mgmt.elasticsan.aio.operations.VolumesOperations.begin_create": "Microsoft.ElasticSan.Volumes.create", + "azure.mgmt.elasticsan.operations.VolumesOperations.begin_update": "Microsoft.ElasticSan.Volumes.update", + "azure.mgmt.elasticsan.aio.operations.VolumesOperations.begin_update": "Microsoft.ElasticSan.Volumes.update", + "azure.mgmt.elasticsan.operations.VolumesOperations.begin_delete": "Microsoft.ElasticSan.Volumes.delete", + "azure.mgmt.elasticsan.aio.operations.VolumesOperations.begin_delete": "Microsoft.ElasticSan.Volumes.delete", + "azure.mgmt.elasticsan.operations.VolumesOperations.list_by_volume_group": "Microsoft.ElasticSan.Volumes.listByVolumeGroup", + "azure.mgmt.elasticsan.aio.operations.VolumesOperations.list_by_volume_group": "Microsoft.ElasticSan.Volumes.listByVolumeGroup", + "azure.mgmt.elasticsan.operations.VolumesOperations.begin_restore_volume": "Microsoft.ElasticSan.Volumes.restoreVolume", + "azure.mgmt.elasticsan.aio.operations.VolumesOperations.begin_restore_volume": "Microsoft.ElasticSan.Volumes.restoreVolume", + "azure.mgmt.elasticsan.operations.SnapshotsOperations.get": "Microsoft.ElasticSan.Snapshots.get", + "azure.mgmt.elasticsan.aio.operations.SnapshotsOperations.get": "Microsoft.ElasticSan.Snapshots.get", + "azure.mgmt.elasticsan.operations.SnapshotsOperations.begin_create": "Microsoft.ElasticSan.Snapshots.create", + "azure.mgmt.elasticsan.aio.operations.SnapshotsOperations.begin_create": "Microsoft.ElasticSan.Snapshots.create", + "azure.mgmt.elasticsan.operations.SnapshotsOperations.begin_delete": "Microsoft.ElasticSan.Snapshots.delete", + "azure.mgmt.elasticsan.aio.operations.SnapshotsOperations.begin_delete": "Microsoft.ElasticSan.Snapshots.delete", + "azure.mgmt.elasticsan.operations.SnapshotsOperations.list_by_volume_group": "Microsoft.ElasticSan.Snapshots.listByVolumeGroup", + "azure.mgmt.elasticsan.aio.operations.SnapshotsOperations.list_by_volume_group": "Microsoft.ElasticSan.Snapshots.listByVolumeGroup", + "azure.mgmt.elasticsan.operations.SkusOperationGroupOperations.list": "Microsoft.ElasticSan.SkusOperationGroup.list", + "azure.mgmt.elasticsan.aio.operations.SkusOperationGroupOperations.list": "Microsoft.ElasticSan.SkusOperationGroup.list" + } +} \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py index de80df82f242..17d8dfc72b56 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._elastic_san_mgmt_client import ElasticSanMgmtClient # type: ignore +from ._client import ElasticSanClient # type: ignore from ._version import VERSION __version__ = VERSION @@ -25,7 +25,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ElasticSanMgmtClient", + "ElasticSanClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_client.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_client.py similarity index 65% rename from sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_client.py rename to sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_client.py index 410a876e57b9..e452fd8bda68 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_client.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_client.py @@ -2,31 +2,30 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models -from ._configuration import ElasticSanMgmtClientConfiguration -from ._serialization import Deserializer, Serializer +from ._configuration import ElasticSanClientConfiguration +from ._utils.serialization import Deserializer, Serializer from .operations import ( - ElasticSanMgmtClientOperationsMixin, ElasticSansOperations, Operations, PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - SkusOperations, + SkusOperationGroupOperations, + SnapshotsOperations, VolumeGroupsOperations, - VolumeSnapshotsOperations, VolumesOperations, ) @@ -34,50 +33,55 @@ from azure.core.credentials import TokenCredential -class ElasticSanMgmtClient(ElasticSanMgmtClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """ElasticSanMgmtClient. +class ElasticSanClient: # pylint: disable=too-many-instance-attributes + """(missing-service-description) Add service description. :ivar operations: Operations operations :vartype operations: azure.mgmt.elasticsan.operations.Operations - :ivar skus: SkusOperations operations - :vartype skus: azure.mgmt.elasticsan.operations.SkusOperations :ivar elastic_sans: ElasticSansOperations operations :vartype elastic_sans: azure.mgmt.elasticsan.operations.ElasticSansOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.elasticsan.operations.PrivateEndpointConnectionsOperations :ivar volume_groups: VolumeGroupsOperations operations :vartype volume_groups: azure.mgmt.elasticsan.operations.VolumeGroupsOperations :ivar volumes: VolumesOperations operations :vartype volumes: azure.mgmt.elasticsan.operations.VolumesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.elasticsan.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.elasticsan.operations.PrivateLinkResourcesOperations - :ivar volume_snapshots: VolumeSnapshotsOperations operations - :vartype volume_snapshots: azure.mgmt.elasticsan.operations.VolumeSnapshotsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.elasticsan.operations.SnapshotsOperations + :ivar skus_operation_group: SkusOperationGroupOperations operations + :vartype skus_operation_group: azure.mgmt.elasticsan.operations.SkusOperationGroupOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-07-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: - self._config = ElasticSanMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + _endpoint = "{endpoint}" + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ElasticSanClientConfiguration( + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -96,34 +100,30 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.elastic_sans = ElasticSansOperations(self._client, self._config, self._serialize, self._deserialize) - self.volume_groups = VolumeGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.volumes = VolumesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.volume_snapshots = VolumeSnapshotsOperations( + self.volume_groups = VolumeGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.volumes = VolumesOperations(self._client, self._config, self._serialize, self._deserialize) + self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus_operation_group = SkusOperationGroupOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -136,7 +136,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py index d5648eef13d0..e76aa63ba0ec 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,22 +17,31 @@ from azure.core.credentials import TokenCredential -class ElasticSanMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ElasticSanMgmtClient. +class ElasticSanClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for ElasticSanClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: The API version to use for this operation. Default value is + "2024-07-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: api_version: str = kwargs.pop("api_version", "2024-07-01-preview") if credential is None: @@ -42,6 +51,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-elasticsan/{}".format(VERSION)) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/model_base.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/model_base.py new file mode 100644 index 000000000000..49d5c7259389 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/model_base.py @@ -0,0 +1,1232 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_serialization.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/serialization.py similarity index 94% rename from sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_serialization.py rename to sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/serialization.py index b24ab2885450..eb86ea23c965 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_serialization.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_utils/serialization.py @@ -1,28 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -48,9 +30,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -61,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +165,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +393,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -626,7 +540,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -736,8 +650,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +695,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +719,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +749,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +769,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -1192,7 +1106,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1132,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1165,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1429,7 +1343,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1488,7 +1402,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1502,7 +1416,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1717,7 +1631,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1799,7 +1713,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1845,7 +1759,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1936,7 +1850,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1949,7 +1863,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1964,7 +1878,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1982,7 +1896,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1995,7 +1909,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2013,7 +1927,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2029,7 +1943,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2044,14 +1958,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2067,7 +1981,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2105,7 +2019,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py deleted file mode 100644 index 0991066f64ac..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import ElasticSanMgmtClientConfiguration - -if TYPE_CHECKING: - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -class ElasticSanMgmtClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: ElasticSanMgmtClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py index 6f72e83fa148..c04584b58b20 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py @@ -2,8 +2,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.2.0b2" +VERSION = "1.2.0b3" diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py index 3cf3381c16f0..a4b275a3cc74 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._elastic_san_mgmt_client import ElasticSanMgmtClient # type: ignore +from ._client import ElasticSanClient # type: ignore try: from ._patch import __all__ as _patch_all @@ -22,7 +22,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ElasticSanMgmtClient", + "ElasticSanClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_client.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_client.py similarity index 66% rename from sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_client.py rename to sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_client.py index b7896d46888b..92ca24987c63 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_client.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_client.py @@ -2,31 +2,30 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ElasticSanMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer +from ._configuration import ElasticSanClientConfiguration from .operations import ( - ElasticSanMgmtClientOperationsMixin, ElasticSansOperations, Operations, PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - SkusOperations, + SkusOperationGroupOperations, + SnapshotsOperations, VolumeGroupsOperations, - VolumeSnapshotsOperations, VolumesOperations, ) @@ -34,50 +33,56 @@ from azure.core.credentials_async import AsyncTokenCredential -class ElasticSanMgmtClient(ElasticSanMgmtClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """ElasticSanMgmtClient. +class ElasticSanClient: # pylint: disable=too-many-instance-attributes + """(missing-service-description) Add service description. :ivar operations: Operations operations :vartype operations: azure.mgmt.elasticsan.aio.operations.Operations - :ivar skus: SkusOperations operations - :vartype skus: azure.mgmt.elasticsan.aio.operations.SkusOperations :ivar elastic_sans: ElasticSansOperations operations :vartype elastic_sans: azure.mgmt.elasticsan.aio.operations.ElasticSansOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.elasticsan.aio.operations.PrivateEndpointConnectionsOperations :ivar volume_groups: VolumeGroupsOperations operations :vartype volume_groups: azure.mgmt.elasticsan.aio.operations.VolumeGroupsOperations :ivar volumes: VolumesOperations operations :vartype volumes: azure.mgmt.elasticsan.aio.operations.VolumesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.elasticsan.aio.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.elasticsan.aio.operations.PrivateLinkResourcesOperations - :ivar volume_snapshots: VolumeSnapshotsOperations operations - :vartype volume_snapshots: azure.mgmt.elasticsan.aio.operations.VolumeSnapshotsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.elasticsan.aio.operations.SnapshotsOperations + :ivar skus_operation_group: SkusOperationGroupOperations operations + :vartype skus_operation_group: + azure.mgmt.elasticsan.aio.operations.SkusOperationGroupOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2024-07-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: - self._config = ElasticSanMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + _endpoint = "{endpoint}" + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ElasticSanClientConfiguration( + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -96,28 +101,26 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.elastic_sans = ElasticSansOperations(self._client, self._config, self._serialize, self._deserialize) - self.volume_groups = VolumeGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.volumes = VolumesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.volume_snapshots = VolumeSnapshotsOperations( + self.volume_groups = VolumeGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.volumes = VolumesOperations(self._client, self._config, self._serialize, self._deserialize) + self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus_operation_group = SkusOperationGroupOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -125,7 +128,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -138,7 +141,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py index 7f103110510e..f41ff3fd84b3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,22 +17,31 @@ from azure.core.credentials_async import AsyncTokenCredential -class ElasticSanMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ElasticSanMgmtClient. +class ElasticSanClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for ElasticSanClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: The API version to use for this operation. Default value is + "2024-07-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: api_version: str = kwargs.pop("api_version", "2024-07-01-preview") if credential is None: @@ -42,6 +51,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-elasticsan/{}".format(VERSION)) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_vendor.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_vendor.py deleted file mode 100644 index a6050133f86d..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import ElasticSanMgmtClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class ElasticSanMgmtClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: ElasticSanMgmtClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py index fae06f03570b..e935c5d90360 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,14 +13,12 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import Operations # type: ignore -from ._skus_operations import SkusOperations # type: ignore -from ._elastic_sans_operations import ElasticSansOperations # type: ignore -from ._volume_groups_operations import VolumeGroupsOperations # type: ignore -from ._volumes_operations import VolumesOperations # type: ignore -from ._elastic_san_mgmt_client_operations import ElasticSanMgmtClientOperationsMixin # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._volume_snapshots_operations import VolumeSnapshotsOperations # type: ignore +from ._operations import ElasticSansOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import VolumeGroupsOperations # type: ignore +from ._operations import VolumesOperations # type: ignore +from ._operations import SnapshotsOperations # type: ignore +from ._operations import SkusOperationGroupOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -28,14 +26,12 @@ __all__ = [ "Operations", - "SkusOperations", "ElasticSansOperations", + "PrivateEndpointConnectionsOperations", "VolumeGroupsOperations", "VolumesOperations", - "ElasticSanMgmtClientOperationsMixin", - "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", - "VolumeSnapshotsOperations", + "SnapshotsOperations", + "SkusOperationGroupOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_san_mgmt_client_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_san_mgmt_client_operations.py deleted file mode 100644 index 327f7c4a5a0b..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_san_mgmt_client_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._elastic_san_mgmt_client_operations import build_restore_volume_request -from .._vendor import ElasticSanMgmtClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ElasticSanMgmtClientOperationsMixin(ElasticSanMgmtClientMixinABC): - - async def _restore_volume_initial( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_volume_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_restore_volume( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Restore Soft Deleted Volumes. The volume name is obtained by using the API to list soft deleted - volumes by volume group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :return: An instance of AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :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.Volume] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._restore_volume_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Volume].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Volume]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py deleted file mode 100644 index caaac706e01c..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py +++ /dev/null @@ -1,784 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._elastic_sans_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ElasticSansOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`elastic_sans` 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_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ElasticSan"]: - """Gets a list of ElasticSans in a subscription. - - :return: An iterator like instance of either ElasticSan or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSanList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticSanList", 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) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ElasticSan"]: - """Gets a list of ElasticSan in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either ElasticSan or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSanList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticSanList", 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) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSan, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "ElasticSan") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: _models.ElasticSan, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticSan]: - """Create ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan - :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 AsyncLROPoller that returns either ElasticSan or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticSan]: - """Create ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. 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 AsyncLROPoller that returns either ElasticSan or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSan, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticSan]: - """Create ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSan type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSan] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ElasticSan].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ElasticSan]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "ElasticSanUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: _models.ElasticSanUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticSan]: - """Update a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate - :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 AsyncLROPoller that returns either ElasticSan or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticSan]: - """Update a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. 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 AsyncLROPoller that returns either ElasticSan or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticSan]: - """Update a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSanUpdate type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSan] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._update_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ElasticSan].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ElasticSan]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - 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: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> _models.ElasticSan: - """Get a ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: ElasticSan or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.ElasticSan - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ElasticSan] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py index feddd16b9123..cabb2b14d297 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py @@ -1,14 +1,18 @@ +# 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. +# Code generated by Microsoft (R) Python 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, Optional, TypeVar +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,23 +20,59 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ...operations._operations import build_list_request +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operations import ( + build_elastic_sans_create_request, + build_elastic_sans_delete_request, + build_elastic_sans_get_request, + build_elastic_sans_list_by_elastic_san_request, + build_elastic_sans_list_by_resource_group_request, + build_elastic_sans_list_by_subscription_request, + build_elastic_sans_update_request, + build_operations_list_request, + build_private_endpoint_connections_create_request, + build_private_endpoint_connections_delete_request, + build_private_endpoint_connections_get_request, + build_private_endpoint_connections_list_request, + build_skus_operation_group_list_request, + build_snapshots_create_request, + build_snapshots_delete_request, + build_snapshots_get_request, + build_snapshots_list_by_volume_group_request, + build_volume_groups_create_request, + build_volume_groups_delete_request, + build_volume_groups_get_request, + build_volume_groups_list_by_elastic_san_request, + build_volume_groups_pre_backup_request, + build_volume_groups_pre_restore_request, + build_volume_groups_update_request, + build_volumes_create_request, + build_volumes_delete_request, + build_volumes_get_request, + build_volumes_list_by_volume_group_request, + build_volumes_restore_volume_request, + build_volumes_update_request, +) +from .._configuration import ElasticSanClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] class Operations: @@ -41,32 +81,766 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s :attr:`operations` 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Gets a list of ElasticSan operations. + """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ElasticSansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s + :attr:`elastic_sans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> _models.ElasticSan: + """Get a ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: ElasticSan. The ElasticSan is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.ElasticSan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ElasticSan] = kwargs.pop("cls", None) + + _request = build_elastic_sans_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ElasticSan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_sans_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: _models.ElasticSan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. 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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Is one of the following types: ElasticSan, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSanUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_sans_update_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: _models.ElasticSanUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate + :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 AsyncLROPoller that returns ElasticSan. The ElasticSan is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns ElasticSan. The ElasticSan is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. 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 AsyncLROPoller that returns ElasticSan. The ElasticSan is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSanUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Is one of the following types: ElasticSanUpdate, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ElasticSan. The ElasticSan is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ElasticSan] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._update_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ElasticSan, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ElasticSan].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ElasticSan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, elastic_san_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_elastic_sans_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, elastic_san_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ElasticSan"]: + """Gets a list of ElasticSan in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of ElasticSan + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ElasticSan]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -79,12 +853,19 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_elastic_sans_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -99,16 +880,3731 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ElasticSan], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ElasticSan"]: + """Gets a list of ElasticSans in a subscription. + + :return: An iterator like instance of ElasticSan + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticSan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_elastic_sans_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ElasticSan], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_elastic_san( + self, resource_group_name: str, elastic_san_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Gets the private link resources that need to be created for a elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_elastic_sans_list_by_elastic_san_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. 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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. Is one of the following types: + PrivateEndpointConnection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _delete_initial( + self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, elastic_san_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List all Private Endpoint Connections associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_private_endpoint_connections_list_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VolumeGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s + :attr:`volume_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any + ) -> _models.VolumeGroup: + """Get an VolumeGroups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :return: VolumeGroup. The VolumeGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VolumeGroup] = kwargs.pop("cls", None) + + _request = build_volume_groups_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VolumeGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.VolumeGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. 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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Is one of the following types: VolumeGroup, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_update_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.VolumeGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate + :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 AsyncLROPoller that returns VolumeGroup. The VolumeGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns VolumeGroup. The VolumeGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. 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 AsyncLROPoller that returns VolumeGroup. The VolumeGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Is one of the following types: VolumeGroupUpdate, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns VolumeGroup. The VolumeGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VolumeGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._update_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VolumeGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VolumeGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VolumeGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_volume_groups_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_elastic_san( + self, + resource_group_name: str, + elastic_san_name: str, + *, + x_ms_access_soft_deleted_resources: Optional[Union[str, _models.X_ms_access_soft_deleted_resources]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VolumeGroup"]: + """List VolumeGroups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :keyword x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volume groups + if set to true. If set to false or if not specified, returns only active volume groups. Known + values are: "true" and "false". Default value is None. + :paramtype x_ms_access_soft_deleted_resources: str or + ~azure.mgmt.elasticsan.models.X_ms_access_soft_deleted_resources + :return: An iterator like instance of VolumeGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VolumeGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_volume_groups_list_by_elastic_san_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.VolumeGroup], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _pre_backup_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeNameList, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_pre_backup_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.VolumeNameList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList + :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 AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). Required. + :type parameters: JSON + :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 AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). 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 AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeNameList, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). Is one of the following types: VolumeNameList, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreValidationResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._pre_backup_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PreValidationResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PreValidationResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PreValidationResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _pre_restore_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.DiskSnapshotList, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_pre_restore_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.DiskSnapshotList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). Required. + :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList + :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 AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). Required. + :type parameters: JSON + :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 AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). 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 AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.DiskSnapshotList, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). Is one of the following types: DiskSnapshotList, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PreValidationResponse. The + PreValidationResponse is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreValidationResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._pre_restore_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PreValidationResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PreValidationResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PreValidationResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class VolumesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s + :attr:`volumes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any + ) -> _models.Volume: + """Get an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :return: Volume. The Volume is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.Volume + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Volume] = kwargs.pop("cls", None) + + _request = build_volumes_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Volume, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.Volume, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volumes_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: _models.Volume, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Volume + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. 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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.Volume, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Is one of the following types: Volume, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.elasticsan.models.Volume or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.VolumeUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volumes_update_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: _models.VolumeUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate + :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 AsyncLROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. 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 AsyncLROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.VolumeUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Is one of the following types: VolumeUpdate, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Volume] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._update_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Volume, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Volume].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + x_ms_delete_snapshots: Optional[Union[str, _models.X_ms_delete_snapshots]] = None, + x_ms_force_delete: Optional[Union[str, _models.X_ms_force_delete]] = None, + delete_type: Optional[Union[str, _models.DeleteType]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_volumes_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + x_ms_delete_snapshots=x_ms_delete_snapshots, + x_ms_force_delete=x_ms_force_delete, + delete_type=delete_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + x_ms_delete_snapshots: Optional[Union[str, _models.X_ms_delete_snapshots]] = None, + x_ms_force_delete: Optional[Union[str, _models.X_ms_force_delete]] = None, + delete_type: Optional[Union[str, _models.DeleteType]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :keyword x_ms_delete_snapshots: Optional, used to delete snapshots under volume. Allowed value + are only true or false. Default value is false. Known values are: "true" and "false". Default + value is None. + :paramtype x_ms_delete_snapshots: str or ~azure.mgmt.elasticsan.models.X_ms_delete_snapshots + :keyword x_ms_force_delete: Optional, used to delete volume if active sessions present. Allowed + value are only true or false. Default value is false. Known values are: "true" and "false". + Default value is None. + :paramtype x_ms_force_delete: str or ~azure.mgmt.elasticsan.models.X_ms_force_delete + :keyword delete_type: Optional. Specifies that the delete operation should be a permanent + delete for the soft deleted volume. The value of deleteType can only be 'permanent'. + "permanent" Default value is None. + :paramtype delete_type: str or ~azure.mgmt.elasticsan.models.DeleteType + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + x_ms_delete_snapshots=x_ms_delete_snapshots, + x_ms_force_delete=x_ms_force_delete, + delete_type=delete_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_volume_group( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + x_ms_access_soft_deleted_resources: Optional[Union[str, _models.X_ms_access_soft_deleted_resources]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Volume"]: + """List Volumes in a VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :keyword x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volumes if set + to true. If set to false or if not specified, returns only active volumes. Known values are: + "true" and "false". Default value is None. + :paramtype x_ms_access_soft_deleted_resources: str or + ~azure.mgmt.elasticsan.models.X_ms_access_soft_deleted_resources + :return: An iterator like instance of Volume + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Volume]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_volumes_list_by_volume_group_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Volume], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _restore_volume_initial( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_volumes_restore_volume_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_restore_volume( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Volume]: + """Restore Soft Deleted Volumes. The volume name is obtained by using the API to list soft deleted + volumes by volume group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :return: An instance of AsyncLROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Volume] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._restore_volume_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Volume, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Volume].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s + :attr:`snapshots` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any + ) -> _models.Snapshot: + """Get a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :return: Snapshot. The Snapshot is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.Snapshot + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + + _request = build_snapshots_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Snapshot, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: Union[_models.Snapshot, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_snapshots_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: _models.Snapshot, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Snapshot + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. Required. + :type parameters: JSON + :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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. 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 AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: Union[_models.Snapshot, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. Is one of the following types: Snapshot, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _delete_initial( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_snapshots_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_volume_group( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Snapshot"]: + """List Snapshots in a VolumeGroup or List Snapshots by Volume (name) in a VolumeGroup using + filter. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :keyword filter: Specify $filter='volumeName eq ' to filter on volume. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of Snapshot + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Snapshot]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_snapshots_list_by_volume_group_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Snapshot], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SkusOperationGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanClient`'s + :attr:`skus_operation_group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: + """List all the available Skus in the region and information related to them. + + List all the available Skus in the region and information related to them. + + :keyword filter: Specify $filter='location eq ' to filter on location. Default value + is None. + :paramtype filter: str + :return: An iterator like instance of SkuInformation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SkuInformation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_skus_operation_group_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.SkuInformation], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -121,7 +4617,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 007dcba8b77e..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,539 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._private_endpoint_connections_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`private_endpoint_connections` 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") - - async def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "PrivateEndpointConnection") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the state of specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Private Endpoint Connection Approval object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection - :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 AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the state of specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Private Endpoint Connection Approval object. 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 AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Update the state of specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Private Endpoint Connection Approval object. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :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.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets the specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - 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: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """List all Private Endpoint Connections associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :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.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 37bf6eb8b911..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ...operations._private_link_resources_operations import build_list_by_elastic_san_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_by_elastic_san( - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources that need to be created for a elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_elastic_san_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py deleted file mode 100644 index fd5910d9c00d..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py +++ /dev/null @@ -1,136 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -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.rest import AsyncHttpResponse, 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 ...operations._skus_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`skus` 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, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: - """List all the available Skus in the region and information related to them. - - List all the available Skus in the region and information related to them. - - :param filter: Specify $filter='location eq :code:``' to filter on location. Default - value is None. - :type filter: str - :return: An iterator like instance of either SkuInformation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.SkuInformation] - :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.SkuInformationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SkuInformationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py deleted file mode 100644 index 0dcfa0bac6dc..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py +++ /dev/null @@ -1,756 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._volume_groups_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_elastic_san_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class VolumeGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`volume_groups` 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_by_elastic_san( - self, - resource_group_name: str, - elastic_san_name: str, - x_ms_access_soft_deleted_resources: Optional[Union[str, _models.XMsAccessSoftDeletedResources]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.VolumeGroup"]: - """List VolumeGroups. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volume groups if - set to true. If set to false or if not specified, returns only active volume groups. Known - values are: "true" and "false". Default value is None. - :type x_ms_access_soft_deleted_resources: str or - ~azure.mgmt.elasticsan.models.XMsAccessSoftDeletedResources - :return: An iterator like instance of either VolumeGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.VolumeGroup] - :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.VolumeGroupList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_elastic_san_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VolumeGroupList", 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) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "VolumeGroup") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.VolumeGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VolumeGroup]: - """Create a Volume Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup - :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 AsyncLROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VolumeGroup]: - """Create a Volume Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. 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 AsyncLROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VolumeGroup]: - """Create a Volume Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroup type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :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.VolumeGroup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VolumeGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VolumeGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "VolumeGroupUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.VolumeGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VolumeGroup]: - """Update an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate - :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 AsyncLROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VolumeGroup]: - """Update an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. 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 AsyncLROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VolumeGroup]: - """Update an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroupUpdate type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :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.VolumeGroup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._update_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VolumeGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VolumeGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - 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: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> _models.VolumeGroup: - """Get an VolumeGroups. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :return: VolumeGroup or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.VolumeGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_operations.py deleted file mode 100644 index 86f629e60e08..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_operations.py +++ /dev/null @@ -1,565 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._volume_snapshots_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_volume_group_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class VolumeSnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`volume_snapshots` 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_by_volume_group( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Snapshot"]: - """List Snapshots in a VolumeGroup or List Snapshots by Volume (name) in a VolumeGroup using - filter. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param filter: Specify $filter='volumeName eq :code:``' to filter on volume. - Default value is None. - :type filter: str - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Snapshot] - :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.SnapshotList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_volume_group_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", 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) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: Union[_models.Snapshot, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "Snapshot") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Create a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :param parameters: Snapshot object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Snapshot - :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 AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Create a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :param parameters: Snapshot object. 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 AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: Union[_models.Snapshot, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Create a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :param parameters: Snapshot object. Is either a Snapshot type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Snapshot] - :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.Snapshot] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Snapshot].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Snapshot]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - 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: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> _models.Snapshot: - """Get a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :return: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.Snapshot - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.Snapshot] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py deleted file mode 100644 index be7689df5ca7..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py +++ /dev/null @@ -1,1257 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._volumes_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_volume_group_request, - build_pre_backup_request, - build_pre_restore_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class VolumesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.aio.ElasticSanMgmtClient`'s - :attr:`volumes` 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") - - async def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.Volume, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "Volume") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: _models.Volume, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Create a Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Volume - :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 AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Create a Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. 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 AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.Volume, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Create a Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Is either a Volume type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Volume or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :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.Volume] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._create_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Volume].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Volume]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.VolumeUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "VolumeUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: _models.VolumeUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Update an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate - :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 AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Update an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. 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 AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.VolumeUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Volume]: - """Update an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Is either a VolumeUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Volume or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] - :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.Volume] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._update_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Volume].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Volume]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, - x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, - delete_type: Optional[Union[str, _models.DeleteType]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - x_ms_delete_snapshots=x_ms_delete_snapshots, - x_ms_force_delete=x_ms_force_delete, - delete_type=delete_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, - x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, - delete_type: Optional[Union[str, _models.DeleteType]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param x_ms_delete_snapshots: Optional, used to delete snapshots under volume. Allowed value - are only true or false. Default value is false. Known values are: "true" and "false". Default - value is None. - :type x_ms_delete_snapshots: str or ~azure.mgmt.elasticsan.models.XMsDeleteSnapshots - :param x_ms_force_delete: Optional, used to delete volume if active sessions present. Allowed - value are only true or false. Default value is false. Known values are: "true" and "false". - Default value is None. - :type x_ms_force_delete: str or ~azure.mgmt.elasticsan.models.XMsForceDelete - :param delete_type: Optional. Specifies that the delete operation should be a permanent delete - for the soft deleted volume. The value of deleteType can only be 'permanent'. "permanent" - Default value is None. - :type delete_type: str or ~azure.mgmt.elasticsan.models.DeleteType - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - x_ms_delete_snapshots=x_ms_delete_snapshots, - x_ms_force_delete=x_ms_force_delete, - delete_type=delete_type, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - 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: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any - ) -> _models.Volume: - """Get an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :return: Volume or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.Volume - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.Volume] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Volume", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_volume_group( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - x_ms_access_soft_deleted_resources: Optional[Union[str, _models.XMsAccessSoftDeletedResources]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Volume"]: - """List Volumes in a VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volumes if set - to true. If set to false or if not specified, returns only active volumes. Known values are: - "true" and "false". Default value is None. - :type x_ms_access_soft_deleted_resources: str or - ~azure.mgmt.elasticsan.models.XMsAccessSoftDeletedResources - :return: An iterator like instance of either Volume or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Volume] - :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.VolumeList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_volume_group_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VolumeList", 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) - - _stream = False - pipeline_response: PipelineResponse = await 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _pre_backup_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeNameList, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "VolumeNameList") - - _request = build_pre_backup_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_pre_backup( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.VolumeNameList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PreValidationResponse]: - """Validate whether a disk snapshot backup can be taken for list of volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Name List (currently only one volume name in the list is supported. - Server would return error if list is bigger). Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList - :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 AsyncLROPoller that returns either PreValidationResponse or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_pre_backup( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PreValidationResponse]: - """Validate whether a disk snapshot backup can be taken for list of volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Name List (currently only one volume name in the list is supported. - Server would return error if list is bigger). 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 AsyncLROPoller that returns either PreValidationResponse or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_pre_backup( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeNameList, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PreValidationResponse]: - """Validate whether a disk snapshot backup can be taken for list of volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Name List (currently only one volume name in the list is supported. - Server would return error if list is bigger). Is either a VolumeNameList type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PreValidationResponse or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :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.PreValidationResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._pre_backup_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PreValidationResponse", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PreValidationResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PreValidationResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _pre_restore_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.DiskSnapshotList, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, "DiskSnapshotList") - - _request = build_pre_restore_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_pre_restore( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.DiskSnapshotList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PreValidationResponse]: - """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is - supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server - would return error if list is bigger). Required. - :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList - :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 AsyncLROPoller that returns either PreValidationResponse or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_pre_restore( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PreValidationResponse]: - """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is - supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server - would return error if list is bigger). 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 AsyncLROPoller that returns either PreValidationResponse or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_pre_restore( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.DiskSnapshotList, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PreValidationResponse]: - """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is - supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server - would return error if list is bigger). Is either a DiskSnapshotList type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PreValidationResponse or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :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.PreValidationResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = 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 = await self._pre_restore_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PreValidationResponse", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PreValidationResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PreValidationResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/__init__.py index 34b3e7dcfcfe..07dd82328e4c 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/__init__.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,12 +13,11 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore AutoScaleProperties, DeleteRetentionPolicy, DiskSnapshotList, ElasticSan, - ElasticSanList, ElasticSanProperties, ElasticSanUpdate, ElasticSanUpdateProperties, @@ -34,14 +33,11 @@ NetworkRuleSet, Operation, OperationDisplay, - OperationListResult, PreValidationResponse, PrivateEndpoint, PrivateEndpointConnection, - PrivateEndpointConnectionListResult, PrivateEndpointConnectionProperties, PrivateLinkResource, - PrivateLinkResourceListResult, PrivateLinkResourceProperties, PrivateLinkServiceConnectionState, ProxyResource, @@ -50,11 +46,9 @@ ScaleUpProperties, Sku, SkuInformation, - SkuInformationList, SkuLocationInfo, Snapshot, SnapshotCreationData, - SnapshotList, SnapshotProperties, SourceCreationData, SystemData, @@ -63,18 +57,16 @@ VirtualNetworkRule, Volume, VolumeGroup, - VolumeGroupList, VolumeGroupProperties, VolumeGroupUpdate, VolumeGroupUpdateProperties, - VolumeList, VolumeNameList, VolumeProperties, VolumeUpdate, VolumeUpdateProperties, ) -from ._elastic_san_mgmt_client_enums import ( # type: ignore +from ._enums import ( # type: ignore Action, ActionType, AutoScalePolicyEnforcement, @@ -92,9 +84,9 @@ SkuTier, StorageTargetType, VolumeCreateOption, - XMsAccessSoftDeletedResources, - XMsDeleteSnapshots, - XMsForceDelete, + X_ms_access_soft_deleted_resources, + X_ms_delete_snapshots, + X_ms_force_delete, ) from ._patch import __all__ as _patch_all from ._patch import * @@ -105,7 +97,6 @@ "DeleteRetentionPolicy", "DiskSnapshotList", "ElasticSan", - "ElasticSanList", "ElasticSanProperties", "ElasticSanUpdate", "ElasticSanUpdateProperties", @@ -121,14 +112,11 @@ "NetworkRuleSet", "Operation", "OperationDisplay", - "OperationListResult", "PreValidationResponse", "PrivateEndpoint", "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", "PrivateEndpointConnectionProperties", "PrivateLinkResource", - "PrivateLinkResourceListResult", "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", "ProxyResource", @@ -137,11 +125,9 @@ "ScaleUpProperties", "Sku", "SkuInformation", - "SkuInformationList", "SkuLocationInfo", "Snapshot", "SnapshotCreationData", - "SnapshotList", "SnapshotProperties", "SourceCreationData", "SystemData", @@ -150,11 +136,9 @@ "VirtualNetworkRule", "Volume", "VolumeGroup", - "VolumeGroupList", "VolumeGroupProperties", "VolumeGroupUpdate", "VolumeGroupUpdateProperties", - "VolumeList", "VolumeNameList", "VolumeProperties", "VolumeUpdate", @@ -176,9 +160,9 @@ "SkuTier", "StorageTargetType", "VolumeCreateOption", - "XMsAccessSoftDeletedResources", - "XMsDeleteSnapshots", - "XMsForceDelete", + "X_ms_access_soft_deleted_resources", + "X_ms_delete_snapshots", + "X_ms_force_delete", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_enums.py similarity index 80% rename from sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py rename to sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_enums.py index 2597d0b8f277..733c598b3693 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,9 +17,12 @@ class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + """Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal + only APIs. + """ INTERNAL = "Internal" + """Actions are for internal-only APIs.""" class AutoScalePolicyEnforcement(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -31,16 +34,20 @@ class AutoScalePolicyEnforcement(str, Enum, metaclass=CaseInsensitiveEnumMeta): class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class DeleteType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DeleteType.""" + """Type of DeleteType.""" PERMANENT = "permanent" @@ -82,12 +89,15 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ USER = "user" + """Indicates the operation is initiated by a user.""" SYSTEM = "system" + """Indicates the operation is initiated by a system.""" USER_SYSTEM = "user,system" + """Indicates the operation is initiated by a user or system.""" class PolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyState.""" + """Type of PolicyState.""" ENABLED = "Enabled" DISABLED = "Disabled" @@ -160,22 +170,22 @@ class VolumeCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISK_RESTORE_POINT = "DiskRestorePoint" -class XMsAccessSoftDeletedResources(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """XMsAccessSoftDeletedResources.""" +class X_ms_access_soft_deleted_resources(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of x-ms-access-soft-deleted-resources.""" TRUE = "true" FALSE = "false" -class XMsDeleteSnapshots(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """XMsDeleteSnapshots.""" +class X_ms_delete_snapshots(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of x-ms-delete-snapshots.""" TRUE = "true" FALSE = "false" -class XMsForceDelete(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """XMsForceDelete.""" +class X_ms_force_delete(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of x-ms-force-delete.""" TRUE = "true" FALSE = "false" diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models.py new file mode 100644 index 000000000000..97a9a055e75b --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models.py @@ -0,0 +1,2257 @@ +# pylint: disable=line-too-long,useless-suppression,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class AutoScaleProperties(_Model): + """The auto scale settings on Elastic San Appliance. + + :ivar scale_up_properties: Scale up settings on Elastic San Appliance. + :vartype scale_up_properties: ~azure.mgmt.elasticsan.models.ScaleUpProperties + """ + + scale_up_properties: Optional["_models.ScaleUpProperties"] = rest_field( + name="scaleUpProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Scale up settings on Elastic San Appliance.""" + + @overload + def __init__( + self, + *, + scale_up_properties: Optional["_models.ScaleUpProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeleteRetentionPolicy(_Model): + """Response for Delete Retention Policy object. + + :ivar policy_state: Known values are: "Enabled" and "Disabled". + :vartype policy_state: str or ~azure.mgmt.elasticsan.models.PolicyState + :ivar retention_period_days: The number of days to retain the resources after deletion. + :vartype retention_period_days: int + """ + + policy_state: Optional[Union[str, "_models.PolicyState"]] = rest_field( + name="policyState", visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"Enabled\" and \"Disabled\".""" + retention_period_days: Optional[int] = rest_field( + name="retentionPeriodDays", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of days to retain the resources after deletion.""" + + @overload + def __init__( + self, + *, + policy_state: Optional[Union[str, "_models.PolicyState"]] = None, + retention_period_days: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DiskSnapshotList(_Model): + """object to hold array of Disk Snapshot ARM IDs. + + :ivar disk_snapshot_ids: array of DiskSnapshot ARM IDs. Required. + :vartype disk_snapshot_ids: list[str] + """ + + disk_snapshot_ids: List[str] = rest_field( + name="diskSnapshotIds", visibility=["read", "create", "update", "delete", "query"] + ) + """array of DiskSnapshot ARM IDs. Required.""" + + @overload + def __init__( + self, + *, + disk_snapshot_ids: List[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticSan(TrackedResource): + """Response for ElasticSan request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Properties of ElasticSan. Required. + :vartype properties: ~azure.mgmt.elasticsan.models.ElasticSanProperties + """ + + properties: "_models.ElasticSanProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of ElasticSan. Required.""" + + __flattened_items = [ + "sku", + "availability_zones", + "provisioning_state", + "base_size_ti_b", + "extended_capacity_size_ti_b", + "total_volume_size_gi_b", + "volume_group_count", + "total_iops", + "total_m_bps", + "total_size_ti_b", + "private_endpoint_connections", + "public_network_access", + "auto_scale_properties", + ] + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.ElasticSanProperties", + tags: Optional[Dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ElasticSanProperties(_Model): + """Elastic San response properties. + + :ivar sku: resource sku. Required. + :vartype sku: ~azure.mgmt.elasticsan.models.Sku + :ivar availability_zones: Logical zone for Elastic San resource; example: ["1"]. + :vartype availability_zones: list[str] + :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", + "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", + "Restoring", and "SoftDeleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar base_size_ti_b: Base size of the Elastic San appliance in TiB. Required. + :vartype base_size_ti_b: int + :ivar extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. Required. + :vartype extended_capacity_size_ti_b: int + :ivar total_volume_size_gi_b: Total size of the provisioned Volumes in GiB. + :vartype total_volume_size_gi_b: int + :ivar volume_group_count: Total number of volume groups in this Elastic San appliance. + :vartype volume_group_count: int + :ivar total_iops: Total Provisioned IOPS of the Elastic San appliance. + :vartype total_iops: int + :ivar total_m_bps: Total Provisioned MBps Elastic San appliance. + :vartype total_m_bps: int + :ivar total_size_ti_b: Total size of the Elastic San appliance in TB. + :vartype total_size_ti_b: int + :ivar private_endpoint_connections: The list of Private Endpoint Connections. + :vartype private_endpoint_connections: + list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] + :ivar public_network_access: Allow or disallow public network access to ElasticSan. Value is + optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or ~azure.mgmt.elasticsan.models.PublicNetworkAccess + :ivar auto_scale_properties: Auto Scale Properties for Elastic San Appliance. + :vartype auto_scale_properties: ~azure.mgmt.elasticsan.models.AutoScaleProperties + """ + + sku: "_models.Sku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """resource sku. Required.""" + availability_zones: Optional[List[str]] = rest_field( + name="availabilityZones", visibility=["read", "create", "update", "delete", "query"] + ) + """Logical zone for Elastic San resource; example: [\"1\"].""" + provisioning_state: Optional[Union[str, "_models.ProvisioningStates"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """State of the operation on the resource. Known values are: \"Invalid\", \"Succeeded\", + \"Failed\", \"Canceled\", \"Pending\", \"Creating\", \"Updating\", \"Deleting\", \"Deleted\", + \"Restoring\", and \"SoftDeleting\".""" + base_size_ti_b: int = rest_field(name="baseSizeTiB", visibility=["read", "create"]) + """Base size of the Elastic San appliance in TiB. Required.""" + extended_capacity_size_ti_b: int = rest_field(name="extendedCapacitySizeTiB", visibility=["read", "create"]) + """Extended size of the Elastic San appliance in TiB. Required.""" + total_volume_size_gi_b: Optional[int] = rest_field(name="totalVolumeSizeGiB", visibility=["read"]) + """Total size of the provisioned Volumes in GiB.""" + volume_group_count: Optional[int] = rest_field(name="volumeGroupCount", visibility=["read"]) + """Total number of volume groups in this Elastic San appliance.""" + total_iops: Optional[int] = rest_field(name="totalIops", visibility=["read"]) + """Total Provisioned IOPS of the Elastic San appliance.""" + total_m_bps: Optional[int] = rest_field(name="totalMBps", visibility=["read"]) + """Total Provisioned MBps Elastic San appliance.""" + total_size_ti_b: Optional[int] = rest_field(name="totalSizeTiB", visibility=["read"]) + """Total size of the Elastic San appliance in TB.""" + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """The list of Private Endpoint Connections.""" + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Allow or disallow public network access to ElasticSan. Value is optional but if passed in, must + be 'Enabled' or 'Disabled'. Known values are: \"Enabled\" and \"Disabled\".""" + auto_scale_properties: Optional["_models.AutoScaleProperties"] = rest_field( + name="autoScaleProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Auto Scale Properties for Elastic San Appliance.""" + + @overload + def __init__( + self, + *, + sku: "_models.Sku", + base_size_ti_b: int, + extended_capacity_size_ti_b: int, + availability_zones: Optional[List[str]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + auto_scale_properties: Optional["_models.AutoScaleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticSanUpdate(_Model): + """Response for ElasticSan update request. + + :ivar properties: Properties of ElasticSan. + :vartype properties: ~azure.mgmt.elasticsan.models.ElasticSanUpdateProperties + :ivar tags: Update tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.ElasticSanUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of ElasticSan.""" + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Update tags.""" + + __flattened_items = [ + "base_size_ti_b", + "extended_capacity_size_ti_b", + "public_network_access", + "auto_scale_properties", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ElasticSanUpdateProperties"] = None, + tags: Optional[Dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ElasticSanUpdateProperties(_Model): + """Elastic San update properties. + + :ivar base_size_ti_b: Base size of the Elastic San appliance in TiB. + :vartype base_size_ti_b: int + :ivar extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. + :vartype extended_capacity_size_ti_b: int + :ivar public_network_access: Allow or disallow public network access to ElasticSan Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.elasticsan.models.PublicNetworkAccess + :ivar auto_scale_properties: Auto Scale Properties for Elastic San Appliance. + :vartype auto_scale_properties: ~azure.mgmt.elasticsan.models.AutoScaleProperties + """ + + base_size_ti_b: Optional[int] = rest_field(name="baseSizeTiB", visibility=["update"]) + """Base size of the Elastic San appliance in TiB.""" + extended_capacity_size_ti_b: Optional[int] = rest_field(name="extendedCapacitySizeTiB", visibility=["update"]) + """Extended size of the Elastic San appliance in TiB.""" + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Allow or disallow public network access to ElasticSan Account. Value is optional but if passed + in, must be 'Enabled' or 'Disabled'. Known values are: \"Enabled\" and \"Disabled\".""" + auto_scale_properties: Optional["_models.AutoScaleProperties"] = rest_field( + name="autoScaleProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Auto Scale Properties for Elastic San Appliance.""" + + @overload + def __init__( + self, + *, + base_size_ti_b: Optional[int] = None, + extended_capacity_size_ti_b: Optional[int] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + auto_scale_properties: Optional["_models.AutoScaleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EncryptionIdentity(_Model): + """Encryption identity for the volume group. + + :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be + associated with server-side encryption on the volume group. + :vartype encryption_user_assigned_identity: str + """ + + encryption_user_assigned_identity: Optional[str] = rest_field( + name="userAssignedIdentity", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource identifier of the UserAssigned identity to be associated with server-side encryption + on the volume group.""" + + @overload + def __init__( + self, + *, + encryption_user_assigned_identity: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EncryptionProperties(_Model): + """The encryption settings on the volume group. + + :ivar key_vault_properties: Properties provided by key vault. + :vartype key_vault_properties: ~azure.mgmt.elasticsan.models.KeyVaultProperties + :ivar encryption_identity: The identity to be used with service-side encryption at rest. + :vartype encryption_identity: ~azure.mgmt.elasticsan.models.EncryptionIdentity + """ + + key_vault_properties: Optional["_models.KeyVaultProperties"] = rest_field( + name="keyVaultProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties provided by key vault.""" + encryption_identity: Optional["_models.EncryptionIdentity"] = rest_field( + name="identity", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity to be used with service-side encryption at rest.""" + + @overload + def __init__( + self, + *, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.elasticsan.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.elasticsan.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.elasticsan.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Identity(_Model): + """Identity for the resource. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", and + "UserAssigned". + :vartype type: str or ~azure.mgmt.elasticsan.models.IdentityType + :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of + User Assigned identities that will be used with this volume group. The key is the ARM resource + identifier of the identity. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.elasticsan.models.UserAssignedIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of resource identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of resource.""" + type: Union[str, "_models.IdentityType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identity type. Required. Known values are: \"None\", \"SystemAssigned\", and + \"UserAssigned\".""" + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets a list of key value pairs that describe the set of User Assigned identities that + will be used with this volume group. The key is the ARM resource identifier of the identity.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IscsiTargetInfo(_Model): + """Iscsi target information. + + :ivar target_iqn: iSCSI Target IQN (iSCSI Qualified Name); example: + "iqn.2005-03.org.iscsi:server". + :vartype target_iqn: str + :ivar target_portal_hostname: iSCSI Target Portal Host Name. + :vartype target_portal_hostname: str + :ivar target_portal_port: iSCSI Target Portal Port. + :vartype target_portal_port: int + :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", + "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", + "Restoring", and "SoftDeleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar status: Operational status of the iSCSI Target. Known values are: "Invalid", "Unknown", + "Healthy", "Unhealthy", "Updating", "Running", "Stopped", and "Stopped (deallocated)". + :vartype status: str or ~azure.mgmt.elasticsan.models.OperationalStatus + """ + + target_iqn: Optional[str] = rest_field(name="targetIqn", visibility=["read"]) + """iSCSI Target IQN (iSCSI Qualified Name); example: \"iqn.2005-03.org.iscsi:server\".""" + target_portal_hostname: Optional[str] = rest_field(name="targetPortalHostname", visibility=["read"]) + """iSCSI Target Portal Host Name.""" + target_portal_port: Optional[int] = rest_field(name="targetPortalPort", visibility=["read"]) + """iSCSI Target Portal Port.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningStates"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """State of the operation on the resource. Known values are: \"Invalid\", \"Succeeded\", + \"Failed\", \"Canceled\", \"Pending\", \"Creating\", \"Updating\", \"Deleting\", \"Deleted\", + \"Restoring\", and \"SoftDeleting\".""" + status: Optional[Union[str, "_models.OperationalStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Operational status of the iSCSI Target. Known values are: \"Invalid\", \"Unknown\", + \"Healthy\", \"Unhealthy\", \"Updating\", \"Running\", \"Stopped\", and \"Stopped + (deallocated)\".""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.OperationalStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyVaultProperties(_Model): + """Properties of key vault. + + :ivar key_name: The name of KeyVault key. + :vartype key_name: str + :ivar key_version: The version of KeyVault key. + :vartype key_version: str + :ivar key_vault_uri: The Uri of KeyVault. + :vartype key_vault_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + :ivar current_versioned_key_expiration_timestamp: This is a read only property that represents + the expiration time of the current version of the customer managed key used for encryption. + :vartype current_versioned_key_expiration_timestamp: ~datetime.datetime + """ + + key_name: Optional[str] = rest_field(name="keyName", visibility=["read", "create", "update", "delete", "query"]) + """The name of KeyVault key.""" + key_version: Optional[str] = rest_field( + name="keyVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The version of KeyVault key.""" + key_vault_uri: Optional[str] = rest_field( + name="keyVaultUri", visibility=["read", "create", "update", "delete", "query"] + ) + """The Uri of KeyVault.""" + current_versioned_key_identifier: Optional[str] = rest_field( + name="currentVersionedKeyIdentifier", visibility=["read"] + ) + """The object identifier of the current versioned Key Vault Key in use.""" + last_key_rotation_timestamp: Optional[datetime.datetime] = rest_field( + name="lastKeyRotationTimestamp", visibility=["read"], format="rfc3339" + ) + """Timestamp of last rotation of the Key Vault Key.""" + current_versioned_key_expiration_timestamp: Optional[datetime.datetime] = rest_field( + name="currentVersionedKeyExpirationTimestamp", visibility=["read"], format="rfc3339" + ) + """This is a read only property that represents the expiration time of the current version of the + customer managed key used for encryption.""" + + @overload + def __init__( + self, + *, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + key_vault_uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedByInfo(_Model): + """Parent resource information. + + :ivar resource_id: Resource ID of the resource managing the volume, this is a restricted field + and can only be set for internal use. + :vartype resource_id: str + """ + + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource ID of the resource managing the volume, this is a restricted field and can only be set + for internal use.""" + + @overload + def __init__( + self, + *, + resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkRuleSet(_Model): + """A set of rules governing the network accessibility. + + :ivar virtual_network_rules: The list of virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.elasticsan.models.VirtualNetworkRule] + """ + + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = rest_field( + name="virtualNetworkRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of virtual network rules.""" + + @overload + def __init__( + self, + *, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """REST API Operation. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for Azure Resource Manager/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.elasticsan.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.elasticsan.models.Origin + :ivar action_type: Extensible enum. Indicates the action type. "Internal" refers to actions + that are for internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.elasticsan.models.ActionType + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + \"Microsoft.Compute/virtualMachines/write\", + \"Microsoft.Compute/virtualMachines/capture/action\".""" + is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) + """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and + \"false\" for Azure Resource Manager/control-plane operations.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Localized display information for this particular operation.""" + origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and + \"user,system\".""" + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) + """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for + internal only APIs. \"Internal\"""" + + @overload + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """Localized display information for and operation. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring + Insights\" or \"Microsoft Compute\".""" + resource: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly name of the resource type related to this operation. E.g. \"Virtual + Machines\" or \"Job Schedule Collections\".""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create + or Update Virtual Machine\", \"Restart Virtual Machine\".""" + description: Optional[str] = rest_field(visibility=["read"]) + """The short, localized friendly description of the operation; suitable for tool tips and detailed + views.""" + + +class PreValidationResponse(_Model): + """response object for pre validation api. + + :ivar validation_status: a status value indicating success or failure of validation. + :vartype validation_status: str + """ + + validation_status: Optional[str] = rest_field( + name="validationStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """a status value indicating success or failure of validation.""" + + @overload + def __init__( + self, + *, + validation_status: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpoint(_Model): + """Response for PrivateEndpoint. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The ARM identifier for Private Endpoint.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + """ + + +class PrivateEndpointConnection(ProxyResource): + """Response for PrivateEndpoint Connection object. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar properties: Private Endpoint Connection Properties. Required. + :vartype properties: ~azure.mgmt.elasticsan.models.PrivateEndpointConnectionProperties + """ + + properties: "_models.PrivateEndpointConnectionProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Private Endpoint Connection Properties. Required.""" + + __flattened_items = ["provisioning_state", "private_endpoint", "private_link_service_connection_state", "group_ids"] + + @overload + def __init__( + self, + *, + properties: "_models.PrivateEndpointConnectionProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionProperties(_Model): + """Response for PrivateEndpoint connection properties. + + :ivar provisioning_state: Provisioning State of Private Endpoint connection resource. Known + values are: "Invalid", "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", + "Deleting", "Deleted", "Restoring", and "SoftDeleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar private_endpoint: Private Endpoint resource. + :vartype private_endpoint: ~azure.mgmt.elasticsan.models.PrivateEndpoint + :ivar private_link_service_connection_state: Private Link Service Connection State. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.elasticsan.models.PrivateLinkServiceConnectionState + :ivar group_ids: List of resources private endpoint is mapped. + :vartype group_ids: list[str] + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningStates"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning State of Private Endpoint connection resource. Known values are: \"Invalid\", + \"Succeeded\", \"Failed\", \"Canceled\", \"Pending\", \"Creating\", \"Updating\", \"Deleting\", + \"Deleted\", \"Restoring\", and \"SoftDeleting\".""" + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Private Endpoint resource.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """Private Link Service Connection State. Required.""" + group_ids: Optional[List[str]] = rest_field( + name="groupIds", visibility=["read", "create", "update", "delete", "query"] + ) + """List of resources private endpoint is mapped.""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + group_ids: Optional[List[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(Resource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.elasticsan.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_id", "required_members", "required_zone_names"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[List[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[List[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The private link resource Private link DNS zone name.""" + + @overload + def __init__( + self, + *, + required_zone_names: Optional[List[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkServiceConnectionState(_Model): + """Response for Private Link Service Connection state. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", "Failed", and "Rejected". + :vartype status: str or ~azure.mgmt.elasticsan.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", \"Failed\", and \"Rejected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ScaleUpProperties(_Model): + """Scale up properties on Elastic San Appliance. + + :ivar unused_size_ti_b: Unused size on Elastic San appliance in TiB. + :vartype unused_size_ti_b: int + :ivar increase_capacity_unit_by_ti_b: Unit to increase Capacity Unit on Elastic San appliance + in TiB. + :vartype increase_capacity_unit_by_ti_b: int + :ivar capacity_unit_scale_up_limit_ti_b: Maximum scale up size on Elastic San appliance in TiB. + :vartype capacity_unit_scale_up_limit_ti_b: int + :ivar auto_scale_policy_enforcement: Enable or Disable scale up setting on Elastic San + Appliance. Known values are: "None", "Enabled", and "Disabled". + :vartype auto_scale_policy_enforcement: str or + ~azure.mgmt.elasticsan.models.AutoScalePolicyEnforcement + """ + + unused_size_ti_b: Optional[int] = rest_field( + name="unusedSizeTiB", visibility=["read", "create", "update", "delete", "query"] + ) + """Unused size on Elastic San appliance in TiB.""" + increase_capacity_unit_by_ti_b: Optional[int] = rest_field( + name="increaseCapacityUnitByTiB", visibility=["read", "create", "update", "delete", "query"] + ) + """Unit to increase Capacity Unit on Elastic San appliance in TiB.""" + capacity_unit_scale_up_limit_ti_b: Optional[int] = rest_field( + name="capacityUnitScaleUpLimitTiB", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum scale up size on Elastic San appliance in TiB.""" + auto_scale_policy_enforcement: Optional[Union[str, "_models.AutoScalePolicyEnforcement"]] = rest_field( + name="autoScalePolicyEnforcement", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or Disable scale up setting on Elastic San Appliance. Known values are: \"None\", + \"Enabled\", and \"Disabled\".""" + + @overload + def __init__( + self, + *, + unused_size_ti_b: Optional[int] = None, + increase_capacity_unit_by_ti_b: Optional[int] = None, + capacity_unit_scale_up_limit_ti_b: Optional[int] = None, + auto_scale_policy_enforcement: Optional[Union[str, "_models.AutoScalePolicyEnforcement"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Sku(_Model): + """The SKU name. Required for account creation; optional for update. + + :ivar name: The sku name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". + :vartype name: str or ~azure.mgmt.elasticsan.models.SkuName + :ivar tier: The sku tier. "Premium" + :vartype tier: str or ~azure.mgmt.elasticsan.models.SkuTier + """ + + name: Union[str, "_models.SkuName"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The sku name. Required. Known values are: \"Premium_LRS\" and \"Premium_ZRS\".""" + tier: Optional[Union[str, "_models.SkuTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The sku tier. \"Premium\"""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.SkuName"], + tier: Optional[Union[str, "_models.SkuTier"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SKUCapability(_Model): + """The capability information in the specified SKU. + + :ivar name: The name of capability. + :vartype name: str + :ivar value: A string value to indicate states of given capability. + :vartype value: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of capability.""" + value: Optional[str] = rest_field(visibility=["read"]) + """A string value to indicate states of given capability.""" + + +class SkuInformation(_Model): + """ElasticSAN SKU and its properties. + + :ivar name: Sku Name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". + :vartype name: str or ~azure.mgmt.elasticsan.models.SkuName + :ivar tier: Sku Tier. "Premium" + :vartype tier: str or ~azure.mgmt.elasticsan.models.SkuTier + :ivar resource_type: The type of the resource. + :vartype resource_type: str + :ivar locations: The set of locations that the SKU is available. This will be supported and + registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). + :vartype locations: list[str] + :ivar location_info: Availability of the SKU for the location/zone. + :vartype location_info: list[~azure.mgmt.elasticsan.models.SkuLocationInfo] + :ivar capabilities: The capability information in the specified SKU. + :vartype capabilities: list[~azure.mgmt.elasticsan.models.SKUCapability] + """ + + name: Union[str, "_models.SkuName"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Sku Name. Required. Known values are: \"Premium_LRS\" and \"Premium_ZRS\".""" + tier: Optional[Union[str, "_models.SkuTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sku Tier. \"Premium\"""" + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """The type of the resource.""" + locations: Optional[List[str]] = rest_field(visibility=["read"]) + """The set of locations that the SKU is available. This will be supported and registered Azure Geo + Regions (e.g. West US, East US, Southeast Asia, etc.).""" + location_info: Optional[List["_models.SkuLocationInfo"]] = rest_field(name="locationInfo", visibility=["read"]) + """Availability of the SKU for the location/zone.""" + capabilities: Optional[List["_models.SKUCapability"]] = rest_field(visibility=["read"]) + """The capability information in the specified SKU.""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.SkuName"], + tier: Optional[Union[str, "_models.SkuTier"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuLocationInfo(_Model): + """The location info. + + :ivar location: The location. + :vartype location: str + :ivar zones: The zones. + :vartype zones: list[str] + """ + + location: Optional[str] = rest_field(visibility=["read"]) + """The location.""" + zones: Optional[List[str]] = rest_field(visibility=["read"]) + """The zones.""" + + +class Snapshot(ProxyResource): + """Response for Volume Snapshot request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar properties: Properties of Volume Snapshot. Required. + :vartype properties: ~azure.mgmt.elasticsan.models.SnapshotProperties + """ + + properties: "_models.SnapshotProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Volume Snapshot. Required.""" + + __flattened_items = ["creation_data", "provisioning_state", "source_volume_size_gi_b", "volume_name"] + + @overload + def __init__( + self, + *, + properties: "_models.SnapshotProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SnapshotCreationData(_Model): + """Data used when creating a volume snapshot. + + :ivar source_id: Fully qualified resource ID of the volume. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". + Required. + :vartype source_id: str + """ + + source_id: str = rest_field(name="sourceId", visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified resource ID of the volume. E.g. + \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}\". + Required.""" + + @overload + def __init__( + self, + *, + source_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SnapshotProperties(_Model): + """Properties for Snapshot. + + :ivar creation_data: Data used when creating a volume snapshot. Required. + :vartype creation_data: ~azure.mgmt.elasticsan.models.SnapshotCreationData + :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", + "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", + "Restoring", and "SoftDeleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar source_volume_size_gi_b: Size of Source Volume. + :vartype source_volume_size_gi_b: int + :ivar volume_name: Source Volume Name of a snapshot. + :vartype volume_name: str + """ + + creation_data: "_models.SnapshotCreationData" = rest_field( + name="creationData", visibility=["read", "create", "update", "delete", "query"] + ) + """Data used when creating a volume snapshot. Required.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningStates"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """State of the operation on the resource. Known values are: \"Invalid\", \"Succeeded\", + \"Failed\", \"Canceled\", \"Pending\", \"Creating\", \"Updating\", \"Deleting\", \"Deleted\", + \"Restoring\", and \"SoftDeleting\".""" + source_volume_size_gi_b: Optional[int] = rest_field(name="sourceVolumeSizeGiB", visibility=["read"]) + """Size of Source Volume.""" + volume_name: Optional[str] = rest_field(name="volumeName", visibility=["read"]) + """Source Volume Name of a snapshot.""" + + @overload + def __init__( + self, + *, + creation_data: "_models.SnapshotCreationData", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SourceCreationData(_Model): + """Data source used when creating the volume. + + :ivar create_source: This enumerates the possible sources of a volume creation. Known values + are: "None", "VolumeSnapshot", "DiskSnapshot", "Disk", and "DiskRestorePoint". + :vartype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption + :ivar source_id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype source_id: str + """ + + create_source: Optional[Union[str, "_models.VolumeCreateOption"]] = rest_field( + name="createSource", visibility=["read", "create", "update", "delete", "query"] + ) + """This enumerates the possible sources of a volume creation. Known values are: \"None\", + \"VolumeSnapshot\", \"DiskSnapshot\", \"Disk\", and \"DiskRestorePoint\".""" + source_id: Optional[str] = rest_field(name="sourceId", visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified resource ID for the resource. E.g. + \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}\".""" + + @overload + def __init__( + self, + *, + create_source: Optional[Union[str, "_models.VolumeCreateOption"]] = None, + source_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedIdentity(_Model): + """UserAssignedIdentity for the resource. + + :ivar principal_id: The principal ID of the identity. + :vartype principal_id: str + :ivar client_id: The client ID of the identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of the identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The client ID of the identity.""" + + +class VirtualNetworkRule(_Model): + """Virtual Network rule. + + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. + :vartype virtual_network_resource_id: str + :ivar action: The action of virtual network rule. "Allow" + :vartype action: str or ~azure.mgmt.elasticsan.models.Action + """ + + virtual_network_resource_id: str = rest_field(name="id", visibility=["read", "create", "update", "delete", "query"]) + """Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required.""" + action: Optional[Union[str, "_models.Action"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The action of virtual network rule. \"Allow\"""" + + @overload + def __init__( + self, + *, + virtual_network_resource_id: str, + action: Optional[Union[str, "_models.Action"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Volume(ProxyResource): + """Response for Volume request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar properties: Properties of Volume. Required. + :vartype properties: ~azure.mgmt.elasticsan.models.VolumeProperties + """ + + properties: "_models.VolumeProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Volume. Required.""" + + __flattened_items = [ + "volume_id", + "creation_data", + "size_gi_b", + "storage_target", + "managed_by", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: "_models.VolumeProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VolumeGroup(ProxyResource): + """Response for Volume Group request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.elasticsan.models.Identity + :ivar properties: Properties of VolumeGroup. + :vartype properties: ~azure.mgmt.elasticsan.models.VolumeGroupProperties + """ + + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identity of the resource.""" + properties: Optional["_models.VolumeGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of VolumeGroup.""" + + __flattened_items = [ + "provisioning_state", + "protocol_type", + "encryption", + "encryption_properties", + "network_acls", + "private_endpoint_connections", + "enforce_data_integrity_check_for_iscsi", + "delete_retention_policy", + ] + + @overload + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + properties: Optional["_models.VolumeGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VolumeGroupProperties(_Model): + """VolumeGroup response properties. + + :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", + "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", + "Restoring", and "SoftDeleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar protocol_type: Type of storage target. Known values are: "Iscsi" and "None". + :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :ivar encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey" and + "EncryptionAtRestWithCustomerManagedKey". + :vartype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType + :ivar encryption_properties: Encryption Properties describing Key Vault and Identity + information. + :vartype encryption_properties: ~azure.mgmt.elasticsan.models.EncryptionProperties + :ivar network_acls: A collection of rules governing the accessibility from specific network + locations. + :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + :ivar private_endpoint_connections: The list of Private Endpoint Connections. + :vartype private_endpoint_connections: + list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] + :ivar enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data + Integrity Check is enabled. + :vartype enforce_data_integrity_check_for_iscsi: bool + :ivar delete_retention_policy: The retention policy for the soft deleted volume group and its + associated resources. + :vartype delete_retention_policy: ~azure.mgmt.elasticsan.models.DeleteRetentionPolicy + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningStates"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """State of the operation on the resource. Known values are: \"Invalid\", \"Succeeded\", + \"Failed\", \"Canceled\", \"Pending\", \"Creating\", \"Updating\", \"Deleting\", \"Deleted\", + \"Restoring\", and \"SoftDeleting\".""" + protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = rest_field( + name="protocolType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of storage target. Known values are: \"Iscsi\" and \"None\".""" + encryption: Optional[Union[str, "_models.EncryptionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of encryption. Known values are: \"EncryptionAtRestWithPlatformKey\" and + \"EncryptionAtRestWithCustomerManagedKey\".""" + encryption_properties: Optional["_models.EncryptionProperties"] = rest_field( + name="encryptionProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Encryption Properties describing Key Vault and Identity information.""" + network_acls: Optional["_models.NetworkRuleSet"] = rest_field(name="networkAcls", visibility=["read", "create"]) + """A collection of rules governing the accessibility from specific network locations.""" + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """The list of Private Endpoint Connections.""" + enforce_data_integrity_check_for_iscsi: Optional[bool] = rest_field( + name="enforceDataIntegrityCheckForIscsi", visibility=["read", "create", "update", "delete", "query"] + ) + """A boolean indicating whether or not Data Integrity Check is enabled.""" + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = rest_field( + name="deleteRetentionPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The retention policy for the soft deleted volume group and its associated resources.""" + + @overload + def __init__( + self, + *, + protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = None, + encryption: Optional[Union[str, "_models.EncryptionType"]] = None, + encryption_properties: Optional["_models.EncryptionProperties"] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + enforce_data_integrity_check_for_iscsi: Optional[bool] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VolumeGroupUpdate(_Model): + """Volume Group request. + + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.elasticsan.models.Identity + :ivar properties: Properties of VolumeGroup. + :vartype properties: ~azure.mgmt.elasticsan.models.VolumeGroupUpdateProperties + """ + + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identity of the resource.""" + properties: Optional["_models.VolumeGroupUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of VolumeGroup.""" + + __flattened_items = [ + "protocol_type", + "encryption", + "encryption_properties", + "network_acls", + "enforce_data_integrity_check_for_iscsi", + "delete_retention_policy", + ] + + @overload + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + properties: Optional["_models.VolumeGroupUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VolumeGroupUpdateProperties(_Model): + """VolumeGroup response properties. + + :ivar protocol_type: Type of storage target. Known values are: "Iscsi" and "None". + :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :ivar encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey" and + "EncryptionAtRestWithCustomerManagedKey". + :vartype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType + :ivar encryption_properties: Encryption Properties describing Key Vault and Identity + information. + :vartype encryption_properties: ~azure.mgmt.elasticsan.models.EncryptionProperties + :ivar network_acls: A collection of rules governing the accessibility from specific network + locations. + :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + :ivar enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data + Integrity Check is enabled. + :vartype enforce_data_integrity_check_for_iscsi: bool + :ivar delete_retention_policy: The retention policy for the soft deleted volume group and its + associated resources. + :vartype delete_retention_policy: ~azure.mgmt.elasticsan.models.DeleteRetentionPolicy + """ + + protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = rest_field( + name="protocolType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of storage target. Known values are: \"Iscsi\" and \"None\".""" + encryption: Optional[Union[str, "_models.EncryptionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of encryption. Known values are: \"EncryptionAtRestWithPlatformKey\" and + \"EncryptionAtRestWithCustomerManagedKey\".""" + encryption_properties: Optional["_models.EncryptionProperties"] = rest_field( + name="encryptionProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Encryption Properties describing Key Vault and Identity information.""" + network_acls: Optional["_models.NetworkRuleSet"] = rest_field(name="networkAcls", visibility=["update"]) + """A collection of rules governing the accessibility from specific network locations.""" + enforce_data_integrity_check_for_iscsi: Optional[bool] = rest_field( + name="enforceDataIntegrityCheckForIscsi", visibility=["read", "create", "update", "delete", "query"] + ) + """A boolean indicating whether or not Data Integrity Check is enabled.""" + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = rest_field( + name="deleteRetentionPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The retention policy for the soft deleted volume group and its associated resources.""" + + @overload + def __init__( + self, + *, + protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = None, + encryption: Optional[Union[str, "_models.EncryptionType"]] = None, + encryption_properties: Optional["_models.EncryptionProperties"] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + enforce_data_integrity_check_for_iscsi: Optional[bool] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VolumeNameList(_Model): + """object to hold array of volume names. + + :ivar volume_names: array of volume names. Required. + :vartype volume_names: list[str] + """ + + volume_names: List[str] = rest_field(name="volumeNames", visibility=["read", "create", "update", "delete", "query"]) + """array of volume names. Required.""" + + @overload + def __init__( + self, + *, + volume_names: List[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VolumeProperties(_Model): + """Volume response properties. + + :ivar volume_id: Unique Id of the volume in GUID format. + :vartype volume_id: str + :ivar creation_data: State of the operation on the resource. + :vartype creation_data: ~azure.mgmt.elasticsan.models.SourceCreationData + :ivar size_gi_b: Volume size. Required. + :vartype size_gi_b: int + :ivar storage_target: Storage target information. + :vartype storage_target: ~azure.mgmt.elasticsan.models.IscsiTargetInfo + :ivar managed_by: Parent resource information. + :vartype managed_by: ~azure.mgmt.elasticsan.models.ManagedByInfo + :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", + "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", + "Restoring", and "SoftDeleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + """ + + volume_id: Optional[str] = rest_field(name="volumeId", visibility=["read"]) + """Unique Id of the volume in GUID format.""" + creation_data: Optional["_models.SourceCreationData"] = rest_field( + name="creationData", visibility=["read", "create", "update", "delete", "query"] + ) + """State of the operation on the resource.""" + size_gi_b: int = rest_field(name="sizeGiB", visibility=["read", "create", "update", "delete", "query"]) + """Volume size. Required.""" + storage_target: Optional["_models.IscsiTargetInfo"] = rest_field( + name="storageTarget", visibility=["read", "create", "update", "delete", "query"] + ) + """Storage target information.""" + managed_by: Optional["_models.ManagedByInfo"] = rest_field( + name="managedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """Parent resource information.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningStates"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """State of the operation on the resource. Known values are: \"Invalid\", \"Succeeded\", + \"Failed\", \"Canceled\", \"Pending\", \"Creating\", \"Updating\", \"Deleting\", \"Deleted\", + \"Restoring\", and \"SoftDeleting\".""" + + @overload + def __init__( + self, + *, + size_gi_b: int, + creation_data: Optional["_models.SourceCreationData"] = None, + storage_target: Optional["_models.IscsiTargetInfo"] = None, + managed_by: Optional["_models.ManagedByInfo"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VolumeUpdate(_Model): + """Response for Volume request. + + :ivar properties: Properties of Volume. + :vartype properties: ~azure.mgmt.elasticsan.models.VolumeUpdateProperties + """ + + properties: Optional["_models.VolumeUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Volume.""" + + __flattened_items = ["size_gi_b", "managed_by"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VolumeUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VolumeUpdateProperties(_Model): + """Volume response properties. + + :ivar size_gi_b: Volume size. + :vartype size_gi_b: int + :ivar managed_by: Parent resource information. + :vartype managed_by: ~azure.mgmt.elasticsan.models.ManagedByInfo + """ + + size_gi_b: Optional[int] = rest_field(name="sizeGiB", visibility=["read", "create", "update", "delete", "query"]) + """Volume size.""" + managed_by: Optional["_models.ManagedByInfo"] = rest_field( + name="managedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """Parent resource information.""" + + @overload + def __init__( + self, + *, + size_gi_b: Optional[int] = None, + managed_by: Optional["_models.ManagedByInfo"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py deleted file mode 100644 index 42ae42808191..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py +++ /dev/null @@ -1,2364 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .. import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AutoScaleProperties(_serialization.Model): - """The auto scale settings on Elastic San Appliance. - - :ivar scale_up_properties: Scale up settings on Elastic San Appliance. - :vartype scale_up_properties: ~azure.mgmt.elasticsan.models.ScaleUpProperties - """ - - _attribute_map = { - "scale_up_properties": {"key": "scaleUpProperties", "type": "ScaleUpProperties"}, - } - - def __init__(self, *, scale_up_properties: Optional["_models.ScaleUpProperties"] = None, **kwargs: Any) -> None: - """ - :keyword scale_up_properties: Scale up settings on Elastic San Appliance. - :paramtype scale_up_properties: ~azure.mgmt.elasticsan.models.ScaleUpProperties - """ - super().__init__(**kwargs) - self.scale_up_properties = scale_up_properties - - -class DeleteRetentionPolicy(_serialization.Model): - """Response for Delete Retention Policy object. - - :ivar policy_state: Known values are: "Enabled" and "Disabled". - :vartype policy_state: str or ~azure.mgmt.elasticsan.models.PolicyState - :ivar retention_period_days: The number of days to retain the resources after deletion. - :vartype retention_period_days: int - """ - - _validation = { - "retention_period_days": {"minimum": 0}, - } - - _attribute_map = { - "policy_state": {"key": "policyState", "type": "str"}, - "retention_period_days": {"key": "retentionPeriodDays", "type": "int"}, - } - - def __init__( - self, - *, - policy_state: Optional[Union[str, "_models.PolicyState"]] = None, - retention_period_days: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword policy_state: Known values are: "Enabled" and "Disabled". - :paramtype policy_state: str or ~azure.mgmt.elasticsan.models.PolicyState - :keyword retention_period_days: The number of days to retain the resources after deletion. - :paramtype retention_period_days: int - """ - super().__init__(**kwargs) - self.policy_state = policy_state - self.retention_period_days = retention_period_days - - -class DiskSnapshotList(_serialization.Model): - """object to hold array of Disk Snapshot ARM IDs. - - All required parameters must be populated in order to send to server. - - :ivar disk_snapshot_ids: array of DiskSnapshot ARM IDs. Required. - :vartype disk_snapshot_ids: list[str] - """ - - _validation = { - "disk_snapshot_ids": {"required": True}, - } - - _attribute_map = { - "disk_snapshot_ids": {"key": "diskSnapshotIds", "type": "[str]"}, - } - - def __init__(self, *, disk_snapshot_ids: List[str], **kwargs: Any) -> None: - """ - :keyword disk_snapshot_ids: array of DiskSnapshot ARM IDs. Required. - :paramtype disk_snapshot_ids: list[str] - """ - super().__init__(**kwargs) - self.disk_snapshot_ids = disk_snapshot_ids - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class ElasticSan(TrackedResource): - """Response for ElasticSan request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar properties: Properties of ElasticSan. Required. - :vartype properties: ~azure.mgmt.elasticsan.models.ElasticSanProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "ElasticSanProperties"}, - } - - def __init__( - self, - *, - location: str, - properties: "_models.ElasticSanProperties", - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword properties: Properties of ElasticSan. Required. - :paramtype properties: ~azure.mgmt.elasticsan.models.ElasticSanProperties - """ - super().__init__(tags=tags, location=location, **kwargs) - self.properties = properties - - -class ElasticSanList(_serialization.Model): - """List of Elastic Sans. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of Elastic San objects. - :vartype value: list[~azure.mgmt.elasticsan.models.ElasticSan] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticSan]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.ElasticSan"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of Elastic San objects. - :paramtype value: list[~azure.mgmt.elasticsan.models.ElasticSan] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ElasticSanProperties(_serialization.Model): - """Elastic San response properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar sku: resource sku. Required. - :vartype sku: ~azure.mgmt.elasticsan.models.Sku - :ivar availability_zones: Logical zone for Elastic San resource; example: ["1"]. - :vartype availability_zones: list[str] - :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", - "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", - "Restoring", and "SoftDeleting". - :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates - :ivar base_size_ti_b: Base size of the Elastic San appliance in TiB. Required. - :vartype base_size_ti_b: int - :ivar extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. Required. - :vartype extended_capacity_size_ti_b: int - :ivar total_volume_size_gi_b: Total size of the provisioned Volumes in GiB. - :vartype total_volume_size_gi_b: int - :ivar volume_group_count: Total number of volume groups in this Elastic San appliance. - :vartype volume_group_count: int - :ivar total_iops: Total Provisioned IOPS of the Elastic San appliance. - :vartype total_iops: int - :ivar total_m_bps: Total Provisioned MBps Elastic San appliance. - :vartype total_m_bps: int - :ivar total_size_ti_b: Total size of the Elastic San appliance in TB. - :vartype total_size_ti_b: int - :ivar private_endpoint_connections: The list of Private Endpoint Connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :ivar public_network_access: Allow or disallow public network access to ElasticSan. Value is - optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and - "Disabled". - :vartype public_network_access: str or ~azure.mgmt.elasticsan.models.PublicNetworkAccess - :ivar auto_scale_properties: Auto Scale Properties for Elastic San Appliance. - :vartype auto_scale_properties: ~azure.mgmt.elasticsan.models.AutoScaleProperties - """ - - _validation = { - "sku": {"required": True}, - "provisioning_state": {"readonly": True}, - "base_size_ti_b": {"required": True}, - "extended_capacity_size_ti_b": {"required": True}, - "total_volume_size_gi_b": {"readonly": True}, - "volume_group_count": {"readonly": True}, - "total_iops": {"readonly": True}, - "total_m_bps": {"readonly": True}, - "total_size_ti_b": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - } - - _attribute_map = { - "sku": {"key": "sku", "type": "Sku"}, - "availability_zones": {"key": "availabilityZones", "type": "[str]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "base_size_ti_b": {"key": "baseSizeTiB", "type": "int"}, - "extended_capacity_size_ti_b": {"key": "extendedCapacitySizeTiB", "type": "int"}, - "total_volume_size_gi_b": {"key": "totalVolumeSizeGiB", "type": "int"}, - "volume_group_count": {"key": "volumeGroupCount", "type": "int"}, - "total_iops": {"key": "totalIops", "type": "int"}, - "total_m_bps": {"key": "totalMBps", "type": "int"}, - "total_size_ti_b": {"key": "totalSizeTiB", "type": "int"}, - "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - "auto_scale_properties": {"key": "autoScaleProperties", "type": "AutoScaleProperties"}, - } - - def __init__( - self, - *, - sku: "_models.Sku", - base_size_ti_b: int, - extended_capacity_size_ti_b: int, - availability_zones: Optional[List[str]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - auto_scale_properties: Optional["_models.AutoScaleProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: resource sku. Required. - :paramtype sku: ~azure.mgmt.elasticsan.models.Sku - :keyword availability_zones: Logical zone for Elastic San resource; example: ["1"]. - :paramtype availability_zones: list[str] - :keyword base_size_ti_b: Base size of the Elastic San appliance in TiB. Required. - :paramtype base_size_ti_b: int - :keyword extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. - Required. - :paramtype extended_capacity_size_ti_b: int - :keyword public_network_access: Allow or disallow public network access to ElasticSan. Value is - optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and - "Disabled". - :paramtype public_network_access: str or ~azure.mgmt.elasticsan.models.PublicNetworkAccess - :keyword auto_scale_properties: Auto Scale Properties for Elastic San Appliance. - :paramtype auto_scale_properties: ~azure.mgmt.elasticsan.models.AutoScaleProperties - """ - super().__init__(**kwargs) - self.sku = sku - self.availability_zones = availability_zones - self.provisioning_state = None - self.base_size_ti_b = base_size_ti_b - self.extended_capacity_size_ti_b = extended_capacity_size_ti_b - self.total_volume_size_gi_b = None - self.volume_group_count = None - self.total_iops = None - self.total_m_bps = None - self.total_size_ti_b = None - self.private_endpoint_connections = None - self.public_network_access = public_network_access - self.auto_scale_properties = auto_scale_properties - - -class ElasticSanUpdate(_serialization.Model): - """Response for ElasticSan update request. - - :ivar properties: Properties of ElasticSan. - :vartype properties: ~azure.mgmt.elasticsan.models.ElasticSanUpdateProperties - :ivar tags: Update tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "ElasticSanUpdateProperties"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - properties: Optional["_models.ElasticSanUpdateProperties"] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword properties: Properties of ElasticSan. - :paramtype properties: ~azure.mgmt.elasticsan.models.ElasticSanUpdateProperties - :keyword tags: Update tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.properties = properties - self.tags = tags - - -class ElasticSanUpdateProperties(_serialization.Model): - """Elastic San update properties. - - :ivar base_size_ti_b: Base size of the Elastic San appliance in TiB. - :vartype base_size_ti_b: int - :ivar extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. - :vartype extended_capacity_size_ti_b: int - :ivar public_network_access: Allow or disallow public network access to ElasticSan Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or ~azure.mgmt.elasticsan.models.PublicNetworkAccess - :ivar auto_scale_properties: Auto Scale Properties for Elastic San Appliance. - :vartype auto_scale_properties: ~azure.mgmt.elasticsan.models.AutoScaleProperties - """ - - _attribute_map = { - "base_size_ti_b": {"key": "baseSizeTiB", "type": "int"}, - "extended_capacity_size_ti_b": {"key": "extendedCapacitySizeTiB", "type": "int"}, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - "auto_scale_properties": {"key": "autoScaleProperties", "type": "AutoScaleProperties"}, - } - - def __init__( - self, - *, - base_size_ti_b: Optional[int] = None, - extended_capacity_size_ti_b: Optional[int] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - auto_scale_properties: Optional["_models.AutoScaleProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword base_size_ti_b: Base size of the Elastic San appliance in TiB. - :paramtype base_size_ti_b: int - :keyword extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. - :paramtype extended_capacity_size_ti_b: int - :keyword public_network_access: Allow or disallow public network access to ElasticSan Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or ~azure.mgmt.elasticsan.models.PublicNetworkAccess - :keyword auto_scale_properties: Auto Scale Properties for Elastic San Appliance. - :paramtype auto_scale_properties: ~azure.mgmt.elasticsan.models.AutoScaleProperties - """ - super().__init__(**kwargs) - self.base_size_ti_b = base_size_ti_b - self.extended_capacity_size_ti_b = extended_capacity_size_ti_b - self.public_network_access = public_network_access - self.auto_scale_properties = auto_scale_properties - - -class EncryptionIdentity(_serialization.Model): - """Encryption identity for the volume group. - - :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be - associated with server-side encryption on the volume group. - :vartype encryption_user_assigned_identity: str - """ - - _attribute_map = { - "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, - } - - def __init__(self, *, encryption_user_assigned_identity: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to - be associated with server-side encryption on the volume group. - :paramtype encryption_user_assigned_identity: str - """ - super().__init__(**kwargs) - self.encryption_user_assigned_identity = encryption_user_assigned_identity - - -class EncryptionProperties(_serialization.Model): - """The encryption settings on the volume group. - - :ivar key_vault_properties: Properties provided by key vault. - :vartype key_vault_properties: ~azure.mgmt.elasticsan.models.KeyVaultProperties - :ivar encryption_identity: The identity to be used with service-side encryption at rest. - :vartype encryption_identity: ~azure.mgmt.elasticsan.models.EncryptionIdentity - """ - - _attribute_map = { - "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, - "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, - } - - def __init__( - self, - *, - key_vault_properties: Optional["_models.KeyVaultProperties"] = None, - encryption_identity: Optional["_models.EncryptionIdentity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword key_vault_properties: Properties provided by key vault. - :paramtype key_vault_properties: ~azure.mgmt.elasticsan.models.KeyVaultProperties - :keyword encryption_identity: The identity to be used with service-side encryption at rest. - :paramtype encryption_identity: ~azure.mgmt.elasticsan.models.EncryptionIdentity - """ - super().__init__(**kwargs) - self.key_vault_properties = key_vault_properties - self.encryption_identity = encryption_identity - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.elasticsan.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.elasticsan.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.elasticsan.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.elasticsan.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Identity(_serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", and - "UserAssigned". - :vartype type: str or ~azure.mgmt.elasticsan.models.IdentityType - :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of - User Assigned identities that will be used with this volume group. The key is the ARM resource - identifier of the identity. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.elasticsan.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.IdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", and - "UserAssigned". - :paramtype type: str or ~azure.mgmt.elasticsan.models.IdentityType - :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set - of User Assigned identities that will be used with this volume group. The key is the ARM - resource identifier of the identity. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.elasticsan.models.UserAssignedIdentity] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class IscsiTargetInfo(_serialization.Model): - """Iscsi target information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_iqn: iSCSI Target IQN (iSCSI Qualified Name); example: - "iqn.2005-03.org.iscsi:server". - :vartype target_iqn: str - :ivar target_portal_hostname: iSCSI Target Portal Host Name. - :vartype target_portal_hostname: str - :ivar target_portal_port: iSCSI Target Portal Port. - :vartype target_portal_port: int - :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", - "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", - "Restoring", and "SoftDeleting". - :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates - :ivar status: Operational status of the iSCSI Target. Known values are: "Invalid", "Unknown", - "Healthy", "Unhealthy", "Updating", "Running", "Stopped", and "Stopped (deallocated)". - :vartype status: str or ~azure.mgmt.elasticsan.models.OperationalStatus - """ - - _validation = { - "target_iqn": {"readonly": True}, - "target_portal_hostname": {"readonly": True}, - "target_portal_port": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "target_iqn": {"key": "targetIqn", "type": "str"}, - "target_portal_hostname": {"key": "targetPortalHostname", "type": "str"}, - "target_portal_port": {"key": "targetPortalPort", "type": "int"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.OperationalStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword status: Operational status of the iSCSI Target. Known values are: "Invalid", - "Unknown", "Healthy", "Unhealthy", "Updating", "Running", "Stopped", and "Stopped - (deallocated)". - :paramtype status: str or ~azure.mgmt.elasticsan.models.OperationalStatus - """ - super().__init__(**kwargs) - self.target_iqn = None - self.target_portal_hostname = None - self.target_portal_port = None - self.provisioning_state = None - self.status = status - - -class KeyVaultProperties(_serialization.Model): - """Properties of key vault. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar key_name: The name of KeyVault key. - :vartype key_name: str - :ivar key_version: The version of KeyVault key. - :vartype key_version: str - :ivar key_vault_uri: The Uri of KeyVault. - :vartype key_vault_uri: str - :ivar current_versioned_key_identifier: The object identifier of the current versioned Key - Vault Key in use. - :vartype current_versioned_key_identifier: str - :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. - :vartype last_key_rotation_timestamp: ~datetime.datetime - :ivar current_versioned_key_expiration_timestamp: This is a read only property that represents - the expiration time of the current version of the customer managed key used for encryption. - :vartype current_versioned_key_expiration_timestamp: ~datetime.datetime - """ - - _validation = { - "current_versioned_key_identifier": {"readonly": True}, - "last_key_rotation_timestamp": {"readonly": True}, - "current_versioned_key_expiration_timestamp": {"readonly": True}, - } - - _attribute_map = { - "key_name": {"key": "keyName", "type": "str"}, - "key_version": {"key": "keyVersion", "type": "str"}, - "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, - "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, - "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, - "current_versioned_key_expiration_timestamp": { - "key": "currentVersionedKeyExpirationTimestamp", - "type": "iso-8601", - }, - } - - def __init__( - self, - *, - key_name: Optional[str] = None, - key_version: Optional[str] = None, - key_vault_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword key_name: The name of KeyVault key. - :paramtype key_name: str - :keyword key_version: The version of KeyVault key. - :paramtype key_version: str - :keyword key_vault_uri: The Uri of KeyVault. - :paramtype key_vault_uri: str - """ - super().__init__(**kwargs) - self.key_name = key_name - self.key_version = key_version - self.key_vault_uri = key_vault_uri - self.current_versioned_key_identifier = None - self.last_key_rotation_timestamp = None - self.current_versioned_key_expiration_timestamp = None - - -class ManagedByInfo(_serialization.Model): - """Parent resource information. - - :ivar resource_id: Resource ID of the resource managing the volume, this is a restricted field - and can only be set for internal use. - :vartype resource_id: str - """ - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - } - - def __init__(self, *, resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword resource_id: Resource ID of the resource managing the volume, this is a restricted - field and can only be set for internal use. - :paramtype resource_id: str - """ - super().__init__(**kwargs) - self.resource_id = resource_id - - -class NetworkRuleSet(_serialization.Model): - """A set of rules governing the network accessibility. - - :ivar virtual_network_rules: The list of virtual network rules. - :vartype virtual_network_rules: list[~azure.mgmt.elasticsan.models.VirtualNetworkRule] - """ - - _attribute_map = { - "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, - } - - def __init__( - self, *, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, **kwargs: Any - ) -> None: - """ - :keyword virtual_network_rules: The list of virtual network rules. - :paramtype virtual_network_rules: list[~azure.mgmt.elasticsan.models.VirtualNetworkRule] - """ - super().__init__(**kwargs) - self.virtual_network_rules = virtual_network_rules - - -class Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.elasticsan.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.elasticsan.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.elasticsan.models.ActionType - """ - - _validation = { - "name": {"readonly": True}, - "is_data_action": {"readonly": True}, - "origin": {"readonly": True}, - "action_type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "action_type": {"key": "actionType", "type": "str"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.elasticsan.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = display - self.origin = None - self.action_type = None - - -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.elasticsan.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class PreValidationResponse(_serialization.Model): - """response object for pre validation api. - - :ivar validation_status: a status value indicating success or failure of validation. - :vartype validation_status: str - """ - - _attribute_map = { - "validation_status": {"key": "validationStatus", "type": "str"}, - } - - def __init__(self, *, validation_status: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword validation_status: a status value indicating success or failure of validation. - :paramtype validation_status: str - """ - super().__init__(**kwargs) - self.validation_status = validation_status - - -class PrivateEndpoint(_serialization.Model): - """Response for PrivateEndpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(Resource): - """Response for PrivateEndpoint Connection object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar properties: Private Endpoint Connection Properties. Required. - :vartype properties: ~azure.mgmt.elasticsan.models.PrivateEndpointConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": 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": "PrivateEndpointConnectionProperties"}, - } - - def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs: Any) -> None: - """ - :keyword properties: Private Endpoint Connection Properties. Required. - :paramtype properties: ~azure.mgmt.elasticsan.models.PrivateEndpointConnectionProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """List of private endpoint connections associated with SAN. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of private endpoint connections. - :vartype value: list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private endpoint connections. - :paramtype value: list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class PrivateEndpointConnectionProperties(_serialization.Model): - """Response for PrivateEndpoint connection properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar provisioning_state: Provisioning State of Private Endpoint connection resource. Known - values are: "Invalid", "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", - "Deleting", "Deleted", "Restoring", and "SoftDeleting". - :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates - :ivar private_endpoint: Private Endpoint resource. - :vartype private_endpoint: ~azure.mgmt.elasticsan.models.PrivateEndpoint - :ivar private_link_service_connection_state: Private Link Service Connection State. Required. - :vartype private_link_service_connection_state: - ~azure.mgmt.elasticsan.models.PrivateLinkServiceConnectionState - :ivar group_ids: List of resources private endpoint is mapped. - :vartype group_ids: list[str] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "private_link_service_connection_state": {"required": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "group_ids": {"key": "groupIds", "type": "[str]"}, - } - - def __init__( - self, - *, - private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - group_ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private Endpoint resource. - :paramtype private_endpoint: ~azure.mgmt.elasticsan.models.PrivateEndpoint - :keyword private_link_service_connection_state: Private Link Service Connection State. - Required. - :paramtype private_link_service_connection_state: - ~azure.mgmt.elasticsan.models.PrivateLinkServiceConnectionState - :keyword group_ids: List of resources private endpoint is mapped. - :paramtype group_ids: list[str] - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.group_ids = group_ids - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar properties: Resource properties. - :vartype properties: ~azure.mgmt.elasticsan.models.PrivateLinkResourceProperties - """ - - _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": "PrivateLinkResourceProperties"}, - } - - def __init__(self, *, properties: Optional["_models.PrivateLinkResourceProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Resource properties. - :paramtype properties: ~azure.mgmt.elasticsan.models.PrivateLinkResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.elasticsan.models.PrivateLinkResource] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.elasticsan.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class PrivateLinkResourceProperties(_serialization.Model): - """Properties of a private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource Private link DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource Private link DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = required_zone_names - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """Response for Private Link Service Connection state. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Failed", and "Rejected". - :vartype status: str or ~azure.mgmt.elasticsan.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Failed", and "Rejected". - :paramtype status: str or ~azure.mgmt.elasticsan.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - """ - - -class ScaleUpProperties(_serialization.Model): - """Scale up properties on Elastic San Appliance. - - :ivar unused_size_ti_b: Unused size on Elastic San appliance in TiB. - :vartype unused_size_ti_b: int - :ivar increase_capacity_unit_by_ti_b: Unit to increase Capacity Unit on Elastic San appliance - in TiB. - :vartype increase_capacity_unit_by_ti_b: int - :ivar capacity_unit_scale_up_limit_ti_b: Maximum scale up size on Elastic San appliance in TiB. - :vartype capacity_unit_scale_up_limit_ti_b: int - :ivar auto_scale_policy_enforcement: Enable or Disable scale up setting on Elastic San - Appliance. Known values are: "None", "Enabled", and "Disabled". - :vartype auto_scale_policy_enforcement: str or - ~azure.mgmt.elasticsan.models.AutoScalePolicyEnforcement - """ - - _attribute_map = { - "unused_size_ti_b": {"key": "unusedSizeTiB", "type": "int"}, - "increase_capacity_unit_by_ti_b": {"key": "increaseCapacityUnitByTiB", "type": "int"}, - "capacity_unit_scale_up_limit_ti_b": {"key": "capacityUnitScaleUpLimitTiB", "type": "int"}, - "auto_scale_policy_enforcement": {"key": "autoScalePolicyEnforcement", "type": "str"}, - } - - def __init__( - self, - *, - unused_size_ti_b: Optional[int] = None, - increase_capacity_unit_by_ti_b: Optional[int] = None, - capacity_unit_scale_up_limit_ti_b: Optional[int] = None, - auto_scale_policy_enforcement: Optional[Union[str, "_models.AutoScalePolicyEnforcement"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword unused_size_ti_b: Unused size on Elastic San appliance in TiB. - :paramtype unused_size_ti_b: int - :keyword increase_capacity_unit_by_ti_b: Unit to increase Capacity Unit on Elastic San - appliance in TiB. - :paramtype increase_capacity_unit_by_ti_b: int - :keyword capacity_unit_scale_up_limit_ti_b: Maximum scale up size on Elastic San appliance in - TiB. - :paramtype capacity_unit_scale_up_limit_ti_b: int - :keyword auto_scale_policy_enforcement: Enable or Disable scale up setting on Elastic San - Appliance. Known values are: "None", "Enabled", and "Disabled". - :paramtype auto_scale_policy_enforcement: str or - ~azure.mgmt.elasticsan.models.AutoScalePolicyEnforcement - """ - super().__init__(**kwargs) - self.unused_size_ti_b = unused_size_ti_b - self.increase_capacity_unit_by_ti_b = increase_capacity_unit_by_ti_b - self.capacity_unit_scale_up_limit_ti_b = capacity_unit_scale_up_limit_ti_b - self.auto_scale_policy_enforcement = auto_scale_policy_enforcement - - -class Sku(_serialization.Model): - """The SKU name. Required for account creation; optional for update. - - All required parameters must be populated in order to send to server. - - :ivar name: The sku name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". - :vartype name: str or ~azure.mgmt.elasticsan.models.SkuName - :ivar tier: The sku tier. "Premium" - :vartype tier: str or ~azure.mgmt.elasticsan.models.SkuTier - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - tier: Optional[Union[str, "_models.SkuTier"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". - :paramtype name: str or ~azure.mgmt.elasticsan.models.SkuName - :keyword tier: The sku tier. "Premium" - :paramtype tier: str or ~azure.mgmt.elasticsan.models.SkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - - -class SKUCapability(_serialization.Model): - """The capability information in the specified SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of capability. - :vartype name: str - :ivar value: A string value to indicate states of given capability. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.value = None - - -class SkuInformation(_serialization.Model): - """ElasticSAN SKU and its properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar name: Sku Name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". - :vartype name: str or ~azure.mgmt.elasticsan.models.SkuName - :ivar tier: Sku Tier. "Premium" - :vartype tier: str or ~azure.mgmt.elasticsan.models.SkuTier - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar locations: The set of locations that the SKU is available. This will be supported and - registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). - :vartype locations: list[str] - :ivar location_info: Availability of the SKU for the location/zone. - :vartype location_info: list[~azure.mgmt.elasticsan.models.SkuLocationInfo] - :ivar capabilities: The capability information in the specified SKU. - :vartype capabilities: list[~azure.mgmt.elasticsan.models.SKUCapability] - """ - - _validation = { - "name": {"required": True}, - "resource_type": {"readonly": True}, - "locations": {"readonly": True}, - "location_info": {"readonly": True}, - "capabilities": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "resource_type": {"key": "resourceType", "type": "str"}, - "locations": {"key": "locations", "type": "[str]"}, - "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, - "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, - } - - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - tier: Optional[Union[str, "_models.SkuTier"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Sku Name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". - :paramtype name: str or ~azure.mgmt.elasticsan.models.SkuName - :keyword tier: Sku Tier. "Premium" - :paramtype tier: str or ~azure.mgmt.elasticsan.models.SkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.resource_type = None - self.locations = None - self.location_info = None - self.capabilities = None - - -class SkuInformationList(_serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.elasticsan.models.SkuInformation] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SkuInformation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(_serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - """ - - _validation = { - "location": {"readonly": True}, - "zones": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location = None - self.zones = None - - -class Snapshot(ProxyResource): - """Response for Volume Snapshot request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar properties: Properties of Volume Snapshot. Required. - :vartype properties: ~azure.mgmt.elasticsan.models.SnapshotProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": 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": "SnapshotProperties"}, - } - - def __init__(self, *, properties: "_models.SnapshotProperties", **kwargs: Any) -> None: - """ - :keyword properties: Properties of Volume Snapshot. Required. - :paramtype properties: ~azure.mgmt.elasticsan.models.SnapshotProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class SnapshotCreationData(_serialization.Model): - """Data used when creating a volume snapshot. - - All required parameters must be populated in order to send to server. - - :ivar source_id: Fully qualified resource ID of the volume. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". # pylint: disable=line-too-long - Required. - :vartype source_id: str - """ - - _validation = { - "source_id": {"required": True}, - } - - _attribute_map = { - "source_id": {"key": "sourceId", "type": "str"}, - } - - def __init__(self, *, source_id: str, **kwargs: Any) -> None: - """ - :keyword source_id: Fully qualified resource ID of the volume. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". # pylint: disable=line-too-long - Required. - :paramtype source_id: str - """ - super().__init__(**kwargs) - self.source_id = source_id - - -class SnapshotList(_serialization.Model): - """List of Snapshots. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of Snapshot objects. - :vartype value: list[~azure.mgmt.elasticsan.models.Snapshot] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Snapshot"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of Snapshot objects. - :paramtype value: list[~azure.mgmt.elasticsan.models.Snapshot] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class SnapshotProperties(_serialization.Model): - """Properties for Snapshot. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar creation_data: Data used when creating a volume snapshot. Required. - :vartype creation_data: ~azure.mgmt.elasticsan.models.SnapshotCreationData - :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", - "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", - "Restoring", and "SoftDeleting". - :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates - :ivar source_volume_size_gi_b: Size of Source Volume. - :vartype source_volume_size_gi_b: int - :ivar volume_name: Source Volume Name of a snapshot. - :vartype volume_name: str - """ - - _validation = { - "creation_data": {"required": True}, - "provisioning_state": {"readonly": True}, - "source_volume_size_gi_b": {"readonly": True}, - "volume_name": {"readonly": True}, - } - - _attribute_map = { - "creation_data": {"key": "creationData", "type": "SnapshotCreationData"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "source_volume_size_gi_b": {"key": "sourceVolumeSizeGiB", "type": "int"}, - "volume_name": {"key": "volumeName", "type": "str"}, - } - - def __init__(self, *, creation_data: "_models.SnapshotCreationData", **kwargs: Any) -> None: - """ - :keyword creation_data: Data used when creating a volume snapshot. Required. - :paramtype creation_data: ~azure.mgmt.elasticsan.models.SnapshotCreationData - """ - super().__init__(**kwargs) - self.creation_data = creation_data - self.provisioning_state = None - self.source_volume_size_gi_b = None - self.volume_name = None - - -class SourceCreationData(_serialization.Model): - """Data source used when creating the volume. - - :ivar create_source: This enumerates the possible sources of a volume creation. Known values - are: "None", "VolumeSnapshot", "DiskSnapshot", "Disk", and "DiskRestorePoint". - :vartype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption - :ivar source_id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype source_id: str - """ - - _attribute_map = { - "create_source": {"key": "createSource", "type": "str"}, - "source_id": {"key": "sourceId", "type": "str"}, - } - - def __init__( - self, - *, - create_source: Optional[Union[str, "_models.VolumeCreateOption"]] = None, - source_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_source: This enumerates the possible sources of a volume creation. Known values - are: "None", "VolumeSnapshot", "DiskSnapshot", "Disk", and "DiskRestorePoint". - :paramtype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption - :keyword source_id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :paramtype source_id: str - """ - super().__init__(**kwargs) - self.create_source = create_source - self.source_id = source_id - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class UserAssignedIdentity(_serialization.Model): - """UserAssignedIdentity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of the identity. - :vartype principal_id: str - :ivar client_id: The client ID of the identity. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class VirtualNetworkRule(_serialization.Model): - """Virtual Network rule. - - All required parameters must be populated in order to send to server. - - :ivar virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. "Allow" - :vartype action: str or ~azure.mgmt.elasticsan.models.Action - """ - - _validation = { - "virtual_network_resource_id": {"required": True}, - } - - _attribute_map = { - "virtual_network_resource_id": {"key": "id", "type": "str"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, *, virtual_network_resource_id: str, action: Union[str, "_models.Action"] = "Allow", **kwargs: Any - ) -> None: - """ - :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. "Allow" - :paramtype action: str or ~azure.mgmt.elasticsan.models.Action - """ - super().__init__(**kwargs) - self.virtual_network_resource_id = virtual_network_resource_id - self.action = action - - -class Volume(ProxyResource): - """Response for Volume request. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar properties: Properties of Volume. Required. - :vartype properties: ~azure.mgmt.elasticsan.models.VolumeProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": 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": "VolumeProperties"}, - } - - def __init__(self, *, properties: "_models.VolumeProperties", **kwargs: Any) -> None: - """ - :keyword properties: Properties of Volume. Required. - :paramtype properties: ~azure.mgmt.elasticsan.models.VolumeProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class VolumeGroup(ProxyResource): - """Response for Volume Group request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.elasticsan.models.Identity - :ivar properties: Properties of VolumeGroup. - :vartype properties: ~azure.mgmt.elasticsan.models.VolumeGroupProperties - """ - - _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"}, - "identity": {"key": "identity", "type": "Identity"}, - "properties": {"key": "properties", "type": "VolumeGroupProperties"}, - } - - def __init__( - self, - *, - identity: Optional["_models.Identity"] = None, - properties: Optional["_models.VolumeGroupProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.elasticsan.models.Identity - :keyword properties: Properties of VolumeGroup. - :paramtype properties: ~azure.mgmt.elasticsan.models.VolumeGroupProperties - """ - super().__init__(**kwargs) - self.identity = identity - self.properties = properties - - -class VolumeGroupList(_serialization.Model): - """List of Volume Groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of Volume Groups objects. - :vartype value: list[~azure.mgmt.elasticsan.models.VolumeGroup] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VolumeGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.VolumeGroup"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of Volume Groups objects. - :paramtype value: list[~azure.mgmt.elasticsan.models.VolumeGroup] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class VolumeGroupProperties(_serialization.Model): - """VolumeGroup response properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", - "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", - "Restoring", and "SoftDeleting". - :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates - :ivar protocol_type: Type of storage target. Known values are: "Iscsi" and "None". - :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType - :ivar encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey" and - "EncryptionAtRestWithCustomerManagedKey". - :vartype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType - :ivar encryption_properties: Encryption Properties describing Key Vault and Identity - information. - :vartype encryption_properties: ~azure.mgmt.elasticsan.models.EncryptionProperties - :ivar network_acls: A collection of rules governing the accessibility from specific network - locations. - :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet - :ivar private_endpoint_connections: The list of Private Endpoint Connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :ivar enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data - Integrity Check is enabled. - :vartype enforce_data_integrity_check_for_iscsi: bool - :ivar delete_retention_policy: The retention policy for the soft deleted volume group and its - associated resources. - :vartype delete_retention_policy: ~azure.mgmt.elasticsan.models.DeleteRetentionPolicy - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "protocol_type": {"key": "protocolType", "type": "str"}, - "encryption": {"key": "encryption", "type": "str"}, - "encryption_properties": {"key": "encryptionProperties", "type": "EncryptionProperties"}, - "network_acls": {"key": "networkAcls", "type": "NetworkRuleSet"}, - "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, - "enforce_data_integrity_check_for_iscsi": {"key": "enforceDataIntegrityCheckForIscsi", "type": "bool"}, - "delete_retention_policy": {"key": "deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, - } - - def __init__( - self, - *, - protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = None, - encryption: Optional[Union[str, "_models.EncryptionType"]] = None, - encryption_properties: Optional["_models.EncryptionProperties"] = None, - network_acls: Optional["_models.NetworkRuleSet"] = None, - enforce_data_integrity_check_for_iscsi: Optional[bool] = None, - delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol_type: Type of storage target. Known values are: "Iscsi" and "None". - :paramtype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType - :keyword encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey" - and "EncryptionAtRestWithCustomerManagedKey". - :paramtype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType - :keyword encryption_properties: Encryption Properties describing Key Vault and Identity - information. - :paramtype encryption_properties: ~azure.mgmt.elasticsan.models.EncryptionProperties - :keyword network_acls: A collection of rules governing the accessibility from specific network - locations. - :paramtype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet - :keyword enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data - Integrity Check is enabled. - :paramtype enforce_data_integrity_check_for_iscsi: bool - :keyword delete_retention_policy: The retention policy for the soft deleted volume group and - its associated resources. - :paramtype delete_retention_policy: ~azure.mgmt.elasticsan.models.DeleteRetentionPolicy - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.protocol_type = protocol_type - self.encryption = encryption - self.encryption_properties = encryption_properties - self.network_acls = network_acls - self.private_endpoint_connections = None - self.enforce_data_integrity_check_for_iscsi = enforce_data_integrity_check_for_iscsi - self.delete_retention_policy = delete_retention_policy - - -class VolumeGroupUpdate(_serialization.Model): - """Volume Group request. - - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.elasticsan.models.Identity - :ivar properties: Properties of VolumeGroup. - :vartype properties: ~azure.mgmt.elasticsan.models.VolumeGroupUpdateProperties - """ - - _attribute_map = { - "identity": {"key": "identity", "type": "Identity"}, - "properties": {"key": "properties", "type": "VolumeGroupUpdateProperties"}, - } - - def __init__( - self, - *, - identity: Optional["_models.Identity"] = None, - properties: Optional["_models.VolumeGroupUpdateProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.elasticsan.models.Identity - :keyword properties: Properties of VolumeGroup. - :paramtype properties: ~azure.mgmt.elasticsan.models.VolumeGroupUpdateProperties - """ - super().__init__(**kwargs) - self.identity = identity - self.properties = properties - - -class VolumeGroupUpdateProperties(_serialization.Model): - """VolumeGroup response properties. - - :ivar protocol_type: Type of storage target. Known values are: "Iscsi" and "None". - :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType - :ivar encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey" and - "EncryptionAtRestWithCustomerManagedKey". - :vartype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType - :ivar encryption_properties: Encryption Properties describing Key Vault and Identity - information. - :vartype encryption_properties: ~azure.mgmt.elasticsan.models.EncryptionProperties - :ivar network_acls: A collection of rules governing the accessibility from specific network - locations. - :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet - :ivar enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data - Integrity Check is enabled. - :vartype enforce_data_integrity_check_for_iscsi: bool - :ivar delete_retention_policy: The retention policy for the soft deleted volume group and its - associated resources. - :vartype delete_retention_policy: ~azure.mgmt.elasticsan.models.DeleteRetentionPolicy - """ - - _attribute_map = { - "protocol_type": {"key": "protocolType", "type": "str"}, - "encryption": {"key": "encryption", "type": "str"}, - "encryption_properties": {"key": "encryptionProperties", "type": "EncryptionProperties"}, - "network_acls": {"key": "networkAcls", "type": "NetworkRuleSet"}, - "enforce_data_integrity_check_for_iscsi": {"key": "enforceDataIntegrityCheckForIscsi", "type": "bool"}, - "delete_retention_policy": {"key": "deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, - } - - def __init__( - self, - *, - protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = None, - encryption: Optional[Union[str, "_models.EncryptionType"]] = None, - encryption_properties: Optional["_models.EncryptionProperties"] = None, - network_acls: Optional["_models.NetworkRuleSet"] = None, - enforce_data_integrity_check_for_iscsi: Optional[bool] = None, - delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol_type: Type of storage target. Known values are: "Iscsi" and "None". - :paramtype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType - :keyword encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey" - and "EncryptionAtRestWithCustomerManagedKey". - :paramtype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType - :keyword encryption_properties: Encryption Properties describing Key Vault and Identity - information. - :paramtype encryption_properties: ~azure.mgmt.elasticsan.models.EncryptionProperties - :keyword network_acls: A collection of rules governing the accessibility from specific network - locations. - :paramtype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet - :keyword enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data - Integrity Check is enabled. - :paramtype enforce_data_integrity_check_for_iscsi: bool - :keyword delete_retention_policy: The retention policy for the soft deleted volume group and - its associated resources. - :paramtype delete_retention_policy: ~azure.mgmt.elasticsan.models.DeleteRetentionPolicy - """ - super().__init__(**kwargs) - self.protocol_type = protocol_type - self.encryption = encryption - self.encryption_properties = encryption_properties - self.network_acls = network_acls - self.enforce_data_integrity_check_for_iscsi = enforce_data_integrity_check_for_iscsi - self.delete_retention_policy = delete_retention_policy - - -class VolumeList(_serialization.Model): - """List of Volumes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of Volume objects. - :vartype value: list[~azure.mgmt.elasticsan.models.Volume] - :ivar next_link: URI to fetch the next section of the paginated response. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Volume]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.Volume"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of Volume objects. - :paramtype value: list[~azure.mgmt.elasticsan.models.Volume] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class VolumeNameList(_serialization.Model): - """object to hold array of volume names. - - All required parameters must be populated in order to send to server. - - :ivar volume_names: array of volume names. Required. - :vartype volume_names: list[str] - """ - - _validation = { - "volume_names": {"required": True}, - } - - _attribute_map = { - "volume_names": {"key": "volumeNames", "type": "[str]"}, - } - - def __init__(self, *, volume_names: List[str], **kwargs: Any) -> None: - """ - :keyword volume_names: array of volume names. Required. - :paramtype volume_names: list[str] - """ - super().__init__(**kwargs) - self.volume_names = volume_names - - -class VolumeProperties(_serialization.Model): - """Volume response properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar volume_id: Unique Id of the volume in GUID format. - :vartype volume_id: str - :ivar creation_data: State of the operation on the resource. - :vartype creation_data: ~azure.mgmt.elasticsan.models.SourceCreationData - :ivar size_gi_b: Volume size. Required. - :vartype size_gi_b: int - :ivar storage_target: Storage target information. - :vartype storage_target: ~azure.mgmt.elasticsan.models.IscsiTargetInfo - :ivar managed_by: Parent resource information. - :vartype managed_by: ~azure.mgmt.elasticsan.models.ManagedByInfo - :ivar provisioning_state: State of the operation on the resource. Known values are: "Invalid", - "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting", "Deleted", - "Restoring", and "SoftDeleting". - :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates - """ - - _validation = { - "volume_id": {"readonly": True}, - "size_gi_b": {"required": True}, - "storage_target": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "volume_id": {"key": "volumeId", "type": "str"}, - "creation_data": {"key": "creationData", "type": "SourceCreationData"}, - "size_gi_b": {"key": "sizeGiB", "type": "int"}, - "storage_target": {"key": "storageTarget", "type": "IscsiTargetInfo"}, - "managed_by": {"key": "managedBy", "type": "ManagedByInfo"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - size_gi_b: int, - creation_data: Optional["_models.SourceCreationData"] = None, - managed_by: Optional["_models.ManagedByInfo"] = None, - **kwargs: Any - ) -> None: - """ - :keyword creation_data: State of the operation on the resource. - :paramtype creation_data: ~azure.mgmt.elasticsan.models.SourceCreationData - :keyword size_gi_b: Volume size. Required. - :paramtype size_gi_b: int - :keyword managed_by: Parent resource information. - :paramtype managed_by: ~azure.mgmt.elasticsan.models.ManagedByInfo - """ - super().__init__(**kwargs) - self.volume_id = None - self.creation_data = creation_data - self.size_gi_b = size_gi_b - self.storage_target = None - self.managed_by = managed_by - self.provisioning_state = None - - -class VolumeUpdate(_serialization.Model): - """Response for Volume request. - - :ivar properties: Properties of Volume. - :vartype properties: ~azure.mgmt.elasticsan.models.VolumeUpdateProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "VolumeUpdateProperties"}, - } - - def __init__(self, *, properties: Optional["_models.VolumeUpdateProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Properties of Volume. - :paramtype properties: ~azure.mgmt.elasticsan.models.VolumeUpdateProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class VolumeUpdateProperties(_serialization.Model): - """Volume response properties. - - :ivar size_gi_b: Volume size. - :vartype size_gi_b: int - :ivar managed_by: Parent resource information. - :vartype managed_by: ~azure.mgmt.elasticsan.models.ManagedByInfo - """ - - _attribute_map = { - "size_gi_b": {"key": "sizeGiB", "type": "int"}, - "managed_by": {"key": "managedBy", "type": "ManagedByInfo"}, - } - - def __init__( - self, *, size_gi_b: Optional[int] = None, managed_by: Optional["_models.ManagedByInfo"] = None, **kwargs: Any - ) -> None: - """ - :keyword size_gi_b: Volume size. - :paramtype size_gi_b: int - :keyword managed_by: Parent resource information. - :paramtype managed_by: ~azure.mgmt.elasticsan.models.ManagedByInfo - """ - super().__init__(**kwargs) - self.size_gi_b = size_gi_b - self.managed_by = managed_by diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py index fae06f03570b..e935c5d90360 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,14 +13,12 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import Operations # type: ignore -from ._skus_operations import SkusOperations # type: ignore -from ._elastic_sans_operations import ElasticSansOperations # type: ignore -from ._volume_groups_operations import VolumeGroupsOperations # type: ignore -from ._volumes_operations import VolumesOperations # type: ignore -from ._elastic_san_mgmt_client_operations import ElasticSanMgmtClientOperationsMixin # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._volume_snapshots_operations import VolumeSnapshotsOperations # type: ignore +from ._operations import ElasticSansOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import VolumeGroupsOperations # type: ignore +from ._operations import VolumesOperations # type: ignore +from ._operations import SnapshotsOperations # type: ignore +from ._operations import SkusOperationGroupOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -28,14 +26,12 @@ __all__ = [ "Operations", - "SkusOperations", "ElasticSansOperations", + "PrivateEndpointConnectionsOperations", "VolumeGroupsOperations", "VolumesOperations", - "ElasticSanMgmtClientOperationsMixin", - "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", - "VolumeSnapshotsOperations", + "SnapshotsOperations", + "SkusOperationGroupOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_san_mgmt_client_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_san_mgmt_client_operations.py deleted file mode 100644 index 944594306f74..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_san_mgmt_client_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterator, Optional, TypeVar, Union, cast - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 ElasticSanMgmtClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_restore_volume_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}/restore", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeName": _SERIALIZER.url( - "volume_name", volume_name, "str", max_length=63, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9A-Z]+)*$" - ), - } - - _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) - - -class ElasticSanMgmtClientOperationsMixin(ElasticSanMgmtClientMixinABC): - - def _restore_volume_initial( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_volume_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restore_volume( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Restore Soft Deleted Volumes. The volume name is obtained by using the API to list soft deleted - volumes by volume group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :return: An instance of LROPoller that returns either Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :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.Volume] = 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._restore_volume_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response.http_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.Volume].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Volume]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py deleted file mode 100644 index 4a6e05840abb..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py +++ /dev/null @@ -1,989 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, 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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, elastic_san_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-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, elastic_san_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-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, elastic_san_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, elastic_san_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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) - - -class ElasticSansOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`elastic_sans` 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_by_subscription(self, **kwargs: Any) -> Iterable["_models.ElasticSan"]: - """Gets a list of ElasticSans in a subscription. - - :return: An iterator like instance of either ElasticSan or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSanList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticSanList", 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ElasticSan"]: - """Gets a list of ElasticSan in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either ElasticSan or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSanList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticSanList", 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSan, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "ElasticSan") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: _models.ElasticSan, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticSan]: - """Create ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan - :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 ElasticSan or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticSan]: - """Create ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. 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 ElasticSan or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSan, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ElasticSan]: - """Create ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSan type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or IO[bytes] - :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSan] = 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_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticSan", pipeline_response.http_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.ElasticSan].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ElasticSan]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "ElasticSanUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: _models.ElasticSanUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticSan]: - """Update a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate - :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 ElasticSan or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticSan]: - """Update a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. 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 ElasticSan or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ElasticSan]: - """Update a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSanUpdate type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or IO[bytes] - :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] - :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.ElasticSan] = 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._update_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticSan", pipeline_response.http_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.ElasticSan].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ElasticSan]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete a Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_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._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - 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, 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[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 - - @distributed_trace - def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> _models.ElasticSan: - """Get a ElasticSan. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: ElasticSan or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.ElasticSan - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ElasticSan] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py index 0a621a2f8147..70ded948b4ab 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py @@ -1,44 +1,51 @@ +# pylint: disable=line-too-long,useless-suppression,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse 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 .._configuration import ElasticSanClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -46,7 +53,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.ElasticSan/operations") + _url = "/providers/Microsoft.ElasticSan/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -57,38 +64,5439 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_elastic_sans_get_request( + resource_group_name: str, elastic_san_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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_elastic_sans_create_request( + resource_group_name: str, elastic_san_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_sans_update_request( + resource_group_name: str, elastic_san_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_sans_delete_request( + resource_group_name: str, elastic_san_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_sans_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_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_elastic_sans_list_by_subscription_request( # pylint: disable=name-too-long + 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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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_elastic_sans_list_by_elastic_san_request( # pylint: disable=name-too-long + resource_group_name: str, elastic_san_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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_private_endpoint_connections_get_request( # pylint: disable=name-too-long + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_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_private_endpoint_connections_create_request( # pylint: disable=name-too-long + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_list_request( # pylint: disable=name-too-long + resource_group_name: str, elastic_san_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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_volume_groups_get_request( + resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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_volume_groups_create_request( + resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volume_groups_update_request( + resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volume_groups_delete_request( + resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volume_groups_list_by_elastic_san_request( # pylint: disable=name-too-long + resource_group_name: str, + elastic_san_name: str, + subscription_id: str, + *, + x_ms_access_soft_deleted_resources: Optional[Union[str, _models.X_ms_access_soft_deleted_resources]] = 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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_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_access_soft_deleted_resources is not None: + _headers["x-ms-access-soft-deleted-resources"] = _SERIALIZER.header( + "x_ms_access_soft_deleted_resources", x_ms_access_soft_deleted_resources, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volume_groups_pre_backup_request( + resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/preBackup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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_volume_groups_pre_restore_request( + resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/preRestore" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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_volumes_get_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "volumeName": _SERIALIZER.url("volume_name", volume_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_volumes_create_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "volumeName": _SERIALIZER.url("volume_name", volume_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volumes_update_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "volumeName": _SERIALIZER.url("volume_name", volume_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volumes_delete_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + subscription_id: str, + *, + x_ms_delete_snapshots: Optional[Union[str, _models.X_ms_delete_snapshots]] = None, + x_ms_force_delete: Optional[Union[str, _models.X_ms_force_delete]] = None, + delete_type: Optional[Union[str, _models.DeleteType]] = 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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "volumeName": _SERIALIZER.url("volume_name", volume_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if delete_type is not None: + _params["deleteType"] = _SERIALIZER.query("delete_type", delete_type, "str") + + # Construct headers + if x_ms_delete_snapshots is not None: + _headers["x-ms-delete-snapshots"] = _SERIALIZER.header("x_ms_delete_snapshots", x_ms_delete_snapshots, "str") + if x_ms_force_delete is not None: + _headers["x-ms-force-delete"] = _SERIALIZER.header("x_ms_force_delete", x_ms_force_delete, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volumes_list_by_volume_group_request( # pylint: disable=name-too-long + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + subscription_id: str, + *, + x_ms_access_soft_deleted_resources: Optional[Union[str, _models.X_ms_access_soft_deleted_resources]] = 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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_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_access_soft_deleted_resources is not None: + _headers["x-ms-access-soft-deleted-resources"] = _SERIALIZER.header( + "x_ms_access_soft_deleted_resources", x_ms_access_soft_deleted_resources, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_volumes_restore_volume_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}/restore" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "volumeName": _SERIALIZER.url("volume_name", volume_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_snapshots_get_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_snapshots_create_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_snapshots_delete_request( + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_snapshots_list_by_volume_group_request( # pylint: disable=name-too-long + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + subscription_id: str, + *, + filter: 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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "elasticSanName": _SERIALIZER.url("elastic_san_name", elastic_san_name, "str"), + "volumeGroupName": _SERIALIZER.url("volume_group_name", volume_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_skus_operation_group_list_request( + subscription_id: str, *, filter: 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-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`operations` attribute. + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ElasticSansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`elastic_sans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> _models.ElasticSan: + """Get a ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: ElasticSan. The ElasticSan is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.ElasticSan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ElasticSan] = kwargs.pop("cls", None) + + _request = build_elastic_sans_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ElasticSan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_sans_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: _models.ElasticSan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: JSON + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. 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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Is one of the following types: ElasticSan, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSanUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_sans_update_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: _models.ElasticSanUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate + :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 ElasticSan. The ElasticSan is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Required. + :type parameters: JSON + :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 ElasticSan. The ElasticSan is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. 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 ElasticSan. The ElasticSan is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSanUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ElasticSan]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param parameters: Elastic San object. Is one of the following types: ElasticSanUpdate, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns ElasticSan. The ElasticSan is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ElasticSan] = 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._update_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ElasticSan, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ElasticSan].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ElasticSan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_elastic_sans_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ElasticSan"]: + """Gets a list of ElasticSan in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of ElasticSan + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticSan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_elastic_sans_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ElasticSan], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ElasticSan"]: + """Gets a list of ElasticSans in a subscription. + + :return: An iterator like instance of ElasticSan + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticSan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_elastic_sans_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ElasticSan], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_elastic_san( + self, resource_group_name: str, elastic_san_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: + """Gets the private link resources that need to be created for a elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_elastic_sans_list_by_elastic_san_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. Required. + :type parameters: JSON + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. 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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Update the state of specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Private Endpoint Connection Approval object. Is one of the following types: + PrivateEndpointConnection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _delete_initial( + self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified private endpoint connection associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list( + self, resource_group_name: str, elastic_san_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List all Private Endpoint Connections associated with the Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_private_endpoint_connections_list_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class VolumeGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`volume_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any + ) -> _models.VolumeGroup: + """Get an VolumeGroups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :return: VolumeGroup. The VolumeGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VolumeGroup] = kwargs.pop("cls", None) + + _request = build_volume_groups_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VolumeGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.VolumeGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: JSON + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. 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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Is one of the following types: VolumeGroup, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_update_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.VolumeGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate + :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 VolumeGroup. The VolumeGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Required. + :type parameters: JSON + :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 VolumeGroup. The VolumeGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. 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 VolumeGroup. The VolumeGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VolumeGroup]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Group object. Is one of the following types: VolumeGroupUpdate, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns VolumeGroup. The VolumeGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VolumeGroup] = 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._update_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VolumeGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VolumeGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VolumeGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_volume_groups_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_elastic_san( + self, + resource_group_name: str, + elastic_san_name: str, + *, + x_ms_access_soft_deleted_resources: Optional[Union[str, _models.X_ms_access_soft_deleted_resources]] = None, + **kwargs: Any + ) -> Iterable["_models.VolumeGroup"]: + """List VolumeGroups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :keyword x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volume groups + if set to true. If set to false or if not specified, returns only active volume groups. Known + values are: "true" and "false". Default value is None. + :paramtype x_ms_access_soft_deleted_resources: str or + ~azure.mgmt.elasticsan.models.X_ms_access_soft_deleted_resources + :return: An iterator like instance of VolumeGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VolumeGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_volume_groups_list_by_elastic_san_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + subscription_id=self._config.subscription_id, + x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.VolumeGroup], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _pre_backup_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeNameList, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_pre_backup_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.VolumeNameList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList + :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 PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). Required. + :type parameters: JSON + :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 PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). 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 PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_pre_backup( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.VolumeNameList, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a disk snapshot backup can be taken for list of volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Volume Name List (currently only one volume name in the list is supported. + Server would return error if list is bigger). Is one of the following types: VolumeNameList, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList or JSON or IO[bytes] + :return: An instance of LROPoller that returns PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreValidationResponse] = 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._pre_backup_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PreValidationResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PreValidationResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PreValidationResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _pre_restore_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.DiskSnapshotList, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volume_groups_pre_restore_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: _models.DiskSnapshotList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). Required. + :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList + :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 PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). Required. + :type parameters: JSON + :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 PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). 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 PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_pre_restore( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: Union[_models.DiskSnapshotList, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PreValidationResponse]: + """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is + supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server + would return error if list is bigger). Is one of the following types: DiskSnapshotList, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList or JSON or IO[bytes] + :return: An instance of LROPoller that returns PreValidationResponse. The PreValidationResponse + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreValidationResponse] = 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._pre_restore_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PreValidationResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PreValidationResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PreValidationResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class VolumesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`volumes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any + ) -> _models.Volume: + """Get an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :return: Volume. The Volume is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.Volume + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Volume] = kwargs.pop("cls", None) + + _request = build_volumes_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Volume, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.Volume, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volumes_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: _models.Volume, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Volume + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: JSON + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. 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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.Volume, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Is one of the following types: Volume, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.elasticsan.models.Volume or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.VolumeUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_volumes_update_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: _models.VolumeUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate + :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 Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Required. + :type parameters: JSON + :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 Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. 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 Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: Union[_models.VolumeUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Volume]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :param parameters: Volume object. Is one of the following types: VolumeUpdate, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Volume] = 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._update_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Volume, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Volume].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + x_ms_delete_snapshots: Optional[Union[str, _models.X_ms_delete_snapshots]] = None, + x_ms_force_delete: Optional[Union[str, _models.X_ms_force_delete]] = None, + delete_type: Optional[Union[str, _models.DeleteType]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_volumes_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + x_ms_delete_snapshots=x_ms_delete_snapshots, + x_ms_force_delete=x_ms_force_delete, + delete_type=delete_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + x_ms_delete_snapshots: Optional[Union[str, _models.X_ms_delete_snapshots]] = None, + x_ms_force_delete: Optional[Union[str, _models.X_ms_force_delete]] = None, + delete_type: Optional[Union[str, _models.DeleteType]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :keyword x_ms_delete_snapshots: Optional, used to delete snapshots under volume. Allowed value + are only true or false. Default value is false. Known values are: "true" and "false". Default + value is None. + :paramtype x_ms_delete_snapshots: str or ~azure.mgmt.elasticsan.models.X_ms_delete_snapshots + :keyword x_ms_force_delete: Optional, used to delete volume if active sessions present. Allowed + value are only true or false. Default value is false. Known values are: "true" and "false". + Default value is None. + :paramtype x_ms_force_delete: str or ~azure.mgmt.elasticsan.models.X_ms_force_delete + :keyword delete_type: Optional. Specifies that the delete operation should be a permanent + delete for the soft deleted volume. The value of deleteType can only be 'permanent'. + "permanent" Default value is None. + :paramtype delete_type: str or ~azure.mgmt.elasticsan.models.DeleteType + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + x_ms_delete_snapshots=x_ms_delete_snapshots, + x_ms_force_delete=x_ms_force_delete, + delete_type=delete_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_volume_group( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + x_ms_access_soft_deleted_resources: Optional[Union[str, _models.X_ms_access_soft_deleted_resources]] = None, + **kwargs: Any + ) -> Iterable["_models.Volume"]: + """List Volumes in a VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :keyword x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volumes if set + to true. If set to false or if not specified, returns only active volumes. Known values are: + "true" and "false". Default value is None. + :paramtype x_ms_access_soft_deleted_resources: str or + ~azure.mgmt.elasticsan.models.X_ms_access_soft_deleted_resources + :return: An iterator like instance of Volume + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Volume]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_volumes_list_by_volume_group_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Volume], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _restore_volume_initial( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_volumes_restore_volume_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_restore_volume( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any + ) -> LROPoller[_models.Volume]: + """Restore Soft Deleted Volumes. The volume name is obtained by using the API to list soft deleted + volumes by volume group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param volume_name: The name of the Volume. Required. + :type volume_name: str + :return: An instance of LROPoller that returns Volume. The Volume is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Volume] = 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._restore_volume_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Volume, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Volume].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`snapshots` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any + ) -> _models.Snapshot: + """Get a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :return: Snapshot. The Snapshot is compatible with MutableMapping + :rtype: ~azure.mgmt.elasticsan.models.Snapshot + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + + _request = build_snapshots_get_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Snapshot, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: Union[_models.Snapshot, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_snapshots_create_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: _models.Snapshot, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Snapshot + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. Required. + :type parameters: JSON + :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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. 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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + snapshot_name: str, + parameters: Union[_models.Snapshot, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :param parameters: Snapshot object. Is one of the following types: Snapshot, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _delete_initial( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_snapshots_delete_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a Volume Snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :param snapshot_name: The name of the volume snapshot within the given volume group. Required. + :type snapshot_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + snapshot_name=snapshot_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_volume_group( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.Snapshot"]: + """List Snapshots in a VolumeGroup or List Snapshots by Volume (name) in a VolumeGroup using + filter. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. Required. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. Required. + :type volume_group_name: str + :keyword filter: Specify $filter='volumeName eq ' to filter on volume. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of Snapshot + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Snapshot]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_snapshots_list_by_volume_group_request( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Snapshot], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SkusOperationGroupOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanClient`'s + :attr:`skus_operation_group` attribute. + """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ElasticSanClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Gets a list of ElasticSan operations. + def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.SkuInformation"]: + """List all the available Skus in the region and information related to them. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Operation] + List all the available Skus in the region and information related to them. + + :keyword filter: Specify $filter='location eq ' to filter on location. Default value + is None. + :paramtype filter: str + :return: An iterator like instance of SkuInformation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.SkuInformation]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -101,12 +5509,19 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_skus_operation_group_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -121,16 +5536,21 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.SkuInformation], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -143,7 +5563,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 54215a6800f6..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,716 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_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-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_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_delete_request( - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, elastic_san_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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) - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`private_endpoint_connections` 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") - - def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "PrivateEndpointConnection") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the state of specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Private Endpoint Connection Approval object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection - :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 PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the state of specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Private Endpoint Connection Approval object. 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 PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Update the state of specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Private Endpoint Connection Approval object. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :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.PrivateEndpointConnection] = 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_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get( - self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets the specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the specified private endpoint connection associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. - :type private_endpoint_connection_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._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - 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, 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[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 - - @distributed_trace - def list( - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - """List all Private Endpoint Connections associated with the Elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] - :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.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py deleted file mode 100644 index 7c025500eef7..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_elastic_san_request( - resource_group_name: str, elastic_san_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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) - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`private_link_resources` 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_by_elastic_san( - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources that need to be created for a elastic San. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_elastic_san_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py deleted file mode 100644 index aa1d0e3dc0f8..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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(subscription_id: str, *, filter: 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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/skus") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`skus` 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, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.SkuInformation"]: - """List all the available Skus in the region and information related to them. - - List all the available Skus in the region and information related to them. - - :param filter: Specify $filter='location eq :code:``' to filter on location. Default - value is None. - :type filter: str - :return: An iterator like instance of either SkuInformation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.SkuInformation] - :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.SkuInformationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SkuInformationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py deleted file mode 100644 index e4a6c9ac7713..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py +++ /dev/null @@ -1,999 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_elastic_san_request( - resource_group_name: str, - elastic_san_name: str, - subscription_id: str, - *, - x_ms_access_soft_deleted_resources: Optional[Union[str, _models.XMsAccessSoftDeletedResources]] = 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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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_access_soft_deleted_resources is not None: - _headers["x-ms-access-soft-deleted-resources"] = _SERIALIZER.header( - "x_ms_access_soft_deleted_resources", x_ms_access_soft_deleted_resources, "str" - ) - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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) - - -class VolumeGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`volume_groups` 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_by_elastic_san( - self, - resource_group_name: str, - elastic_san_name: str, - x_ms_access_soft_deleted_resources: Optional[Union[str, _models.XMsAccessSoftDeletedResources]] = None, - **kwargs: Any - ) -> Iterable["_models.VolumeGroup"]: - """List VolumeGroups. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volume groups if - set to true. If set to false or if not specified, returns only active volume groups. Known - values are: "true" and "false". Default value is None. - :type x_ms_access_soft_deleted_resources: str or - ~azure.mgmt.elasticsan.models.XMsAccessSoftDeletedResources - :return: An iterator like instance of either VolumeGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.VolumeGroup] - :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.VolumeGroupList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_elastic_san_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - subscription_id=self._config.subscription_id, - x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VolumeGroupList", 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "VolumeGroup") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.VolumeGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VolumeGroup]: - """Create a Volume Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup - :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 VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VolumeGroup]: - """Create a Volume Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. 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 VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VolumeGroup]: - """Create a Volume Group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroup type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or IO[bytes] - :return: An instance of LROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :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.VolumeGroup] = 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_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VolumeGroup", pipeline_response.http_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.VolumeGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VolumeGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "VolumeGroupUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.VolumeGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VolumeGroup]: - """Update an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate - :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 VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VolumeGroup]: - """Update an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. 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 VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VolumeGroup]: - """Update an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroupUpdate type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VolumeGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] - :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.VolumeGroup] = 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._update_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VolumeGroup", pipeline_response.http_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.VolumeGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VolumeGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete an VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_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._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - 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, 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[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 - - @distributed_trace - def get( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> _models.VolumeGroup: - """Get an VolumeGroups. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :return: VolumeGroup or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.VolumeGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_operations.py deleted file mode 100644 index f868be427705..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_operations.py +++ /dev/null @@ -1,801 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_volume_group_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - subscription_id: str, - *, - filter: 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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _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_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_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-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "snapshotName": _SERIALIZER.url( - "snapshot_name", - snapshot_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-z0-9]+(?:[._-][a-z0-9]+)*$", - ), - } - - _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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "snapshotName": _SERIALIZER.url( - "snapshot_name", - snapshot_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-z0-9]+(?:[._-][a-z0-9]+)*$", - ), - } - - _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "snapshotName": _SERIALIZER.url( - "snapshot_name", - snapshot_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-z0-9]+(?:[._-][a-z0-9]+)*$", - ), - } - - _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) - - -class VolumeSnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`volume_snapshots` 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_by_volume_group( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.Snapshot"]: - """List Snapshots in a VolumeGroup or List Snapshots by Volume (name) in a VolumeGroup using - filter. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param filter: Specify $filter='volumeName eq :code:``' to filter on volume. - Default value is None. - :type filter: str - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Snapshot] - :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.SnapshotList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_volume_group_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: Union[_models.Snapshot, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "Snapshot") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Create a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :param parameters: Snapshot object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Snapshot - :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 Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Create a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :param parameters: Snapshot object. 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - snapshot_name: str, - parameters: Union[_models.Snapshot, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Create a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :param parameters: Snapshot object. Is either a Snapshot type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or IO[bytes] - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Snapshot] - :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.Snapshot] = 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_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response.http_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.Snapshot].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Snapshot]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_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._delete_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - 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, 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[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 - - @distributed_trace - def get( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> _models.Snapshot: - """Get a Volume Snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param snapshot_name: The name of the volume snapshot within the given volume group. Required. - :type snapshot_name: str - :return: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.Snapshot - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.Snapshot] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py deleted file mode 100644 index 732b0fad340b..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py +++ /dev/null @@ -1,1645 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_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-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeName": _SERIALIZER.url( - "volume_name", volume_name, "str", max_length=63, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9A-Z]+)*$" - ), - } - - _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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_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-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeName": _SERIALIZER.url( - "volume_name", volume_name, "str", max_length=63, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9A-Z]+)*$" - ), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - subscription_id: str, - *, - x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, - x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, - delete_type: Optional[Union[str, _models.DeleteType]] = 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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeName": _SERIALIZER.url( - "volume_name", volume_name, "str", max_length=63, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9A-Z]+)*$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if delete_type is not None: - _params["deleteType"] = _SERIALIZER.query("delete_type", delete_type, "str") - - # Construct headers - if x_ms_delete_snapshots is not None: - _headers["x-ms-delete-snapshots"] = _SERIALIZER.header("x_ms_delete_snapshots", x_ms_delete_snapshots, "str") - if x_ms_force_delete is not None: - _headers["x-ms-force-delete"] = _SERIALIZER.header("x_ms_force_delete", x_ms_force_delete, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeName": _SERIALIZER.url( - "volume_name", volume_name, "str", max_length=63, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9A-Z]+)*$" - ), - } - - _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_list_by_volume_group_request( - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - subscription_id: str, - *, - x_ms_access_soft_deleted_resources: Optional[Union[str, _models.XMsAccessSoftDeletedResources]] = 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-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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_access_soft_deleted_resources is not None: - _headers["x-ms-access-soft-deleted-resources"] = _SERIALIZER.header( - "x_ms_access_soft_deleted_resources", x_ms_access_soft_deleted_resources, "str" - ) - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_pre_backup_request( - resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/preBackup", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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_pre_restore_request( - resource_group_name: str, elastic_san_name: str, volume_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) - 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/preRestore", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "elasticSanName": _SERIALIZER.url( - "elastic_san_name", - elastic_san_name, - "str", - max_length=24, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - "volumeGroupName": _SERIALIZER.url( - "volume_group_name", - volume_group_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$", - ), - } - - _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) - - -class VolumesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.elasticsan.ElasticSanMgmtClient`'s - :attr:`volumes` 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") - - def _create_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.Volume, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "Volume") - - _request = build_create_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: _models.Volume, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Create a Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Volume - :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 Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Create a Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. 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 Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.Volume, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Create a Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Is either a Volume type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Volume or IO[bytes] - :return: An instance of LROPoller that returns either Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :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.Volume] = 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_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response.http_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.Volume].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Volume]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.VolumeUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "VolumeUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: _models.VolumeUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Update an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate - :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 Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Update an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. 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 Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - parameters: Union[_models.VolumeUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Volume]: - """Update an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param parameters: Volume object. Is either a VolumeUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Volume or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] - :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.Volume] = 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._update_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response.http_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.Volume].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Volume]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, - x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, - delete_type: Optional[Union[str, _models.DeleteType]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - x_ms_delete_snapshots=x_ms_delete_snapshots, - x_ms_force_delete=x_ms_force_delete, - delete_type=delete_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - volume_name: str, - x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, - x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, - delete_type: Optional[Union[str, _models.DeleteType]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Delete an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :param x_ms_delete_snapshots: Optional, used to delete snapshots under volume. Allowed value - are only true or false. Default value is false. Known values are: "true" and "false". Default - value is None. - :type x_ms_delete_snapshots: str or ~azure.mgmt.elasticsan.models.XMsDeleteSnapshots - :param x_ms_force_delete: Optional, used to delete volume if active sessions present. Allowed - value are only true or false. Default value is false. Known values are: "true" and "false". - Default value is None. - :type x_ms_force_delete: str or ~azure.mgmt.elasticsan.models.XMsForceDelete - :param delete_type: Optional. Specifies that the delete operation should be a permanent delete - for the soft deleted volume. The value of deleteType can only be 'permanent'. "permanent" - Default value is None. - :type delete_type: str or ~azure.mgmt.elasticsan.models.DeleteType - :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( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - x_ms_delete_snapshots=x_ms_delete_snapshots, - x_ms_force_delete=x_ms_force_delete, - delete_type=delete_type, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - 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, 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[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 - - @distributed_trace - def get( - self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, volume_name: str, **kwargs: Any - ) -> _models.Volume: - """Get an Volume. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param volume_name: The name of the Volume. Required. - :type volume_name: str - :return: Volume or the result of cls(response) - :rtype: ~azure.mgmt.elasticsan.models.Volume - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.Volume] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - volume_name=volume_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Volume", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_volume_group( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - x_ms_access_soft_deleted_resources: Optional[Union[str, _models.XMsAccessSoftDeletedResources]] = None, - **kwargs: Any - ) -> Iterable["_models.Volume"]: - """List Volumes in a VolumeGroup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param x_ms_access_soft_deleted_resources: Optional, returns only soft deleted volumes if set - to true. If set to false or if not specified, returns only active volumes. Known values are: - "true" and "false". Default value is None. - :type x_ms_access_soft_deleted_resources: str or - ~azure.mgmt.elasticsan.models.XMsAccessSoftDeletedResources - :return: An iterator like instance of either Volume or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Volume] - :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.VolumeList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_by_volume_group_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - x_ms_access_soft_deleted_resources=x_ms_access_soft_deleted_resources, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VolumeList", 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _pre_backup_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeNameList, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "VolumeNameList") - - _request = build_pre_backup_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_pre_backup( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.VolumeNameList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PreValidationResponse]: - """Validate whether a disk snapshot backup can be taken for list of volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Name List (currently only one volume name in the list is supported. - Server would return error if list is bigger). Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList - :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 PreValidationResponse or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_pre_backup( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PreValidationResponse]: - """Validate whether a disk snapshot backup can be taken for list of volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Name List (currently only one volume name in the list is supported. - Server would return error if list is bigger). 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 PreValidationResponse or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_pre_backup( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.VolumeNameList, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PreValidationResponse]: - """Validate whether a disk snapshot backup can be taken for list of volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Volume Name List (currently only one volume name in the list is supported. - Server would return error if list is bigger). Is either a VolumeNameList type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeNameList or IO[bytes] - :return: An instance of LROPoller that returns either PreValidationResponse or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :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.PreValidationResponse] = 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._pre_backup_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PreValidationResponse", pipeline_response.http_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.PreValidationResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PreValidationResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _pre_restore_initial( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.DiskSnapshotList, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, "DiskSnapshotList") - - _request = build_pre_restore_request( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_pre_restore( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: _models.DiskSnapshotList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PreValidationResponse]: - """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is - supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server - would return error if list is bigger). Required. - :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList - :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 PreValidationResponse or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_pre_restore( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PreValidationResponse]: - """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is - supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server - would return error if list is bigger). 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 PreValidationResponse or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_pre_restore( - self, - resource_group_name: str, - elastic_san_name: str, - volume_group_name: str, - parameters: Union[_models.DiskSnapshotList, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PreValidationResponse]: - """Validate whether a list of backed up disk snapshots can be restored into ElasticSan volumes. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param elastic_san_name: The name of the ElasticSan. Required. - :type elastic_san_name: str - :param volume_group_name: The name of the VolumeGroup. Required. - :type volume_group_name: str - :param parameters: Disk Snapshot List (currently only one Disk Snapshot in the list is - supported and that the Disk Snapshot must be in same azure region as the ElasticSan. Server - would return error if list is bigger). Is either a DiskSnapshotList type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.elasticsan.models.DiskSnapshotList or IO[bytes] - :return: An instance of LROPoller that returns either PreValidationResponse or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PreValidationResponse] - :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.PreValidationResponse] = 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._pre_restore_initial( - resource_group_name=resource_group_name, - elastic_san_name=elastic_san_name, - volume_group_name=volume_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PreValidationResponse", pipeline_response.http_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.PreValidationResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PreValidationResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py index 102a39b22422..b5d8dd814bde 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.elastic_sans.begin_create( + client.elastic_sans.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", parameters={ @@ -53,9 +53,8 @@ def main(): "tags": {"key9316": "ihndtieqibtob"}, }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Create_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py index 570e6397f8db..6fc53bcd01bb 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.elastic_sans.begin_create( + client.elastic_sans.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", parameters={ @@ -38,9 +38,8 @@ def main(): "properties": {"baseSizeTiB": 15, "extendedCapacitySizeTiB": 27, "sku": {"name": "Premium_LRS"}}, }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Create_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py index baf6f1322882..f7785e5c30e8 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.elastic_sans.begin_delete( @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py index 3e08c36dc9a3..e4f9928106b9 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.elastic_sans.begin_delete( @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Delete_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py index 635179e83547..8d592aeebf9b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py index b4e45cf5b692..a6400a53f519 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Get_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py index a8be468271d5..e50ae49482f3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.list_by_resource_group( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py index fb65ee1a7f06..69ae7937937b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.list_by_resource_group( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py index b6c9008a2787..7532c5245336 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.list_by_subscription() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_ListBySubscription_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py index 0856ae486b0d..483b76f1a3f4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.list_by_subscription() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_ListBySubscription_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py index 9625b7eccd4a..30d54222f32e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_sans.begin_update( @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/ElasticSans_Update_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/ElasticSans_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py index b8724ac7b64e..6834e64cca1e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,7 +25,7 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), subscription_id="SUBSCRIPTION_ID", ) @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Operations_List_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Operations_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py index 147dd19d6b21..1c174d30b994 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,7 +25,7 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), subscription_id="SUBSCRIPTION_ID", ) @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Operations_List_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Operations_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py index 1e9cdb89a2e5..a6074cce21d0 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.private_endpoint_connections.begin_create( + client.private_endpoint_connections.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", private_endpoint_connection_name="privateendpointconnectionname", @@ -46,9 +46,8 @@ def main(): } }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_Create_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py index af392444160a..686556bf6c05 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,20 +25,19 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.private_endpoint_connections.begin_create( + client.private_endpoint_connections.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", private_endpoint_connection_name="privateendpointconnectionname", parameters={"properties": {"privateLinkServiceConnectionState": {}}}, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_Create_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py index b16bdeb0d32e..0daa0d1c64fb 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.private_endpoint_connections.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py index 5b6117f4d5c8..5662e46b7515 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.private_endpoint_connections.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_Delete_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py index 7b7adb29af7a..143ae5cbd57e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py index 6c2faf2f6273..40596e23a516 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py index ef318d05e344..bb3cf293af15 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_List_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py index 50701a407efc..0fb8d0661215 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateEndpointConnections_List_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateEndpointConnections_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py index a9548402a23c..c897afca4aad 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,18 +25,19 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.private_link_resources.list_by_elastic_san( + response = client.elastic_sans.list_by_elastic_san( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateLinkResources_ListByElasticSan_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateLinkResources_ListByElasticSan_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py index 088954b69dbe..870f95215041 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,18 +25,19 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.private_link_resources.list_by_elastic_san( + response = client.elastic_sans.list_by_elastic_san( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/PrivateLinkResources_ListByElasticSan_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/PrivateLinkResources_ListByElasticSan_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_maximum_set_gen.py index d483add6b9f5..3d9f0c432621 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.begin_restore_volume( + response = client.volumes.begin_restore_volume( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/RestoreVolume_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/RestoreVolume_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_minimum_set_gen.py index 6c2557ee979c..572b25e92d43 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/restore_volume_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.begin_restore_volume( + response = client.volumes.begin_restore_volume( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/RestoreVolume_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/RestoreVolume_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py index 83ca7115c016..1d7096e49dd1 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,16 +25,16 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.skus.list() + response = client.skus_operation_group.list() for item in response: print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Skus_List_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Skus_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py index 773f2f27356a..0f46f0d83da9 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,16 +25,16 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.skus.list() + response = client.skus_operation_group.list() for item in response: print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Skus_List_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Skus_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py index cd7a773b2c5b..7a12d37c0590 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_groups.begin_create( + client.volume_groups.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -53,9 +53,8 @@ def main(): }, }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_Create_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py index 4a57e2e0edb8..f465ffefb83c 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.volume_groups.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py index c006dc376f3a..cabdfe31e3d9 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.volume_groups.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_Delete_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py index f106120b4526..043213757756 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volume_groups.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py index a3f17613d3c8..d96b65e9e0b0 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volume_groups.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py index 919a04e61fe5..353621a0c3f2 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volume_groups.list_by_elastic_san( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py index 9d21e9fe96e6..aca7e4d20c13 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volume_groups.list_by_elastic_san( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py index da471eceed14..d1c0e06cc4b7 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volume_groups.begin_update( @@ -56,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeGroups_Update_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeGroups_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py index ce0d79e477dd..1d471ab3fde7 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py @@ -1,14 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +26,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_snapshots.begin_create( + client.snapshots.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -43,9 +44,8 @@ def main(): } }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_Create_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py index 959b687bd93d..a739618e7421 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py @@ -1,14 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +26,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_snapshots.begin_create( + client.snapshots.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -43,9 +44,8 @@ def main(): } }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_Create_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py index d260e8326344..0c3833bc5dce 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - client.volume_snapshots.begin_delete( + client.snapshots.begin_delete( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py index 5819c67495cb..0696b14e47a0 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - client.volume_snapshots.begin_delete( + client.snapshots.begin_delete( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_Delete_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py index a477efda19a1..ce4ff13da1c0 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_snapshots.get( + response = client.snapshots.get( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py index a8fc282ec60d..a0eb0727f1c4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_snapshots.get( + response = client.snapshots.get( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_Get_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py index 8f93e4ed3820..4794cf735511 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_snapshots.list_by_volume_group( + response = client.snapshots.list_by_volume_group( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_ListByVolumeGroup_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_ListByVolumeGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py index 401fab075f5c..fe1f0c1c5050 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volume_snapshots.list_by_volume_group( + response = client.snapshots.list_by_volume_group( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/VolumeSnapshots_ListByVolumeGroup_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/VolumeSnapshots_ListByVolumeGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py index 71a0c332f4d9..b3005d7639af 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volumes.begin_create( + client.volumes.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -43,9 +43,8 @@ def main(): } }, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Create_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py index c3d9d38734f9..32ace5ac8597 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,21 +25,20 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volumes.begin_create( + client.volumes.begin_create( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", volume_name="volumename", parameters={"properties": {"sizeGiB": 9}}, ).result() - print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Create_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py index 9444b4565195..1687baf68c1b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.volumes.begin_delete( @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py index d72d96e12f2a..c44a923aab44 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) client.volumes.begin_delete( @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Delete_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py index e205fd74be2b..a7f2878a5795 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volumes.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Get_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py index 0127f463ae23..3da4b55f169a 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volumes.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Get_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py index 8693a07fd07c..4b15c9dbe86c 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volumes.list_by_volume_group( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_ListByVolumeGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py index 8b0c1cc1b388..7de7dd8c5f58 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volumes.list_by_volume_group( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_ListByVolumeGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_backup_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_backup_maximum_set_gen.py index 6f57f7175236..b3c4eabf9e33 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_backup_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_backup_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +25,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volumes.begin_pre_backup( + response = client.volume_groups.begin_pre_backup( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_PreBackup_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_PreBackup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_restore_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_restore_maximum_set_gen.py index 3c6c3b1a561a..26c95b494274 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_restore_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_pre_restore_maximum_set_gen.py @@ -1,14 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,12 +26,12 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.volumes.begin_pre_restore( + response = client.volume_groups.begin_pre_restore( resource_group_name="resourcegroupname", elastic_san_name="elasticsanname", volume_group_name="volumegroupname", @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_PreRestore_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_PreRestore_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py index 1e8fc39c595b..efe406b32629 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient """ # PREREQUISITES @@ -25,9 +25,9 @@ def main(): - client = ElasticSanMgmtClient( + client = ElasticSanClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionid", + subscription_id="SUBSCRIPTION_ID", ) response = client.volumes.begin_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-07-01-preview/examples/Volumes_Update_MaximumSet_Gen.json +# x-ms-original-file: 2024-07-01-preview/Volumes_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py index dd53ed73adf4..2be08a856a3f 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os @@ -21,14 +21,14 @@ # For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - elasticsanmgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - elasticsanmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - elasticsanmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - elasticsanmgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=elasticsanmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=elasticsanmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=elasticsanmgmt_client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=elasticsanmgmt_client_secret, value="00000000-0000-0000-0000-000000000000") + elasticsan_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + elasticsan_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + elasticsan_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + elasticsan_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsan_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsan_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsan_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsan_client_secret, value="00000000-0000-0000-0000-000000000000") add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") add_header_regex_sanitizer(key="Cookie", value="cookie;") diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_elastic_sans_operations.py similarity index 90% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_elastic_sans_operations.py index e9f1f86bf9f6..9ac2c546a854 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_elastic_sans_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,28 +14,18 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtElasticSansOperations(AzureMgmtRecordedTestCase): +class TestElasticSanElasticSansOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_elastic_sans_list_by_subscription(self, resource_group): - response = self.client.elastic_sans.list_by_subscription( - api_version="2024-07-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_elastic_sans_list_by_resource_group(self, resource_group): - response = self.client.elastic_sans.list_by_resource_group( + def test_elastic_sans_get(self, resource_group): + response = self.client.elastic_sans.get( resource_group_name=resource_group.name, - api_version="2024-07-01-preview", + elastic_san_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -106,7 +96,6 @@ def test_elastic_sans_begin_create(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -134,7 +123,6 @@ def test_elastic_sans_begin_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -146,7 +134,6 @@ def test_elastic_sans_begin_delete(self, resource_group): response = self.client.elastic_sans.begin_delete( resource_group_name=resource_group.name, elastic_san_name="str", - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -154,12 +141,29 @@ def test_elastic_sans_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_elastic_sans_get(self, resource_group): - response = self.client.elastic_sans.get( + def test_elastic_sans_list_by_resource_group(self, resource_group): + response = self.client.elastic_sans.list_by_resource_group( resource_group_name=resource_group.name, - elastic_san_name="str", - api_version="2024-07-01-preview", ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_elastic_sans_list_by_subscription(self, resource_group): + response = self.client.elastic_sans.list_by_subscription() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_elastic_sans_list_by_elastic_san(self, resource_group): + response = self.client.elastic_sans.list_by_elastic_san( + resource_group_name=resource_group.name, + elastic_san_name="str", + ) + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_elastic_sans_operations_async.py similarity index 90% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_elastic_sans_operations_async.py index 7ca3855297aa..fa3a1464b3c3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_elastic_sans_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,28 +15,18 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtElasticSansOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanElasticSansOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_elastic_sans_list_by_subscription(self, resource_group): - response = self.client.elastic_sans.list_by_subscription( - api_version="2024-07-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_elastic_sans_list_by_resource_group(self, resource_group): - response = self.client.elastic_sans.list_by_resource_group( + async def test_elastic_sans_get(self, resource_group): + response = await self.client.elastic_sans.get( resource_group_name=resource_group.name, - api_version="2024-07-01-preview", + elastic_san_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -108,7 +98,6 @@ async def test_elastic_sans_begin_create(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -138,7 +127,6 @@ async def test_elastic_sans_begin_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -152,7 +140,6 @@ async def test_elastic_sans_begin_delete(self, resource_group): await self.client.elastic_sans.begin_delete( resource_group_name=resource_group.name, elastic_san_name="str", - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -161,12 +148,29 @@ async def test_elastic_sans_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_elastic_sans_get(self, resource_group): - response = await self.client.elastic_sans.get( + async def test_elastic_sans_list_by_resource_group(self, resource_group): + response = self.client.elastic_sans.list_by_resource_group( resource_group_name=resource_group.name, - elastic_san_name="str", - api_version="2024-07-01-preview", ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_elastic_sans_list_by_subscription(self, resource_group): + response = self.client.elastic_sans.list_by_subscription() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_elastic_sans_list_by_elastic_san(self, resource_group): + response = self.client.elastic_sans.list_by_elastic_san( + resource_group_name=resource_group.name, + elastic_san_name="str", + ) + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt.py deleted file mode 100644 index c4be4fe06e8f..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmt(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_begin_restore_volume(self, resource_group): - response = self.client.begin_restore_volume( - resource_group_name=resource_group.name, - elastic_san_name="str", - volume_group_name="str", - volume_name="str", - api_version="2024-07-01-preview", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_async.py deleted file mode 100644 index 0d7645ee5bed..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_async.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_begin_restore_volume(self, resource_group): - response = await ( - await self.client.begin_restore_volume( - resource_group_name=resource_group.name, - elastic_san_name="str", - volume_group_name="str", - volume_name="str", - api_version="2024-07-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py deleted file mode 100644 index dcecbb54010f..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_private_link_resources_list_by_elastic_san(self, resource_group): - response = self.client.private_link_resources.list_by_elastic_san( - resource_group_name=resource_group.name, - elastic_san_name="str", - api_version="2024-07-01-preview", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py deleted file mode 100644 index 88cfbae89008..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_private_link_resources_list_by_elastic_san(self, resource_group): - response = await self.client.private_link_resources.list_by_elastic_san( - resource_group_name=resource_group.name, - elastic_san_name="str", - api_version="2024-07-01-preview", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_operations.py similarity index 72% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_operations.py index 621d5cd539b9..3eee208d5013 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,16 +14,14 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtOperations(AzureMgmtRecordedTestCase): +class TestElasticSanOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2024-07-01-preview", - ) + response = self.client.operations.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_operations_async.py similarity index 72% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_operations_async.py index 9837d715873d..20993b08d3f7 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,16 +15,14 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2024-07-01-preview", - ) + response = self.client.operations.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_private_endpoint_connections_operations.py similarity index 88% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_private_endpoint_connections_operations.py index 56b02a68184b..d63c80554941 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_private_endpoint_connections_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,9 +14,21 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): +class TestElasticSanPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + ) + + # please add some check logic here by yourself + # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy @@ -48,25 +60,11 @@ def test_private_endpoint_connections_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_private_endpoint_connections_get(self, resource_group): - response = self.client.private_endpoint_connections.get( - resource_group_name=resource_group.name, - elastic_san_name="str", - private_endpoint_connection_name="str", - api_version="2024-07-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_private_endpoint_connections_begin_delete(self, resource_group): @@ -74,7 +72,6 @@ def test_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, elastic_san_name="str", private_endpoint_connection_name="str", - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -86,7 +83,6 @@ def test_private_endpoint_connections_list(self, resource_group): response = self.client.private_endpoint_connections.list( resource_group_name=resource_group.name, elastic_san_name="str", - api_version="2024-07-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_private_endpoint_connections_operations_async.py similarity index 88% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_private_endpoint_connections_operations_async.py index 831fcb262d74..235200eae1bf 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_private_endpoint_connections_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,9 +15,21 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + ) + + # please add some check logic here by yourself + # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async @@ -50,26 +62,12 @@ async def test_private_endpoint_connections_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_private_endpoint_connections_get(self, resource_group): - response = await self.client.private_endpoint_connections.get( - resource_group_name=resource_group.name, - elastic_san_name="str", - private_endpoint_connection_name="str", - api_version="2024-07-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_private_endpoint_connections_begin_delete(self, resource_group): @@ -78,7 +76,6 @@ async def test_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, elastic_san_name="str", private_endpoint_connection_name="str", - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -91,7 +88,6 @@ async def test_private_endpoint_connections_list(self, resource_group): response = self.client.private_endpoint_connections.list( resource_group_name=resource_group.name, elastic_san_name="str", - api_version="2024-07-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_skus_operation_group_operations.py similarity index 69% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_skus_operation_group_operations.py index 7fb256c7afd5..b47daa1b226d 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_skus_operation_group_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,16 +14,14 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtSkusOperations(AzureMgmtRecordedTestCase): +class TestElasticSanSkusOperationGroupOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_skus_list(self, resource_group): - response = self.client.skus.list( - api_version="2024-07-01-preview", - ) + def test_skus_operation_group_list(self, resource_group): + response = self.client.skus_operation_group.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_skus_operation_group_operations_async.py similarity index 68% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_skus_operation_group_operations_async.py index 7b888e77d990..d8f04252fe5e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_skus_operation_group_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,16 +15,14 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtSkusOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanSkusOperationGroupOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_skus_list(self, resource_group): - response = self.client.skus.list( - api_version="2024-07-01-preview", - ) + async def test_skus_operation_group_list(self, resource_group): + response = self.client.skus_operation_group.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_snapshots_operations.py similarity index 74% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_snapshots_operations.py index 17dc7ee20ee5..4d1d4650b683 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_snapshots_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,27 +14,27 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtVolumeSnapshotsOperations(AzureMgmtRecordedTestCase): +class TestElasticSanSnapshotsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volume_snapshots_list_by_volume_group(self, resource_group): - response = self.client.volume_snapshots.list_by_volume_group( + def test_snapshots_get(self, resource_group): + response = self.client.snapshots.get( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - api_version="2024-07-01-preview", + snapshot_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volume_snapshots_begin_create(self, resource_group): - response = self.client.volume_snapshots.begin_create( + def test_snapshots_begin_create(self, resource_group): + response = self.client.snapshots.begin_create( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", @@ -58,7 +58,6 @@ def test_volume_snapshots_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -66,13 +65,12 @@ def test_volume_snapshots_begin_create(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volume_snapshots_begin_delete(self, resource_group): - response = self.client.volume_snapshots.begin_delete( + def test_snapshots_begin_delete(self, resource_group): + response = self.client.snapshots.begin_delete( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", snapshot_name="str", - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -80,14 +78,12 @@ def test_volume_snapshots_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volume_snapshots_get(self, resource_group): - response = self.client.volume_snapshots.get( + def test_snapshots_list_by_volume_group(self, resource_group): + response = self.client.snapshots.list_by_volume_group( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - snapshot_name="str", - api_version="2024-07-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_snapshots_operations_async.py similarity index 75% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_snapshots_operations_async.py index 03832c8ff7bd..ed4f824ead05 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_snapshots_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,28 +15,28 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtVolumeSnapshotsOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanSnapshotsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volume_snapshots_list_by_volume_group(self, resource_group): - response = self.client.volume_snapshots.list_by_volume_group( + async def test_snapshots_get(self, resource_group): + response = await self.client.snapshots.get( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - api_version="2024-07-01-preview", + snapshot_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volume_snapshots_begin_create(self, resource_group): + async def test_snapshots_begin_create(self, resource_group): response = await ( - await self.client.volume_snapshots.begin_create( + await self.client.snapshots.begin_create( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", @@ -60,7 +60,6 @@ async def test_volume_snapshots_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -69,14 +68,13 @@ async def test_volume_snapshots_begin_create(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volume_snapshots_begin_delete(self, resource_group): + async def test_snapshots_begin_delete(self, resource_group): response = await ( - await self.client.volume_snapshots.begin_delete( + await self.client.snapshots.begin_delete( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", snapshot_name="str", - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -85,14 +83,12 @@ async def test_volume_snapshots_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volume_snapshots_get(self, resource_group): - response = await self.client.volume_snapshots.get( + async def test_snapshots_list_by_volume_group(self, resource_group): + response = self.client.snapshots.list_by_volume_group( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - snapshot_name="str", - api_version="2024-07-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volume_groups_operations.py similarity index 83% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volume_groups_operations.py index 53597dcf0dcc..cf3bf0b242e7 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volume_groups_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,19 +14,19 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtVolumeGroupsOperations(AzureMgmtRecordedTestCase): +class TestElasticSanVolumeGroupsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volume_groups_list_by_elastic_san(self, resource_group): - response = self.client.volume_groups.list_by_elastic_san( + def test_volume_groups_get(self, resource_group): + response = self.client.volume_groups.get( resource_group_name=resource_group.name, elastic_san_name="str", - api_version="2024-07-01-preview", + volume_group_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -61,7 +61,7 @@ def test_volume_groups_begin_create(self, resource_group): }, }, "enforceDataIntegrityCheckForIscsi": bool, - "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "str"}]}, "privateEndpointConnections": [ { "properties": { @@ -100,7 +100,6 @@ def test_volume_groups_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -135,11 +134,10 @@ def test_volume_groups_begin_update(self, resource_group): }, }, "enforceDataIntegrityCheckForIscsi": bool, - "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "str"}]}, "protocolType": "str", }, }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -152,7 +150,6 @@ def test_volume_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -160,13 +157,37 @@ def test_volume_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volume_groups_get(self, resource_group): - response = self.client.volume_groups.get( + def test_volume_groups_list_by_elastic_san(self, resource_group): + response = self.client.volume_groups.list_by_elastic_san( resource_group_name=resource_group.name, elastic_san_name="str", - volume_group_name="str", - api_version="2024-07-01-preview", ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_volume_groups_begin_pre_backup(self, resource_group): + response = self.client.volume_groups.begin_pre_backup( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={"volumeNames": ["str"]}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_volume_groups_begin_pre_restore(self, resource_group): + response = self.client.volume_groups.begin_pre_restore( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={"diskSnapshotIds": ["str"]}, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volume_groups_operations_async.py similarity index 83% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volume_groups_operations_async.py index 18f9721671db..3af9809e76e4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volume_groups_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,19 +15,19 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtVolumeGroupsOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanVolumeGroupsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volume_groups_list_by_elastic_san(self, resource_group): - response = self.client.volume_groups.list_by_elastic_san( + async def test_volume_groups_get(self, resource_group): + response = await self.client.volume_groups.get( resource_group_name=resource_group.name, elastic_san_name="str", - api_version="2024-07-01-preview", + volume_group_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -63,7 +63,7 @@ async def test_volume_groups_begin_create(self, resource_group): }, }, "enforceDataIntegrityCheckForIscsi": bool, - "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "str"}]}, "privateEndpointConnections": [ { "properties": { @@ -102,7 +102,6 @@ async def test_volume_groups_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -139,11 +138,10 @@ async def test_volume_groups_begin_update(self, resource_group): }, }, "enforceDataIntegrityCheckForIscsi": bool, - "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "str"}]}, "protocolType": "str", }, }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -158,7 +156,6 @@ async def test_volume_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -167,13 +164,41 @@ async def test_volume_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volume_groups_get(self, resource_group): - response = await self.client.volume_groups.get( + async def test_volume_groups_list_by_elastic_san(self, resource_group): + response = self.client.volume_groups.list_by_elastic_san( resource_group_name=resource_group.name, elastic_san_name="str", - volume_group_name="str", - api_version="2024-07-01-preview", ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_volume_groups_begin_pre_backup(self, resource_group): + response = await ( + await self.client.volume_groups.begin_pre_backup( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={"volumeNames": ["str"]}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_volume_groups_begin_pre_restore(self, resource_group): + response = await ( + await self.client.volume_groups.begin_pre_restore( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={"diskSnapshotIds": ["str"]}, + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volumes_operations.py similarity index 78% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volumes_operations.py index 34a89a126ade..61960fc0552f 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volumes_operations.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan import ElasticSanMgmtClient +from azure.mgmt.elasticsan import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -14,9 +14,22 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtVolumesOperations(AzureMgmtRecordedTestCase): +class TestElasticSanVolumesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient) + self.client = self.create_mgmt_client(ElasticSanClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_volumes_get(self, resource_group): + response = self.client.volumes.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + ) + + # please add some check logic here by yourself + # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy @@ -53,7 +66,6 @@ def test_volumes_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -68,7 +80,6 @@ def test_volumes_begin_update(self, resource_group): volume_group_name="str", volume_name="str", parameters={"properties": {"managedBy": {"resourceId": "str"}, "sizeGiB": 0}}, - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -82,26 +93,11 @@ def test_volumes_begin_delete(self, resource_group): elastic_san_name="str", volume_group_name="str", volume_name="str", - api_version="2024-07-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_volumes_get(self, resource_group): - response = self.client.volumes.get( - resource_group_name=resource_group.name, - elastic_san_name="str", - volume_group_name="str", - volume_name="str", - api_version="2024-07-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_volumes_list_by_volume_group(self, resource_group): @@ -109,7 +105,6 @@ def test_volumes_list_by_volume_group(self, resource_group): resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - api_version="2024-07-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -117,27 +112,12 @@ def test_volumes_list_by_volume_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_volumes_begin_pre_backup(self, resource_group): - response = self.client.volumes.begin_pre_backup( - resource_group_name=resource_group.name, - elastic_san_name="str", - volume_group_name="str", - parameters={"volumeNames": ["str"]}, - api_version="2024-07-01-preview", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_volumes_begin_pre_restore(self, resource_group): - response = self.client.volumes.begin_pre_restore( + def test_volumes_begin_restore_volume(self, resource_group): + response = self.client.volumes.begin_restore_volume( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - parameters={"diskSnapshotIds": ["str"]}, - api_version="2024-07-01-preview", + volume_name="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volumes_operations_async.py similarity index 78% rename from sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py rename to sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volumes_operations_async.py index 794bc3a53470..435078fab743 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_volumes_operations_async.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient +from azure.mgmt.elasticsan.aio import ElasticSanClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -15,9 +15,22 @@ @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestElasticSanMgmtVolumesOperationsAsync(AzureMgmtRecordedTestCase): +class TestElasticSanVolumesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + self.client = self.create_mgmt_client(ElasticSanClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_volumes_get(self, resource_group): + response = await self.client.volumes.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + ) + + # please add some check logic here by yourself + # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async @@ -55,7 +68,6 @@ async def test_volumes_begin_create(self, resource_group): }, "type": "str", }, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -72,7 +84,6 @@ async def test_volumes_begin_update(self, resource_group): volume_group_name="str", volume_name="str", parameters={"properties": {"managedBy": {"resourceId": "str"}, "sizeGiB": 0}}, - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -88,27 +99,12 @@ async def test_volumes_begin_delete(self, resource_group): elastic_san_name="str", volume_group_name="str", volume_name="str", - api_version="2024-07-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_volumes_get(self, resource_group): - response = await self.client.volumes.get( - resource_group_name=resource_group.name, - elastic_san_name="str", - volume_group_name="str", - volume_name="str", - api_version="2024-07-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_volumes_list_by_volume_group(self, resource_group): @@ -116,7 +112,6 @@ async def test_volumes_list_by_volume_group(self, resource_group): resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - api_version="2024-07-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -124,30 +119,13 @@ async def test_volumes_list_by_volume_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_volumes_begin_pre_backup(self, resource_group): + async def test_volumes_begin_restore_volume(self, resource_group): response = await ( - await self.client.volumes.begin_pre_backup( + await self.client.volumes.begin_restore_volume( resource_group_name=resource_group.name, elastic_san_name="str", volume_group_name="str", - parameters={"volumeNames": ["str"]}, - api_version="2024-07-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_volumes_begin_pre_restore(self, resource_group): - response = await ( - await self.client.volumes.begin_pre_restore( - resource_group_name=resource_group.name, - elastic_san_name="str", - volume_group_name="str", - parameters={"diskSnapshotIds": ["str"]}, - api_version="2024-07-01-preview", + volume_name="str", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/setup.py b/sdk/elasticsan/azure-mgmt-elasticsan/setup.py index 69acc97b5482..fa3b6d111bce 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/setup.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/setup.py @@ -53,7 +53,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -77,7 +76,7 @@ "isodate>=0.6.1", "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/tsp-location.yaml b/sdk/elasticsan/azure-mgmt-elasticsan/tsp-location.yaml new file mode 100644 index 000000000000..c7ca598fc88f --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/elasticsan/ElasticSan.Management +commit: 0e8a60212052dc13f9d071cbc573dedf07234699 +repo: Azure/azure-rest-api-specs +additionalDirectories: