diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md b/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/LICENSE b/sdk/elasticsan/azure-mgmt-elasticsan/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +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. diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/MANIFEST.in b/sdk/elasticsan/azure-mgmt-elasticsan/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/README.md b/sdk/elasticsan/azure-mgmt-elasticsan/README.md new file mode 100644 index 000000000000..c8b043100417 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-elasticsan%2FREADME.png) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json new file mode 100644 index 000000000000..90f1276bd05c --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "7ceae55efa5da25900a74f798d8338b69be8ff74", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/elasticsan/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/elasticsan/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py new file mode 100644 index 000000000000..13665b19e96c --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py @@ -0,0 +1,18 @@ +# 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 ._elastic_san_management import ElasticSanManagement +from ._version import VERSION + +__version__ = VERSION +__all__ = ['ElasticSanManagement'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py new file mode 100644 index 000000000000..13b93d2b8209 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ElasticSanManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ElasticSanManagement. + + 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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-11-20-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: + super(ElasticSanManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + 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)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_management.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_management.py new file mode 100644 index 000000000000..ce2bc8174ece --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_management.py @@ -0,0 +1,109 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import ElasticSanManagementConfiguration +from .operations import ElasticSansOperations, Operations, SkusOperations, VolumeGroupsOperations, VolumesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ElasticSanManagement: + """ElasticSanManagement. + + :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 volume_groups: VolumeGroupsOperations operations + :vartype volume_groups: azure.mgmt.elasticsan.operations.VolumeGroupsOperations + :ivar volumes: VolumesOperations operations + :vartype volumes: azure.mgmt.elasticsan.operations.VolumesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-11-20-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 + ) -> None: + self._config = ElasticSanManagementConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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) + + + def _send_request( + self, + request: HttpRequest, + **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) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ElasticSanManagement + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_metadata.json b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_metadata.json new file mode 100644 index 000000000000..a4818f5c189c --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_metadata.json @@ -0,0 +1,106 @@ +{ + "chosen_version": "2021-11-20-preview", + "total_api_version_list": ["2021-11-20-preview"], + "client": { + "name": "ElasticSanManagement", + "filename": "_elastic_san_management", + "description": "ElasticSanManagement.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ElasticSanManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ElasticSanManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "skus": "SkusOperations", + "elastic_sans": "ElasticSansOperations", + "volume_groups": "VolumeGroupsOperations", + "volumes": "VolumesOperations" + } +} \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..4b727c72fd7a --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py @@ -0,0 +1,15 @@ +# 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 ._elastic_san_management import ElasticSanManagement +__all__ = ['ElasticSanManagement'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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 new file mode 100644 index 000000000000..719146a10967 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ElasticSanManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ElasticSanManagement. + + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-11-20-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: + super(ElasticSanManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + 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)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_management.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_management.py new file mode 100644 index 000000000000..360912c2bf64 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_management.py @@ -0,0 +1,106 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import ElasticSanManagementConfiguration +from .operations import ElasticSansOperations, Operations, SkusOperations, VolumeGroupsOperations, VolumesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ElasticSanManagement: + """ElasticSanManagement. + + :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 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 + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-11-20-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 + ) -> None: + self._config = ElasticSanManagementConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ElasticSanManagement": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) 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 new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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 new file mode 100644 index 000000000000..20f26ad46c67 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py @@ -0,0 +1,21 @@ +# 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 ._operations import Operations +from ._skus_operations import SkusOperations +from ._elastic_sans_operations import ElasticSansOperations +from ._volume_groups_operations import VolumeGroupsOperations +from ._volumes_operations import VolumesOperations + +__all__ = [ + 'Operations', + 'SkusOperations', + 'ElasticSansOperations', + 'VolumeGroupsOperations', + 'VolumesOperations', +] 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 new file mode 100644 index 000000000000..2f1a34d11fb6 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py @@ -0,0 +1,619 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._elastic_sans_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ElasticSansOperations: + """ElasticSansOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ElasticSanList"]: + """Gets a list of ElasticSans in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ElasticSanList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSanList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSanList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ElasticSanList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ElasticSanList"]: + """Gets a list of ElasticSan in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ElasticSanList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSanList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSanList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ElasticSanList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans"} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSan", + **kwargs: Any + ) -> "_models.ElasticSan": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ElasticSan') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSan", + **kwargs: Any + ) -> AsyncLROPoller["_models.ElasticSan"]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param parameters: Elastic San object. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSanUpdate", + **kwargs: Any + ) -> Optional["_models.ElasticSan"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ElasticSan"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ElasticSanUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSanUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.ElasticSan"]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param parameters: Elastic San object. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + 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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + force_delete_volume_groups: Optional[bool] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + force_delete_volume_groups=force_delete_volume_groups, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + force_delete_volume_groups: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param force_delete_volume_groups: Required if the San has associated Volume Groups. Default + value is None. + :type force_delete_volume_groups: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + force_delete_volume_groups=force_delete_volume_groups, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # 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. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ElasticSan, or the result of cls(response) + :rtype: ~azure.mgmt.elasticsan.models.ElasticSan + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # 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 new file mode 100644 index 000000000000..59941c088db9 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py @@ -0,0 +1,117 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ElasticSanOperationListResult"]: + """Gets a list of ElasticSan operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ElasticSanOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSanOperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSanOperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ElasticSanOperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ElasticSan/operations"} # 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 new file mode 100644 index 000000000000..cc8c31fb2053 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py @@ -0,0 +1,124 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SkusOperations: + """SkusOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SkuInformationList"]: + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SkuInformationList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.SkuInformationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuInformationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SkuInformationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ElasticSan/skus"} # type: ignore 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 new file mode 100644 index 000000000000..1020810f039d --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py @@ -0,0 +1,574 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._volume_groups_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_elastic_san_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VolumeGroupsOperations: + """VolumeGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_elastic_san( + self, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VolumeGroupList"]: + """List VolumeGroups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VolumeGroupList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.VolumeGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroupList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_elastic_san_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + template_url=self.list_by_elastic_san.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_elastic_san_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VolumeGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_elastic_san.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups"} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroup", + **kwargs: Any + ) -> "_models.VolumeGroup": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VolumeGroup') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroup", + **kwargs: Any + ) -> AsyncLROPoller["_models.VolumeGroup"]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param parameters: Volume Group object. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroupUpdate", + **kwargs: Any + ) -> Optional["_models.VolumeGroup"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VolumeGroup"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VolumeGroupUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroupUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.VolumeGroup"]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param parameters: Volume Group object. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + 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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + force_delete_volumes: Optional[bool] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + force_delete_volumes=force_delete_volumes, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + force_delete_volumes: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param force_delete_volumes: Required if the Volume Group has associated volumes. Default value + is None. + :type force_delete_volumes: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, + force_delete_volumes=force_delete_volumes, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # 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. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VolumeGroup, or the result of cls(response) + :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # 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 new file mode 100644 index 000000000000..4ac6d7d289ea --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py @@ -0,0 +1,594 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._volumes_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_volume_group_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VolumesOperations: + """VolumesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.Volume", + **kwargs: Any + ) -> "_models.Volume": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Volume') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + 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, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Volume', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('Volume', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.Volume", + **kwargs: Any + ) -> AsyncLROPoller["_models.Volume"]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :param parameters: Volume object. + :type parameters: ~azure.mgmt.elasticsan.models.Volume + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Volume or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.VolumeUpdate", + **kwargs: Any + ) -> Optional["_models.Volume"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Volume"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VolumeUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + 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, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Volume', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.VolumeUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.Volume"]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :param parameters: Volume object. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Volume or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + 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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + 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, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # 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. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Volume, or the result of cls(response) + :rtype: ~azure.mgmt.elasticsan.models.Volume + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Volume', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace + def list_by_volume_group( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VolumeList"]: + """List Volumes in a VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VolumeList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.VolumeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_volume_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + template_url=self.list_by_volume_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_volume_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VolumeList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_volume_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes"} # 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 new file mode 100644 index 000000000000..878fc395f289 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/__init__.py @@ -0,0 +1,93 @@ +# 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 ._models_py3 import ElasticSan +from ._models_py3 import ElasticSanList +from ._models_py3 import ElasticSanOperationDisplay +from ._models_py3 import ElasticSanOperationListResult +from ._models_py3 import ElasticSanRPOperation +from ._models_py3 import ElasticSanUpdate +from ._models_py3 import Error +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import IscsiTargetInfo +from ._models_py3 import NetworkRuleSet +from ._models_py3 import Resource +from ._models_py3 import ResourceTypeSku +from ._models_py3 import SanTierInfo +from ._models_py3 import Sku +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import SourceCreationData +from ._models_py3 import SystemData +from ._models_py3 import TargetCreationData +from ._models_py3 import TrackedResource +from ._models_py3 import VirtualNetworkRule +from ._models_py3 import Volume +from ._models_py3 import VolumeGroup +from ._models_py3 import VolumeGroupList +from ._models_py3 import VolumeGroupTierInfo +from ._models_py3 import VolumeGroupUpdate +from ._models_py3 import VolumeList +from ._models_py3 import VolumeTierInfo +from ._models_py3 import VolumeUpdate + + +from ._elastic_san_management_enums import ( + CreatedByType, + EncryptionType, + Name, + OperationalStatus, + ProvisioningStates, + State, + StorageTargetType, + Tier, + VolumeCreateOption, +) + +__all__ = [ + 'ElasticSan', + 'ElasticSanList', + 'ElasticSanOperationDisplay', + 'ElasticSanOperationListResult', + 'ElasticSanRPOperation', + 'ElasticSanUpdate', + 'Error', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'IscsiTargetInfo', + 'NetworkRuleSet', + 'Resource', + 'ResourceTypeSku', + 'SanTierInfo', + 'Sku', + 'SkuInformationList', + 'SkuLocationInfo', + 'SourceCreationData', + 'SystemData', + 'TargetCreationData', + 'TrackedResource', + 'VirtualNetworkRule', + 'Volume', + 'VolumeGroup', + 'VolumeGroupList', + 'VolumeGroupTierInfo', + 'VolumeGroupUpdate', + 'VolumeList', + 'VolumeTierInfo', + 'VolumeUpdate', + 'CreatedByType', + 'EncryptionType', + 'Name', + 'OperationalStatus', + 'ProvisioningStates', + 'State', + 'StorageTargetType', + 'Tier', + 'VolumeCreateOption', +] diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_management_enums.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_management_enums.py new file mode 100644 index 000000000000..eb1c6f9e0471 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_management_enums.py @@ -0,0 +1,109 @@ +# 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 enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of key used to encrypt the data of the disk. + """ + + #: Volume is encrypted at rest with Platform managed key. It is the default encryption type. This + #: is not a valid encryption type for disk encryption sets. + ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" + #: Volume is encrypted at rest with Customer managed key that can be changed and revoked by a + #: customer. + ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" + #: Volume is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed + #: and the other key is Platform managed. + ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" + +class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The sku name. + """ + + #: Standard locally redundant storage. + STANDARD_LRS = "Standard_LRS" + #: Premium locally redundant storage. + PREMIUM_LRS = "Premium_LRS" + #: Standard zone redundant storage. + STANDARD_ZRS = "Standard_ZRS" + +class OperationalStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Operational status of the resource. + """ + + INVALID = "Invalid" + UNKNOWN = "Unknown" + HEALTHY = "Healthy" + UNHEALTHY = "Unhealthy" + UPDATING = "Updating" + RUNNING = "Running" + STOPPED = "Stopped" + STOPPED_DEALLOCATED_ = "Stopped (deallocated)" + +class ProvisioningStates(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Provisioning state of the iSCSI Target. + """ + + INVALID = "Invalid" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PENDING = "Pending" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + +class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets the state of virtual network rule. + """ + + PROVISIONING = "provisioning" + DEPROVISIONING = "deprovisioning" + SUCCEEDED = "succeeded" + FAILED = "failed" + NETWORK_SOURCE_DELETED = "networkSourceDeleted" + +class StorageTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Storage Target type. + """ + + ISCSI = "Iscsi" + NONE = "None" + +class Tier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The sku tier. + """ + + #: Hero. + HERO = "Hero" + #: Satellite. + SATELLITE = "Satellite" + #: Hub. + HUB = "Hub" + +class VolumeCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This enumerates the possible sources of a volume creation. + """ + + NONE = "None" + FROM_VOLUME = "FromVolume" + FROM_DISK_SNAPSHOT = "FromDiskSnapshot" + EXPORT = "Export" 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 new file mode 100644 index 000000000000..2db5688f6bae --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py @@ -0,0 +1,1434 @@ +# 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 Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._elastic_san_management_enums import * + + +class Resource(msrest.serialization.Model): + """The resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource identifier. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar tags: A set of tags. Azure resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = tags + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource identifier. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar tags: A set of tags. Azure resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(tags=tags, **kwargs) + 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. + + :ivar id: Azure resource identifier. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar tags: A set of tags. Azure resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: Resource metadata required by ARM RPC. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar sku: resource sku. + :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. Possible values include: + "Invalid", "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar base_size_ti_b: Base size of the Elastic San appliance in TiB. + :vartype base_size_ti_b: long + :ivar extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. + :vartype extended_capacity_size_ti_b: long + :ivar total_volume_size_gi_b: Total size of the provisioned Volumes in GiB. + :vartype total_volume_size_gi_b: long + :ivar volume_group_count: Total number of volume groups in this Elastic San appliance. + :vartype volume_group_count: long + :ivar total_iops: Total Provisioned IOPS of the Elastic San appliance. + :vartype total_iops: long + :ivar total_m_bps: Total Provisioned MBps Elastic San appliance. + :vartype total_m_bps: long + :ivar provisioned_m_bps: Provisioned MBps Elastic San appliance. + :vartype provisioned_m_bps: long + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'total_volume_size_gi_b': {'readonly': True}, + 'volume_group_count': {'readonly': True}, + 'total_iops': {'readonly': True}, + 'total_m_bps': {'readonly': True}, + 'provisioned_m_bps': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'sku': {'key': 'properties.sku', 'type': 'Sku'}, + 'availability_zones': {'key': 'properties.availabilityZones', 'type': '[str]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'base_size_ti_b': {'key': 'properties.baseSizeTiB', 'type': 'long'}, + 'extended_capacity_size_ti_b': {'key': 'properties.extendedCapacitySizeTiB', 'type': 'long'}, + 'total_volume_size_gi_b': {'key': 'properties.totalVolumeSizeGiB', 'type': 'long'}, + 'volume_group_count': {'key': 'properties.volumeGroupCount', 'type': 'long'}, + 'total_iops': {'key': 'properties.totalIops', 'type': 'long'}, + 'total_m_bps': {'key': 'properties.totalMBps', 'type': 'long'}, + 'provisioned_m_bps': {'key': 'properties.provisionedMBps', 'type': 'long'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + sku: Optional["Sku"] = None, + availability_zones: Optional[List[str]] = None, + base_size_ti_b: Optional[int] = None, + extended_capacity_size_ti_b: Optional[int] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword sku: resource sku. + :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. + :paramtype base_size_ti_b: long + :keyword extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. + :paramtype extended_capacity_size_ti_b: long + """ + super(ElasticSan, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + 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.provisioned_m_bps = None + + +class ElasticSanList(msrest.serialization.Model): + """List of Elastic Sans. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. 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 = { + 'value': {'required': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ElasticSan]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["ElasticSan"], + **kwargs + ): + """ + :keyword value: Required. An array of Elastic San objects. + :paramtype value: list[~azure.mgmt.elasticsan.models.ElasticSan] + """ + super(ElasticSanList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ElasticSanOperationDisplay(msrest.serialization.Model): + """Metadata about an operation. + + All required parameters must be populated in order to send to Azure. + + :ivar provider: Required. Localized friendly form of the resource provider name. + :vartype provider: str + :ivar resource: Required. Localized friendly form of the resource type related to this + action/operation. + :vartype resource: str + :ivar operation: Required. Localized friendly name for the operation, as it should be shown to + the user. + :vartype operation: str + :ivar description: Required. Localized friendly description for the operation, as it should be + shown to the user. + :vartype description: str + """ + + _validation = { + 'provider': {'required': True}, + 'resource': {'required': True}, + 'operation': {'required': True}, + 'description': {'required': 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, + *, + provider: str, + resource: str, + operation: str, + description: str, + **kwargs + ): + """ + :keyword provider: Required. Localized friendly form of the resource provider name. + :paramtype provider: str + :keyword resource: Required. Localized friendly form of the resource type related to this + action/operation. + :paramtype resource: str + :keyword operation: Required. Localized friendly name for the operation, as it should be shown + to the user. + :paramtype operation: str + :keyword description: Required. Localized friendly description for the operation, as it should + be shown to the user. + :paramtype description: str + """ + super(ElasticSanOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ElasticSanOperationListResult(msrest.serialization.Model): + """List of operations supported by the RP. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. An array of operations supported by the ElasticSan RP. + :vartype value: list[~azure.mgmt.elasticsan.models.ElasticSanRPOperation] + :ivar next_link: URI to fetch the next section of the paginated response. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ElasticSanRPOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["ElasticSanRPOperation"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. An array of operations supported by the ElasticSan RP. + :paramtype value: list[~azure.mgmt.elasticsan.models.ElasticSanRPOperation] + :keyword next_link: URI to fetch the next section of the paginated response. + :paramtype next_link: str + """ + super(ElasticSanOperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ElasticSanRPOperation(msrest.serialization.Model): + """Description of a ElasticSan RP Operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the operation being performed on this particular object. + :vartype name: str + :ivar is_data_action: Indicates whether the operation applies to data-plane. + :vartype is_data_action: bool + :ivar display: Additional metadata about RP operation. + :vartype display: ~azure.mgmt.elasticsan.models.ElasticSanOperationDisplay + """ + + _validation = { + 'name': {'required': True}, + 'is_data_action': {'readonly': True}, + 'display': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'ElasticSanOperationDisplay'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. The name of the operation being performed on this particular object. + :paramtype name: str + """ + super(ElasticSanRPOperation, self).__init__(**kwargs) + self.name = name + self.is_data_action = None + self.display = None + + +class ElasticSanUpdate(msrest.serialization.Model): + """Response for ElasticSan update request. + + :ivar tags: A set of tags. Update tags. + :vartype tags: dict[str, str] + :ivar base_size_ti_b: Base size of the Elastic San appliance in TiB. + :vartype base_size_ti_b: long + :ivar extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. + :vartype extended_capacity_size_ti_b: long + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'base_size_ti_b': {'key': 'properties.baseSizeTiB', 'type': 'long'}, + 'extended_capacity_size_ti_b': {'key': 'properties.extendedCapacitySizeTiB', 'type': 'long'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + base_size_ti_b: Optional[int] = None, + extended_capacity_size_ti_b: Optional[int] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Update tags. + :paramtype tags: dict[str, str] + :keyword base_size_ti_b: Base size of the Elastic San appliance in TiB. + :paramtype base_size_ti_b: long + :keyword extended_capacity_size_ti_b: Extended size of the Elastic San appliance in TiB. + :paramtype extended_capacity_size_ti_b: long + """ + super(ElasticSanUpdate, self).__init__(**kwargs) + self.tags = tags + self.base_size_ti_b = base_size_ti_b + self.extended_capacity_size_ti_b = extended_capacity_size_ti_b + + +class Error(msrest.serialization.Model): + """The resource management error response. + + :ivar error: RP error response. + :vartype error: ~azure.mgmt.elasticsan.models.ErrorResponse + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + """ + :keyword error: RP error response. + :paramtype error: ~azure.mgmt.elasticsan.models.ErrorResponse + """ + super(Error, self).__init__(**kwargs) + self.error = error + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorResponse(msrest.serialization.Model): + """The resource management error response. + + 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.ErrorResponse] + :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': '[ErrorResponse]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class IscsiTargetInfo(msrest.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. Possible values include: + "Invalid", "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar status: Operational status of the iSCSI Target. Possible values include: "Invalid", + "Unknown", "Healthy", "Unhealthy", "Updating", "Running", "Stopped", "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, "OperationalStatus"]] = None, + **kwargs + ): + """ + :keyword status: Operational status of the iSCSI Target. Possible values include: "Invalid", + "Unknown", "Healthy", "Unhealthy", "Updating", "Running", "Stopped", "Stopped (deallocated)". + :paramtype status: str or ~azure.mgmt.elasticsan.models.OperationalStatus + """ + super(IscsiTargetInfo, self).__init__(**kwargs) + self.target_iqn = None + self.target_portal_hostname = None + self.target_portal_port = None + self.provisioning_state = None + self.status = status + + +class NetworkRuleSet(msrest.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["VirtualNetworkRule"]] = None, + **kwargs + ): + """ + :keyword virtual_network_rules: The list of virtual network rules. + :paramtype virtual_network_rules: list[~azure.mgmt.elasticsan.models.VirtualNetworkRule] + """ + super(NetworkRuleSet, self).__init__(**kwargs) + self.virtual_network_rules = virtual_network_rules + + +class ResourceTypeSku(msrest.serialization.Model): + """SkuInformation object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar sku: The Sku tier. + :vartype sku: ~azure.mgmt.elasticsan.models.Sku + :ivar location_info: Availability of the SKU for the location/zone. + :vartype location_info: list[~azure.mgmt.elasticsan.models.SkuLocationInfo] + :ivar san: Scalability targets for the San account for a given tier. + :vartype san: ~azure.mgmt.elasticsan.models.SanTierInfo + :ivar volume_group: Volume Group targets for the San account for a given tier. + :vartype volume_group: ~azure.mgmt.elasticsan.models.VolumeGroupTierInfo + :ivar volume: Volume targets for the San account for a given tier. + :vartype volume: ~azure.mgmt.elasticsan.models.VolumeTierInfo + """ + + _validation = { + 'location_info': {'readonly': True}, + } + + _attribute_map = { + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, + 'san': {'key': 'san', 'type': 'SanTierInfo'}, + 'volume_group': {'key': 'volumeGroup', 'type': 'VolumeGroupTierInfo'}, + 'volume': {'key': 'volume', 'type': 'VolumeTierInfo'}, + } + + def __init__( + self, + *, + sku: Optional["Sku"] = None, + san: Optional["SanTierInfo"] = None, + volume_group: Optional["VolumeGroupTierInfo"] = None, + volume: Optional["VolumeTierInfo"] = None, + **kwargs + ): + """ + :keyword sku: The Sku tier. + :paramtype sku: ~azure.mgmt.elasticsan.models.Sku + :keyword san: Scalability targets for the San account for a given tier. + :paramtype san: ~azure.mgmt.elasticsan.models.SanTierInfo + :keyword volume_group: Volume Group targets for the San account for a given tier. + :paramtype volume_group: ~azure.mgmt.elasticsan.models.VolumeGroupTierInfo + :keyword volume: Volume targets for the San account for a given tier. + :paramtype volume: ~azure.mgmt.elasticsan.models.VolumeTierInfo + """ + super(ResourceTypeSku, self).__init__(**kwargs) + self.sku = sku + self.location_info = None + self.san = san + self.volume_group = volume_group + self.volume = volume + + +class SanTierInfo(msrest.serialization.Model): + """San scalability target. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar max_size_ti_b: Maximum San account capacity in TiB. + :vartype max_size_ti_b: long + :ivar min_size_ti_b: Minimum San account capacity in TiB. + :vartype min_size_ti_b: long + :ivar min_increment_size_ti_b: Increment the San capacity in TiB. + :vartype min_increment_size_ti_b: long + :ivar iops_per_base_ti_b: Maximum IOPS per BaseTiB. + :vartype iops_per_base_ti_b: long + :ivar mbps_per_base_ti_b: Maximum MBps per BaseTiB. + :vartype mbps_per_base_ti_b: long + :ivar max_iops: Maximum IOPS. + :vartype max_iops: long + :ivar max_m_bps: Maximum MBps. + :vartype max_m_bps: long + :ivar max_volume_group_count: Maximum number of volume groups per San account. + :vartype max_volume_group_count: long + """ + + _validation = { + 'max_size_ti_b': {'readonly': True}, + 'min_size_ti_b': {'readonly': True}, + 'min_increment_size_ti_b': {'readonly': True}, + 'iops_per_base_ti_b': {'readonly': True}, + 'mbps_per_base_ti_b': {'readonly': True}, + 'max_iops': {'readonly': True}, + 'max_m_bps': {'readonly': True}, + 'max_volume_group_count': {'readonly': True}, + } + + _attribute_map = { + 'max_size_ti_b': {'key': 'maxSizeTiB', 'type': 'long'}, + 'min_size_ti_b': {'key': 'minSizeTiB', 'type': 'long'}, + 'min_increment_size_ti_b': {'key': 'minIncrementSizeTiB', 'type': 'long'}, + 'iops_per_base_ti_b': {'key': 'iopsPerBaseTiB', 'type': 'long'}, + 'mbps_per_base_ti_b': {'key': 'mbpsPerBaseTiB', 'type': 'long'}, + 'max_iops': {'key': 'maxIops', 'type': 'long'}, + 'max_m_bps': {'key': 'maxMBps', 'type': 'long'}, + 'max_volume_group_count': {'key': 'maxVolumeGroupCount', 'type': 'long'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(SanTierInfo, self).__init__(**kwargs) + self.max_size_ti_b = None + self.min_size_ti_b = None + self.min_increment_size_ti_b = None + self.iops_per_base_ti_b = None + self.mbps_per_base_ti_b = None + self.max_iops = None + self.max_m_bps = None + self.max_volume_group_count = None + + +class Sku(msrest.serialization.Model): + """The SKU name. Required for account creation; optional for update. + + :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + "Standard_ZRS". + :vartype name: str or ~azure.mgmt.elasticsan.models.Name + :ivar tier: The sku tier. Possible values include: "Hero", "Satellite", "Hub". + :vartype tier: str or ~azure.mgmt.elasticsan.models.Tier + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[Union[str, "Name"]] = None, + tier: Optional[Union[str, "Tier"]] = None, + **kwargs + ): + """ + :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + "Standard_ZRS". + :paramtype name: str or ~azure.mgmt.elasticsan.models.Name + :keyword tier: The sku tier. Possible values include: "Hero", "Satellite", "Hub". + :paramtype tier: str or ~azure.mgmt.elasticsan.models.Tier + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + + +class SkuInformationList(msrest.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.ResourceTypeSku] + :ivar next_link: Links to the next set of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(SkuInformationList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SkuLocationInfo(msrest.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 + ): + """ + """ + super(SkuLocationInfo, self).__init__(**kwargs) + self.location = None + self.zones = None + + +class SourceCreationData(msrest.serialization.Model): + """Data used when creating a disk. + + All required parameters must be populated in order to send to Azure. + + :ivar create_source: Required. This enumerates the possible sources of a volume creation. + Possible values include: "None", "FromVolume", "FromDiskSnapshot", "Export". + :vartype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption + :ivar source_uri: If createOption is Copy, this is the ARM id of the source snapshot or disk. + If createOption is Restore, this is the ARM-like id of the source disk restore point. + :vartype source_uri: str + """ + + _validation = { + 'create_source': {'required': True}, + } + + _attribute_map = { + 'create_source': {'key': 'createSource', 'type': 'str'}, + 'source_uri': {'key': 'sourceUri', 'type': 'str'}, + } + + def __init__( + self, + *, + create_source: Union[str, "VolumeCreateOption"], + source_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword create_source: Required. This enumerates the possible sources of a volume creation. + Possible values include: "None", "FromVolume", "FromDiskSnapshot", "Export". + :paramtype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption + :keyword source_uri: If createOption is Copy, this is the ARM id of the source snapshot or + disk. If createOption is Restore, this is the ARM-like id of the source disk restore point. + :paramtype source_uri: str + """ + super(SourceCreationData, self).__init__(**kwargs) + self.create_source = create_source + self.source_uri = source_uri + + +class SystemData(msrest.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. Possible values include: + "User", "Application", "ManagedIdentity", "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. Possible + values include: "User", "Application", "ManagedIdentity", "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, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "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. Possible + values include: "User", "Application", "ManagedIdentity", "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(SystemData, self).__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 TargetCreationData(msrest.serialization.Model): + """Data used when creating a disk. + + All required parameters must be populated in order to send to Azure. + + :ivar target_uri: Required. Target location for the source to be copied or exported. + :vartype target_uri: str + """ + + _validation = { + 'target_uri': {'required': True}, + } + + _attribute_map = { + 'target_uri': {'key': 'targetUri', 'type': 'str'}, + } + + def __init__( + self, + *, + target_uri: str, + **kwargs + ): + """ + :keyword target_uri: Required. Target location for the source to be copied or exported. + :paramtype target_uri: str + """ + super(TargetCreationData, self).__init__(**kwargs) + self.target_uri = target_uri + + +class VirtualNetworkRule(msrest.serialization.Model): + """Virtual Network rule. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + :vartype virtual_network_resource_id: str + :ivar action: The action of virtual network rule. The only acceptable values to pass in are + None and "Allow". The default value is "Allow". + :vartype action: str + :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :vartype state: str or ~azure.mgmt.elasticsan.models.State + """ + + _validation = { + 'virtual_network_resource_id': {'required': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + } + + def __init__( + self, + *, + virtual_network_resource_id: str, + action: Optional[str] = "Allow", + **kwargs + ): + """ + :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + :paramtype virtual_network_resource_id: str + :keyword action: The action of virtual network rule. The only acceptable values to pass in are + None and "Allow". The default value is "Allow". + :paramtype action: str + """ + super(VirtualNetworkRule, self).__init__(**kwargs) + self.virtual_network_resource_id = virtual_network_resource_id + self.action = action + self.state = None + + +class Volume(TrackedResource): + """Response for Volume request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource identifier. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar tags: A set of tags. Azure resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: Resource metadata required by ARM RPC. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :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. + :vartype size_gi_b: long + :ivar storage_target: Storage target information. + :vartype storage_target: ~azure.mgmt.elasticsan.models.IscsiTargetInfo + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'volume_id': {'readonly': True}, + 'storage_target': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'volume_id': {'key': 'properties.volumeId', 'type': 'str'}, + 'creation_data': {'key': 'properties.creationData', 'type': 'SourceCreationData'}, + 'size_gi_b': {'key': 'properties.sizeGiB', 'type': 'long'}, + 'storage_target': {'key': 'properties.storageTarget', 'type': 'IscsiTargetInfo'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + creation_data: Optional["SourceCreationData"] = None, + size_gi_b: Optional[int] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword creation_data: State of the operation on the resource. + :paramtype creation_data: ~azure.mgmt.elasticsan.models.SourceCreationData + :keyword size_gi_b: Volume size. + :paramtype size_gi_b: long + """ + super(Volume, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.volume_id = None + self.creation_data = creation_data + self.size_gi_b = size_gi_b + self.storage_target = None + + +class VolumeGroup(TrackedResource): + """Response for Volume Group request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource identifier. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar tags: A set of tags. Azure resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: Resource metadata required by ARM RPC. + :vartype system_data: ~azure.mgmt.elasticsan.models.SystemData + :ivar provisioning_state: State of the operation on the resource. Possible values include: + "Invalid", "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar protocol_type: Type of storage target. Possible values include: "Iscsi", "None". + :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :ivar encryption: Type of encryption. Possible values include: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + "EncryptionAtRestWithPlatformAndCustomerKeys". + :vartype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType + :ivar network_acls: A collection of rules governing the accessibility from specific network + locations. + :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'protocol_type': {'key': 'properties.protocolType', 'type': 'str'}, + 'encryption': {'key': 'properties.encryption', 'type': 'str'}, + 'network_acls': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + protocol_type: Optional[Union[str, "StorageTargetType"]] = None, + encryption: Optional[Union[str, "EncryptionType"]] = None, + network_acls: Optional["NetworkRuleSet"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword protocol_type: Type of storage target. Possible values include: "Iscsi", "None". + :paramtype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :keyword encryption: Type of encryption. Possible values include: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + "EncryptionAtRestWithPlatformAndCustomerKeys". + :paramtype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType + :keyword network_acls: A collection of rules governing the accessibility from specific network + locations. + :paramtype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + """ + super(VolumeGroup, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.provisioning_state = None + self.protocol_type = protocol_type + self.encryption = encryption + self.network_acls = network_acls + + +class VolumeGroupList(msrest.serialization.Model): + """List of Volume Groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. 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 = { + 'value': {'required': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VolumeGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["VolumeGroup"], + **kwargs + ): + """ + :keyword value: Required. An array of Volume Groups objects. + :paramtype value: list[~azure.mgmt.elasticsan.models.VolumeGroup] + """ + super(VolumeGroupList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class VolumeGroupTierInfo(msrest.serialization.Model): + """Volume Group scalability target. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar max_volume_count: Maximum number of Volumes per Volume Groups per San account. + :vartype max_volume_count: long + """ + + _validation = { + 'max_volume_count': {'readonly': True}, + } + + _attribute_map = { + 'max_volume_count': {'key': 'maxVolumeCount', 'type': 'long'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(VolumeGroupTierInfo, self).__init__(**kwargs) + self.max_volume_count = None + + +class VolumeGroupUpdate(msrest.serialization.Model): + """Volume Group request. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar protocol_type: Type of storage target. Possible values include: "Iscsi", "None". + :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :ivar encryption: Type of encryption. Possible values include: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + "EncryptionAtRestWithPlatformAndCustomerKeys". + :vartype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType + :ivar network_acls: A collection of rules governing the accessibility from specific network + locations. + :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'protocol_type': {'key': 'properties.protocolType', 'type': 'str'}, + 'encryption': {'key': 'properties.encryption', 'type': 'str'}, + 'network_acls': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + protocol_type: Optional[Union[str, "StorageTargetType"]] = None, + encryption: Optional[Union[str, "EncryptionType"]] = None, + network_acls: Optional["NetworkRuleSet"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword protocol_type: Type of storage target. Possible values include: "Iscsi", "None". + :paramtype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :keyword encryption: Type of encryption. Possible values include: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + "EncryptionAtRestWithPlatformAndCustomerKeys". + :paramtype encryption: str or ~azure.mgmt.elasticsan.models.EncryptionType + :keyword network_acls: A collection of rules governing the accessibility from specific network + locations. + :paramtype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + """ + super(VolumeGroupUpdate, self).__init__(**kwargs) + self.tags = tags + self.protocol_type = protocol_type + self.encryption = encryption + self.network_acls = network_acls + + +class VolumeList(msrest.serialization.Model): + """List of Volumes. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. 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 = { + 'value': {'required': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Volume]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["Volume"], + **kwargs + ): + """ + :keyword value: Required. An array of Volume objects. + :paramtype value: list[~azure.mgmt.elasticsan.models.Volume] + """ + super(VolumeList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class VolumeTierInfo(msrest.serialization.Model): + """Volume scalability target. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar max_size_gi_b: Maximum volume capacity in GiB. + :vartype max_size_gi_b: long + :ivar min_size_gi_b: Minimum volume capacity in GiB. + :vartype min_size_gi_b: long + :ivar min_increment_size_gi_b: Increment volume capacity in GiB. + :vartype min_increment_size_gi_b: long + :ivar max_iops_per_gi_b: Maximum IOPS per GiB. + :vartype max_iops_per_gi_b: long + :ivar max_m_bps_per_gi_b: Maximum MBps. + :vartype max_m_bps_per_gi_b: long + :ivar max_iops: Maximum IOPS. + :vartype max_iops: long + :ivar max_m_bps: Maximum MBps. + :vartype max_m_bps: long + :ivar max_connected_client_count: Maximum number of connected clients count per Volume. + :vartype max_connected_client_count: long + """ + + _validation = { + 'max_size_gi_b': {'readonly': True}, + 'min_size_gi_b': {'readonly': True}, + 'min_increment_size_gi_b': {'readonly': True}, + 'max_iops_per_gi_b': {'readonly': True}, + 'max_m_bps_per_gi_b': {'readonly': True}, + 'max_iops': {'readonly': True}, + 'max_m_bps': {'readonly': True}, + 'max_connected_client_count': {'readonly': True}, + } + + _attribute_map = { + 'max_size_gi_b': {'key': 'maxSizeGiB', 'type': 'long'}, + 'min_size_gi_b': {'key': 'minSizeGiB', 'type': 'long'}, + 'min_increment_size_gi_b': {'key': 'minIncrementSizeGiB', 'type': 'long'}, + 'max_iops_per_gi_b': {'key': 'maxIopsPerGiB', 'type': 'long'}, + 'max_m_bps_per_gi_b': {'key': 'maxMBpsPerGiB', 'type': 'long'}, + 'max_iops': {'key': 'maxIops', 'type': 'long'}, + 'max_m_bps': {'key': 'maxMBps', 'type': 'long'}, + 'max_connected_client_count': {'key': 'maxConnectedClientCount', 'type': 'long'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(VolumeTierInfo, self).__init__(**kwargs) + self.max_size_gi_b = None + self.min_size_gi_b = None + self.min_increment_size_gi_b = None + self.max_iops_per_gi_b = None + self.max_m_bps_per_gi_b = None + self.max_iops = None + self.max_m_bps = None + self.max_connected_client_count = None + + +class VolumeUpdate(msrest.serialization.Model): + """Response for Volume request. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar size_gi_b: Volume size. + :vartype size_gi_b: long + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'size_gi_b': {'key': 'properties.sizeGiB', 'type': 'long'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + size_gi_b: Optional[int] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword size_gi_b: Volume size. + :paramtype size_gi_b: long + """ + super(VolumeUpdate, self).__init__(**kwargs) + self.tags = tags + self.size_gi_b = size_gi_b 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 new file mode 100644 index 000000000000..20f26ad46c67 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py @@ -0,0 +1,21 @@ +# 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 ._operations import Operations +from ._skus_operations import SkusOperations +from ._elastic_sans_operations import ElasticSansOperations +from ._volume_groups_operations import VolumeGroupsOperations +from ._volumes_operations import VolumesOperations + +__all__ = [ + 'Operations', + 'SkusOperations', + 'ElasticSansOperations', + 'VolumeGroupsOperations', + 'VolumesOperations', +] 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 new file mode 100644 index 000000000000..6a5781be0d38 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py @@ -0,0 +1,850 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + *, + force_delete_volume_groups: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if force_delete_volume_groups is not None: + _header_parameters['x-ms-delete-volumegroups'] = _SERIALIZER.header("force_delete_volume_groups", force_delete_volume_groups, 'bool') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class ElasticSansOperations(object): + """ElasticSansOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.ElasticSanList"]: + """Gets a list of ElasticSans in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ElasticSanList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSanList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSanList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ElasticSanList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ElasticSanList"]: + """Gets a list of ElasticSan in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ElasticSanList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSanList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSanList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ElasticSanList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans"} # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSan", + **kwargs: Any + ) -> "_models.ElasticSan": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ElasticSan') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSan", + **kwargs: Any + ) -> LROPoller["_models.ElasticSan"]: + """Create ElasticSan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param parameters: Elastic San object. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSanUpdate", + **kwargs: Any + ) -> Optional["_models.ElasticSan"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ElasticSan"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ElasticSanUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + parameters: "_models.ElasticSanUpdate", + **kwargs: Any + ) -> LROPoller["_models.ElasticSan"]: + """Update a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param parameters: Elastic San object. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + 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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + force_delete_volume_groups: Optional[bool] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + force_delete_volume_groups=force_delete_volume_groups, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + force_delete_volume_groups: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a Elastic San. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param force_delete_volume_groups: Required if the San has associated Volume Groups. Default + value is None. + :type force_delete_volume_groups: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + force_delete_volume_groups=force_delete_volume_groups, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # 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. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ElasticSan, or the result of cls(response) + :rtype: ~azure.mgmt.elasticsan.models.ElasticSan + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ElasticSan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}"} # 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 new file mode 100644 index 000000000000..9c73bd2964d0 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py @@ -0,0 +1,146 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ElasticSan/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.ElasticSanOperationListResult"]: + """Gets a list of ElasticSan operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ElasticSanOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSanOperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ElasticSanOperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ElasticSanOperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ElasticSan/operations"} # 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 new file mode 100644 index 000000000000..3a6f0b3fc915 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py @@ -0,0 +1,156 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ElasticSan/skus") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class SkusOperations(object): + """SkusOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SkuInformationList"]: + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SkuInformationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.SkuInformationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuInformationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SkuInformationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ElasticSan/skus"} # type: ignore 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 new file mode 100644 index 000000000000..f5eb3f552d58 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py @@ -0,0 +1,785 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + force_delete_volumes: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if force_delete_volumes is not None: + _header_parameters['x-ms-delete-volumes'] = _SERIALIZER.header("force_delete_volumes", force_delete_volumes, 'bool') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class VolumeGroupsOperations(object): + """VolumeGroupsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_elastic_san( + self, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any + ) -> Iterable["_models.VolumeGroupList"]: + """List VolumeGroups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VolumeGroupList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.VolumeGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroupList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_elastic_san_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + template_url=self.list_by_elastic_san.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_elastic_san_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VolumeGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_elastic_san.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups"} # type: ignore + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroup", + **kwargs: Any + ) -> "_models.VolumeGroup": + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VolumeGroup') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroup", + **kwargs: Any + ) -> LROPoller["_models.VolumeGroup"]: + """Create a Volume Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param parameters: Volume Group object. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either VolumeGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroupUpdate", + **kwargs: Any + ) -> Optional["_models.VolumeGroup"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VolumeGroup"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VolumeGroupUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + parameters: "_models.VolumeGroupUpdate", + **kwargs: Any + ) -> LROPoller["_models.VolumeGroup"]: + """Update an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param parameters: Volume Group object. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either VolumeGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + 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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + force_delete_volumes: Optional[bool] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + force_delete_volumes=force_delete_volumes, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + force_delete_volumes: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete an VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param force_delete_volumes: Required if the Volume Group has associated volumes. Default value + is None. + :type force_delete_volumes: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, + force_delete_volumes=force_delete_volumes, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # 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. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VolumeGroup, or the result of cls(response) + :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VolumeGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}"} # 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 new file mode 100644 index 000000000000..bb3e3a81c945 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py @@ -0,0 +1,809 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_volume_group_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + 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, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + "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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class VolumesOperations(object): + """VolumesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.elasticsan.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.Volume", + **kwargs: Any + ) -> "_models.Volume": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Volume') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + 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, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Volume', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('Volume', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.Volume", + **kwargs: Any + ) -> LROPoller["_models.Volume"]: + """Create a Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :param parameters: Volume object. + :type parameters: ~azure.mgmt.elasticsan.models.Volume + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Volume or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.VolumeUpdate", + **kwargs: Any + ) -> Optional["_models.Volume"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Volume"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VolumeUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + 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, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Volume', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: "_models.VolumeUpdate", + **kwargs: Any + ) -> LROPoller["_models.Volume"]: + """Update an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :param parameters: Volume object. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Volume or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + 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, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + 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, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete an Volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # 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. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :param volume_name: The name of the Volume. + :type volume_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Volume, or the result of cls(response) + :rtype: ~azure.mgmt.elasticsan.models.Volume + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Volume"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Volume', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"} # type: ignore + + + @distributed_trace + def list_by_volume_group( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VolumeList"]: + """List Volumes in a VolumeGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param elastic_san_name: The name of the ElasticSan. + :type elastic_san_name: str + :param volume_group_name: The name of the VolumeGroup. + :type volume_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VolumeList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.VolumeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-20-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.VolumeList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_volume_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + template_url=self.list_by_volume_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_volume_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VolumeList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_volume_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes"} # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/py.typed b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/sdk_packaging.toml b/sdk/elasticsan/azure-mgmt-elasticsan/sdk_packaging.toml new file mode 100644 index 000000000000..b228e678fca3 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-elasticsan" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/setup.py b/sdk/elasticsan/azure-mgmt-elasticsan/setup.py new file mode 100644 index 000000000000..2247e7d85ad7 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/setup.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-elasticsan" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/elasticsan/ci.yml b/sdk/elasticsan/ci.yml new file mode 100644 index 000000000000..47d96c63c546 --- /dev/null +++ b/sdk/elasticsan/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/elasticsan/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/elasticsan/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: elasticsan + Artifacts: + - name: azure-mgmt-elasticsan + safeName: azuremgmtelasticsan