From 918025a922d093b6368bba8e5fe29879da8ee70c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 5 Aug 2022 10:43:05 +0000 Subject: [PATCH] CodeGen from PR 20128 in Azure/azure-rest-api-specs Merge f71f471ade38b4eb27698d543a3d7d7c9480934b into 2feaf7f24cc26a7274c9fd79015ae62b1d273986 --- .../azure-mgmt-elasticsan/CHANGELOG.md | 5 + sdk/elasticsan/azure-mgmt-elasticsan/LICENSE | 21 + .../azure-mgmt-elasticsan/MANIFEST.in | 7 + .../azure-mgmt-elasticsan/README.md | 30 + .../azure-mgmt-elasticsan/_meta.json | 11 + .../azure-mgmt-elasticsan/azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/elasticsan/__init__.py | 23 + .../azure/mgmt/elasticsan/_configuration.py | 73 + .../elasticsan/_elastic_san_management.py | 119 ++ .../azure/mgmt/elasticsan/_patch.py | 19 + .../azure/mgmt/elasticsan/_vendor.py | 27 + .../azure/mgmt/elasticsan/_version.py | 9 + .../azure/mgmt/elasticsan/aio/__init__.py | 20 + .../mgmt/elasticsan/aio/_configuration.py | 72 + .../elasticsan/aio/_elastic_san_management.py | 116 ++ .../azure/mgmt/elasticsan/aio/_patch.py | 19 + .../elasticsan/aio/operations/__init__.py | 26 + .../operations/_elastic_sans_operations.py | 676 ++++++++ .../elasticsan/aio/operations/_operations.py | 123 ++ .../mgmt/elasticsan/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 130 ++ .../operations/_volume_groups_operations.py | 624 ++++++++ .../aio/operations/_volumes_operations.py | 651 ++++++++ .../azure/mgmt/elasticsan/models/__init__.py | 93 ++ .../models/_elastic_san_management_enums.py | 86 ++ .../mgmt/elasticsan/models/_models_py3.py | 1372 +++++++++++++++++ .../azure/mgmt/elasticsan/models/_patch.py | 19 + .../mgmt/elasticsan/operations/__init__.py | 26 + .../operations/_elastic_sans_operations.py | 908 +++++++++++ .../mgmt/elasticsan/operations/_operations.py | 153 ++ .../mgmt/elasticsan/operations/_patch.py | 19 + .../elasticsan/operations/_skus_operations.py | 163 ++ .../operations/_volume_groups_operations.py | 835 ++++++++++ .../operations/_volumes_operations.py | 870 +++++++++++ .../azure/mgmt/elasticsan/py.typed | 1 + .../azure-mgmt-elasticsan/sdk_packaging.toml | 9 + sdk/elasticsan/azure-mgmt-elasticsan/setup.py | 77 + sdk/elasticsan/ci.yml | 33 + 39 files changed, 7486 insertions(+) create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/LICENSE create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/MANIFEST.in create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/README.md create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/_meta.json create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_management.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_management.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_management_enums.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/py.typed create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/sdk_packaging.toml create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/setup.py create mode 100644 sdk/elasticsan/ci.yml 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..46aca029009e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/MANIFEST.in @@ -0,0 +1,7 @@ +include _meta.json +recursive-include tests *.py *.json +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/elasticsan/py.typed diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/README.md b/sdk/elasticsan/azure-mgmt-elasticsan/README.md new file mode 100644 index 000000000000..0d1b155a7df9 --- /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.7+. +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..5004f0fa4fe5 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "7a615081fe5dd4c6d07832f84520896cea417431", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/elasticsan/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.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..8ef8e42f85c9 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/__init__.py @@ -0,0 +1,23 @@ +# 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 + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ElasticSanManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..873c0bc8dc71 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_management.py @@ -0,0 +1,119 @@ +# 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/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..a9b532851bcf --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/__init__.py @@ -0,0 +1,20 @@ +# 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 + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ElasticSanManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..d72c11a0df9b --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_management.py @@ -0,0 +1,116 @@ +# 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..0ad201a8c586 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..76d9b022f202 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/__init__.py @@ -0,0 +1,26 @@ +# 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 + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Operations', + 'SkusOperations', + 'ElasticSansOperations', + 'VolumeGroupsOperations', + 'VolumesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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..fc28eb3232be --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py @@ -0,0 +1,676 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanManagement`'s + :attr:`elastic_sans` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if 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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ElasticSan]] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, + **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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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 = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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..e31ac4644f98 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py @@ -0,0 +1,123 @@ +# 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanManagement`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..4c605341d63e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py @@ -0,0 +1,130 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanManagement`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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..e90e20c1a7bb --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py @@ -0,0 +1,624 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanManagement`'s + :attr:`volume_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_elastic_san( + self, + resource_group_name: str, + elastic_san_name: str, + **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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if 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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VolumeGroup]] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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, + **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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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 = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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..c065cdee9d9b --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py @@ -0,0 +1,651 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.aio.ElasticSanManagement`'s + :attr:`volumes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: _models.Volume, + **kwargs: Any + ) -> _models.Volume: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if 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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Volume]] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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 = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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..6c95bdfe9421 --- /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 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, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ElasticSan', + 'ElasticSanList', + 'ElasticSanOperationDisplay', + 'ElasticSanOperationListResult', + 'ElasticSanRPOperation', + 'ElasticSanUpdate', + 'Error', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'IscsiTargetInfo', + 'NetworkRuleSet', + 'Resource', + 'ResourceTypeSku', + 'SanTierInfo', + 'Sku', + 'SkuInformationList', + 'SkuLocationInfo', + 'SourceCreationData', + 'SystemData', + 'TrackedResource', + 'VirtualNetworkRule', + 'Volume', + 'VolumeGroup', + 'VolumeGroupList', + 'VolumeGroupTierInfo', + 'VolumeGroupUpdate', + 'VolumeList', + 'VolumeTierInfo', + 'VolumeUpdate', + 'CreatedByType', + 'EncryptionType', + 'Name', + 'OperationalStatus', + 'ProvisioningStates', + 'State', + 'StorageTargetType', + 'Tier', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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..a94657383210 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_management_enums.py @@ -0,0 +1,86 @@ +# 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 azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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. + ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" + +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sku name. + """ + + #: Premium locally redundant storage. + PREMIUM_LRS = "Premium_LRS" + #: Premium zone redundant storage. + PREMIUM_ZRS = "Premium_ZRS" + +class OperationalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the iSCSI Target. + """ + + INVALID = "Invalid" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PENDING = "Pending" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the state of virtual network rule. + """ + + PROVISIONING = "provisioning" + DEPROVISIONING = "deprovisioning" + SUCCEEDED = "succeeded" + FAILED = "failed" + NETWORK_SOURCE_DELETED = "networkSourceDeleted" + +class StorageTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage Target type. + """ + + ISCSI = "Iscsi" + NONE = "None" + +class Tier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sku tier. + """ + + #: Premium Tier. + PREMIUM = "Premium" 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..7945c2136ff8 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py @@ -0,0 +1,1372 @@ +# 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, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +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. + + All required parameters must be populated in order to send to Azure. + + :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: Required. 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. Known values are: "Invalid", + "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.elasticsan.models.ProvisioningStates + :ivar base_size_ti_b: Required. Base size of the Elastic San appliance in TiB. + :vartype base_size_ti_b: long + :ivar extended_capacity_size_ti_b: Required. 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 total_size_ti_b: Total size of the Elastic San appliance in TB. + :vartype total_size_ti_b: long + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'sku': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'base_size_ti_b': {'required': True}, + 'extended_capacity_size_ti_b': {'required': True}, + 'total_volume_size_gi_b': {'readonly': True}, + 'volume_group_count': {'readonly': True}, + 'total_iops': {'readonly': True}, + 'total_m_bps': {'readonly': True}, + 'total_size_ti_b': {'readonly': True}, + } + + _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'}, + 'total_size_ti_b': {'key': 'properties.totalSizeTiB', 'type': 'long'}, + } + + def __init__( + self, + *, + sku: "_models.Sku", + base_size_ti_b: int, + extended_capacity_size_ti_b: int, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + availability_zones: Optional[List[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 + :keyword sku: Required. 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: Required. Base size of the Elastic San appliance in TiB. + :paramtype base_size_ti_b: long + :keyword extended_capacity_size_ti_b: Required. 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.total_size_ti_b = 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["_models.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["_models.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["_models.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. Known values are: "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. Known values are: "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, "_models.OperationalStatus"]] = None, + **kwargs + ): + """ + :keyword status: Operational status of the iSCSI Target. Known values are: "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["_models.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: list[~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 elastic_san: Scalability targets for the San account for a given tier. + :vartype elastic_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 = { + 'sku': {'readonly': True}, + 'location_info': {'readonly': True}, + } + + _attribute_map = { + 'sku': {'key': 'sku', 'type': '[Sku]'}, + 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, + 'elastic_san': {'key': 'elasticSan', 'type': 'SanTierInfo'}, + 'volume_group': {'key': 'volumeGroup', 'type': 'VolumeGroupTierInfo'}, + 'volume': {'key': 'volume', 'type': 'VolumeTierInfo'}, + } + + def __init__( + self, + *, + elastic_san: Optional["_models.SanTierInfo"] = None, + volume_group: Optional["_models.VolumeGroupTierInfo"] = None, + volume: Optional["_models.VolumeTierInfo"] = None, + **kwargs + ): + """ + :keyword elastic_san: Scalability targets for the San account for a given tier. + :paramtype elastic_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 = None + self.location_info = None + self.elastic_san = elastic_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_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_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_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_m_bps = None + self.max_volume_group_count = None + + +class Sku(msrest.serialization.Model): + """The SKU name. Required for account creation; optional for update. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The sku name. Known values are: "Premium_LRS", "Premium_ZRS". + :vartype name: str or ~azure.mgmt.elasticsan.models.Name + :ivar tier: The sku tier. Known values are: "Premium". + :vartype tier: str or ~azure.mgmt.elasticsan.models.Tier + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.Name"], + tier: Optional[Union[str, "_models.Tier"]] = None, + **kwargs + ): + """ + :keyword name: Required. The sku name. Known values are: "Premium_LRS", "Premium_ZRS". + :paramtype name: str or ~azure.mgmt.elasticsan.models.Name + :keyword tier: The sku tier. Known values are: "Premium". + :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 source used when creating the volume. + + :ivar create_source: This enumerates the possible sources of a volume creation. The only + acceptable values to pass in are None and "None". The default value is None. + :vartype create_source: str + :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 + """ + + _attribute_map = { + 'create_source': {'key': 'createSource', 'type': 'str'}, + 'source_uri': {'key': 'sourceUri', 'type': 'str'}, + } + + def __init__( + self, + *, + create_source: Optional[str] = None, + source_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword create_source: This enumerates the possible sources of a volume creation. The only + acceptable values to pass in are None and "None". The default value is None. + :paramtype create_source: str + :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. Known values are: + "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. Known values + are: "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, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.elasticsan.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "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 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. Known values are: "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(Resource): + """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 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}'}, + '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, + creation_data: Optional["_models.SourceCreationData"] = None, + size_gi_b: Optional[int] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, 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, **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(Resource): + """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 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. Known values are: "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. Known values are: "Iscsi", "None". + :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :ivar encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey". + :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}'}, + '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, + protocol_type: Optional[Union[str, "_models.StorageTargetType"]] = None, + encryption: Optional[Union[str, "_models.EncryptionType"]] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Azure resource tags. + :paramtype tags: dict[str, str] + :keyword protocol_type: Type of storage target. Known values are: "Iscsi", "None". + :paramtype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :keyword encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey". + :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, **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["_models.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. Known values are: "Iscsi", "None". + :vartype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :ivar encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey". + :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, "_models.StorageTargetType"]] = None, + encryption: Optional[Union[str, "_models.EncryptionType"]] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword protocol_type: Type of storage target. Known values are: "Iscsi", "None". + :paramtype protocol_type: str or ~azure.mgmt.elasticsan.models.StorageTargetType + :keyword encryption: Type of encryption. Known values are: "EncryptionAtRestWithPlatformKey". + :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["_models.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 iops_per_base_gi_b: Maximum IOPS per GiB. + :vartype iops_per_base_gi_b: long + :ivar max_iops: Maximum IOPS. + :vartype max_iops: long + :ivar max_m_bps: Maximum MBps. + :vartype max_m_bps: long + """ + + _validation = { + 'max_size_gi_b': {'readonly': True}, + 'min_size_gi_b': {'readonly': True}, + 'min_increment_size_gi_b': {'readonly': True}, + 'iops_per_base_gi_b': {'readonly': True}, + 'max_iops': {'readonly': True}, + 'max_m_bps': {'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'}, + 'iops_per_base_gi_b': {'key': 'iopsPerBaseGiB', 'type': 'long'}, + 'max_iops': {'key': 'maxIops', 'type': 'long'}, + 'max_m_bps': {'key': 'maxMBps', '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.iops_per_base_gi_b = None + self.max_iops = None + self.max_m_bps = 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/models/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..76d9b022f202 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/__init__.py @@ -0,0 +1,26 @@ +# 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 + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Operations', + 'SkusOperations', + 'ElasticSansOperations', + 'VolumeGroupsOperations', + 'VolumesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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..3d3b8d7ac59e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py @@ -0,0 +1,908 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]*[0-9A-Za-z]$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + *, + json: Optional[_models.ElasticSan] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + *, + json: Optional[_models.ElasticSanUpdate] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ElasticSansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanManagement`'s + :attr:`elastic_sans` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if 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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.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]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ElasticSan]] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ElasticSan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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, + **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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ElasticSan] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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..5a51e009b645 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py @@ -0,0 +1,153 @@ +# 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.core.utils import case_insensitive_dict +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ElasticSan/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanManagement`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + **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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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/_patch.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..a69f02cb6f3f --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py @@ -0,0 +1,163 @@ +# 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.core.utils import case_insensitive_dict +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ElasticSan/skus") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanManagement`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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..475578050ddd --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py @@ -0,0 +1,835 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_elastic_san_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + *, + json: Optional[_models.VolumeGroup] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + 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: Optional[_models.VolumeGroupUpdate] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + 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, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VolumeGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanManagement`'s + :attr:`volume_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_elastic_san( + self, + resource_group_name: str, + elastic_san_name: str, + **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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if 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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.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]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VolumeGroup]] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VolumeGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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, + **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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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 = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VolumeGroup] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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..b27d666ef2d1 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py @@ -0,0 +1,870 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + *, + json: Optional[_models.Volume] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + 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: Optional[_models.VolumeUpdate] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + 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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_volume_group_request( + subscription_id: str, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VolumesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elasticsan.ElasticSanManagement`'s + :attr:`volumes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + def _create_initial( + self, + resource_group_name: str, + elastic_san_name: str, + volume_group_name: str, + volume_name: str, + parameters: _models.Volume, + **kwargs: Any + ) -> _models.Volume: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if 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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.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]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Volume]] + + _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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('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 + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Volume', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_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: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + elastic_san_name=elastic_san_name, + volume_group_name=volume_group_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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 = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-20-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Volume] + + + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.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', {}) or {}) + 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'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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..f3ac7d6ebd7e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/setup.py @@ -0,0 +1,77 @@ +#!/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.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', + ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.1,<2.0.0', + ], + python_requires=">=3.7" +) 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