diff --git a/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md b/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md new file mode 100644 index 000000000000..315f65e31ea2 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (2022-06-13) + +* Initial Release diff --git a/sdk/nginx/azure-mgmt-nginx/LICENSE b/sdk/nginx/azure-mgmt-nginx/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/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/nginx/azure-mgmt-nginx/MANIFEST.in b/sdk/nginx/azure-mgmt-nginx/MANIFEST.in new file mode 100644 index 000000000000..4d8a44901a62 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/MANIFEST.in @@ -0,0 +1,7 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/nginx/py.typed diff --git a/sdk/nginx/azure-mgmt-nginx/README.md b/sdk/nginx/azure-mgmt-nginx/README.md new file mode 100644 index 000000000000..a66cb29140b9 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Nginx Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Nginx 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-nginx%2FREADME.png) diff --git a/sdk/nginx/azure-mgmt-nginx/_meta.json b/sdk/nginx/azure-mgmt-nginx/_meta.json new file mode 100644 index 000000000000..ecdce0f38584 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "f88928d723133dc392e3297e6d61b7f6d10501fd", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/nginx/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/nginx/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/azure/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/__init__.py new file mode 100644 index 000000000000..ef85dc488ce7 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._nginx_management_client import NginxManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['NginxManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_configuration.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_configuration.py new file mode 100644 index 000000000000..a71bea6b02dc --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_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 NginxManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for NginxManagementClient. + + 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-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(NginxManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-05-01-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-nginx/{}'.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/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py new file mode 100644 index 000000000000..61fc893aaa93 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, 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 NginxManagementClientConfiguration +from .operations import CertificatesOperations, ConfigurationsOperations, DeploymentsOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class NginxManagementClient: + """NginxManagementClient. + + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.nginx.operations.CertificatesOperations + :ivar configurations: ConfigurationsOperations operations + :vartype configurations: azure.mgmt.nginx.operations.ConfigurationsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.nginx.operations.DeploymentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.nginx.operations.Operations + :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 "". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "", + **kwargs: Any + ) -> None: + self._config = NginxManagementClientConfiguration(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.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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: () -> NginxManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_vendor.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_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/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_version.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_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/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/__init__.py new file mode 100644 index 000000000000..686482f7c4cf --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._nginx_management_client import NginxManagementClient +__all__ = ['NginxManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_configuration.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_configuration.py new file mode 100644 index 000000000000..be394c687dc2 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/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 NginxManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for NginxManagementClient. + + 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-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(NginxManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-05-01-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-nginx/{}'.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/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py new file mode 100644 index 000000000000..f03079f114da --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py @@ -0,0 +1,103 @@ +# 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 NginxManagementClientConfiguration +from .operations import CertificatesOperations, ConfigurationsOperations, DeploymentsOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class NginxManagementClient: + """NginxManagementClient. + + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.nginx.aio.operations.CertificatesOperations + :ivar configurations: ConfigurationsOperations operations + :vartype configurations: azure.mgmt.nginx.aio.operations.ConfigurationsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.nginx.aio.operations.DeploymentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.nginx.aio.operations.Operations + :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 "". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "", + **kwargs: Any + ) -> None: + self._config = NginxManagementClientConfiguration(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.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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) -> "NginxManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py new file mode 100644 index 000000000000..43e7ffb09d78 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# 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 ._certificates_operations import CertificatesOperations +from ._configurations_operations import ConfigurationsOperations +from ._deployments_operations import DeploymentsOperations +from ._operations import Operations + +__all__ = [ + 'CertificatesOperations', + 'ConfigurationsOperations', + 'DeploymentsOperations', + 'Operations', +] diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py new file mode 100644 index 000000000000..fc2afa067a2d --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py @@ -0,0 +1,437 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CertificatesOperations: + """CertificatesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.NginxCertificate": + """Get a certificate of given Nginx deployment. + + Get a certificate of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param certificate_name: The name of certificate. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NginxCertificate, or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxCertificate + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NginxCertificate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + + async def _create_initial( + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + body: Optional["_models.NginxCertificate"] = None, + **kwargs: Any + ) -> "_models.NginxCertificate": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxCertificate') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxCertificate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxCertificate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + body: Optional["_models.NginxCertificate"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.NginxCertificate"]: + """Create or update the Nginx certificates for given Nginx deployment. + + Create or update the Nginx certificates for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param certificate_name: The name of certificate. + :type certificate_name: str + :param body: The certificate. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxCertificate + :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 NginxCertificate or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxCertificate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificate"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxCertificate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a certificate from the nginx deployment. + + Deletes a certificate from the nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param certificate_name: The name of certificate. + :type certificate_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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.NginxCertificateListResponse"]: + """List all certificates of given Nginx deployment. + + List all certificates of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NginxCertificateListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxCertificateListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificateListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxCertificateListResponse", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py new file mode 100644 index 000000000000..ab81a060fb1f --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py @@ -0,0 +1,440 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configurations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationsOperations: + """ConfigurationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.NginxConfigurationListResponse"]: + """List the Nginx configuration of given Nginx deployment. + + List the Nginx configuration of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NginxConfigurationListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxConfigurationListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfigurationListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxConfigurationListResponse", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any + ) -> "_models.NginxConfiguration": + """Get the Nginx configuration of given Nginx deployment. + + Get the Nginx configuration of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param configuration_name: The name of configuration, only 'default' is supported value due to + the singleton of Nginx conf. + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NginxConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NginxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + body: Optional["_models.NginxConfiguration"] = None, + **kwargs: Any + ) -> "_models.NginxConfiguration": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxConfiguration') + else: + _json = None + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxConfiguration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + body: Optional["_models.NginxConfiguration"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.NginxConfiguration"]: + """Create or update the Nginx configuration for given Nginx deployment. + + Create or update the Nginx configuration for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param configuration_name: The name of configuration, only 'default' is supported value due to + the singleton of Nginx conf. + :type configuration_name: str + :param body: The Nginx configuration. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxConfiguration + :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 NginxConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfiguration"] + 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_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxConfiguration', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reset the Nginx configuration of given Nginx deployment to default. + + Reset the Nginx configuration of given Nginx deployment to default. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param configuration_name: The name of configuration, only 'default' is supported value due to + the singleton of Nginx conf. + :type configuration_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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py new file mode 100644 index 000000000000..10f2adba85dc --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py @@ -0,0 +1,612 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> "_models.NginxDeployment": + """Get the Nginx deployment. + + Get the Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NginxDeployment, or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeployment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NginxDeployment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + async def _create_initial( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeployment"] = None, + **kwargs: Any + ) -> "_models.NginxDeployment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxDeployment') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxDeployment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxDeployment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeployment"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.NginxDeployment"]: + """Create or update the Nginx deployment. + + Create or update the Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeployment + :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 NginxDeployment or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxDeployment] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxDeployment', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeploymentUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.NginxDeployment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxDeploymentUpdateParameters') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxDeployment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxDeployment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeploymentUpdateParameters"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.NginxDeployment"]: + """Update the Nginx deployment. + + Update the Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeploymentUpdateParameters + :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 NginxDeployment or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxDeployment] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxDeployment', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the Nginx deployment resource. + + Delete the Nginx deployment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.NginxDeploymentListResponse"]: + """List the Nginx deployments resources. + + List the Nginx deployments resources. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NginxDeploymentListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeploymentListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeploymentListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Nginx.NginxPlus/nginxDeployments"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.NginxDeploymentListResponse"]: + """List all Nginx deployments under the specified resource group. + + List all Nginx deployments under the specified 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 NginxDeploymentListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeploymentListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeploymentListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", 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.ResourceProviderDefaultErrorResponse, 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/Nginx.NginxPlus/nginxDeployments"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py new file mode 100644 index 000000000000..71a425f5a970 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py @@ -0,0 +1,117 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """List all operations provided by Nginx.NginxPlus for the 2021-05-01-preview api version. + + List all operations provided by Nginx.NginxPlus for the 2021-05-01-preview api version. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Nginx.NginxPlus/operations"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py new file mode 100644 index 000000000000..f792d8691f95 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py @@ -0,0 +1,77 @@ +# 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 ErrorResponseBody +from ._models_py3 import IdentityProperties +from ._models_py3 import NginxCertificate +from ._models_py3 import NginxCertificateListResponse +from ._models_py3 import NginxCertificateProperties +from ._models_py3 import NginxConfiguration +from ._models_py3 import NginxConfigurationFile +from ._models_py3 import NginxConfigurationListResponse +from ._models_py3 import NginxConfigurationPackage +from ._models_py3 import NginxConfigurationProperties +from ._models_py3 import NginxDeployment +from ._models_py3 import NginxDeploymentListResponse +from ._models_py3 import NginxDeploymentProperties +from ._models_py3 import NginxDeploymentUpdateParameters +from ._models_py3 import NginxDeploymentUpdateProperties +from ._models_py3 import NginxFrontendIPConfiguration +from ._models_py3 import NginxNetworkInterfaceConfiguration +from ._models_py3 import NginxNetworkProfile +from ._models_py3 import NginxPrivateIPAddress +from ._models_py3 import NginxPublicIPAddress +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationResult +from ._models_py3 import ResourceProviderDefaultErrorResponse +from ._models_py3 import ResourceSku +from ._models_py3 import SystemData +from ._models_py3 import UserIdentityProperties + + +from ._nginx_management_client_enums import ( + CreatedByType, + IdentityType, + NginxPrivateIPAllocationMethod, + ProvisioningState, +) + +__all__ = [ + 'ErrorResponseBody', + 'IdentityProperties', + 'NginxCertificate', + 'NginxCertificateListResponse', + 'NginxCertificateProperties', + 'NginxConfiguration', + 'NginxConfigurationFile', + 'NginxConfigurationListResponse', + 'NginxConfigurationPackage', + 'NginxConfigurationProperties', + 'NginxDeployment', + 'NginxDeploymentListResponse', + 'NginxDeploymentProperties', + 'NginxDeploymentUpdateParameters', + 'NginxDeploymentUpdateProperties', + 'NginxFrontendIPConfiguration', + 'NginxNetworkInterfaceConfiguration', + 'NginxNetworkProfile', + 'NginxPrivateIPAddress', + 'NginxPublicIPAddress', + 'OperationDisplay', + 'OperationListResult', + 'OperationResult', + 'ResourceProviderDefaultErrorResponse', + 'ResourceSku', + 'SystemData', + 'UserIdentityProperties', + 'CreatedByType', + 'IdentityType', + 'NginxPrivateIPAllocationMethod', + 'ProvisioningState', +] diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py new file mode 100644 index 000000000000..879e9f3ab777 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py @@ -0,0 +1,1134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._nginx_management_client_enums import * + + +class ErrorResponseBody(msrest.serialization.Model): + """ErrorResponseBody. + + :ivar code: + :vartype code: str + :ivar message: + :vartype message: str + :ivar target: + :vartype target: str + :ivar details: + :vartype details: list[~azure.mgmt.nginx.models.ErrorResponseBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorResponseBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["ErrorResponseBody"]] = None, + **kwargs + ): + """ + :keyword code: + :paramtype code: str + :keyword message: + :paramtype message: str + :keyword target: + :paramtype target: str + :keyword details: + :paramtype details: list[~azure.mgmt.nginx.models.ErrorResponseBody] + """ + super(ErrorResponseBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class IdentityProperties(msrest.serialization.Model): + """IdentityProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: + :vartype principal_id: str + :ivar tenant_id: + :vartype tenant_id: str + :ivar type: Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, + UserAssigned", "None". + :vartype type: str or ~azure.mgmt.nginx.models.IdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.nginx.models.UserIdentityProperties] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "IdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + **kwargs + ): + """ + :keyword type: Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, + UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.nginx.models.IdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, ~azure.mgmt.nginx.models.UserIdentityProperties] + """ + super(IdentityProperties, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class NginxCertificate(msrest.serialization.Model): + """NginxCertificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar type: + :vartype type: str + :ivar properties: + :vartype properties: ~azure.mgmt.nginx.models.NginxCertificateProperties + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] + :ivar location: + :vartype location: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'NginxCertificateProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + properties: Optional["NginxCertificateProperties"] = None, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword properties: + :paramtype properties: ~azure.mgmt.nginx.models.NginxCertificateProperties + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + :keyword location: + :paramtype location: str + """ + super(NginxCertificate, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + self.tags = tags + self.location = location + self.system_data = None + + +class NginxCertificateListResponse(msrest.serialization.Model): + """NginxCertificateListResponse. + + :ivar value: + :vartype value: list[~azure.mgmt.nginx.models.NginxCertificate] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NginxCertificate]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["NginxCertificate"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.nginx.models.NginxCertificate] + :keyword next_link: + :paramtype next_link: str + """ + super(NginxCertificateListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class NginxCertificateProperties(msrest.serialization.Model): + """NginxCertificateProperties. + + :ivar provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :ivar key_virtual_path: + :vartype key_virtual_path: str + :ivar certificate_virtual_path: + :vartype certificate_virtual_path: str + :ivar key_vault_secret_id: + :vartype key_vault_secret_id: str + """ + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'key_virtual_path': {'key': 'keyVirtualPath', 'type': 'str'}, + 'certificate_virtual_path': {'key': 'certificateVirtualPath', 'type': 'str'}, + 'key_vault_secret_id': {'key': 'keyVaultSecretId', 'type': 'str'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + key_virtual_path: Optional[str] = None, + certificate_virtual_path: Optional[str] = None, + key_vault_secret_id: Optional[str] = None, + **kwargs + ): + """ + :keyword provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :paramtype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :keyword key_virtual_path: + :paramtype key_virtual_path: str + :keyword certificate_virtual_path: + :paramtype certificate_virtual_path: str + :keyword key_vault_secret_id: + :paramtype key_vault_secret_id: str + """ + super(NginxCertificateProperties, self).__init__(**kwargs) + self.provisioning_state = provisioning_state + self.key_virtual_path = key_virtual_path + self.certificate_virtual_path = certificate_virtual_path + self.key_vault_secret_id = key_vault_secret_id + + +class NginxConfiguration(msrest.serialization.Model): + """NginxConfiguration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar type: + :vartype type: str + :ivar properties: + :vartype properties: ~azure.mgmt.nginx.models.NginxConfigurationProperties + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] + :ivar location: + :vartype location: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'NginxConfigurationProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + properties: Optional["NginxConfigurationProperties"] = None, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword properties: + :paramtype properties: ~azure.mgmt.nginx.models.NginxConfigurationProperties + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + :keyword location: + :paramtype location: str + """ + super(NginxConfiguration, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + self.tags = tags + self.location = location + self.system_data = None + + +class NginxConfigurationFile(msrest.serialization.Model): + """NginxConfigurationFile. + + :ivar content: + :vartype content: str + :ivar virtual_path: + :vartype virtual_path: str + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'str'}, + 'virtual_path': {'key': 'virtualPath', 'type': 'str'}, + } + + def __init__( + self, + *, + content: Optional[str] = None, + virtual_path: Optional[str] = None, + **kwargs + ): + """ + :keyword content: + :paramtype content: str + :keyword virtual_path: + :paramtype virtual_path: str + """ + super(NginxConfigurationFile, self).__init__(**kwargs) + self.content = content + self.virtual_path = virtual_path + + +class NginxConfigurationListResponse(msrest.serialization.Model): + """Response of a list operation. + + :ivar value: Results of a list operation. + :vartype value: list[~azure.mgmt.nginx.models.NginxConfiguration] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NginxConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["NginxConfiguration"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~azure.mgmt.nginx.models.NginxConfiguration] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ + super(NginxConfigurationListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class NginxConfigurationPackage(msrest.serialization.Model): + """NginxConfigurationPackage. + + :ivar data: + :vartype data: str + """ + + _attribute_map = { + 'data': {'key': 'data', 'type': 'str'}, + } + + def __init__( + self, + *, + data: Optional[str] = None, + **kwargs + ): + """ + :keyword data: + :paramtype data: str + """ + super(NginxConfigurationPackage, self).__init__(**kwargs) + self.data = data + + +class NginxConfigurationProperties(msrest.serialization.Model): + """NginxConfigurationProperties. + + :ivar provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :ivar files: + :vartype files: list[~azure.mgmt.nginx.models.NginxConfigurationFile] + :ivar package: + :vartype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage + :ivar root_file: + :vartype root_file: str + """ + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'files': {'key': 'files', 'type': '[NginxConfigurationFile]'}, + 'package': {'key': 'package', 'type': 'NginxConfigurationPackage'}, + 'root_file': {'key': 'rootFile', 'type': 'str'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + files: Optional[List["NginxConfigurationFile"]] = None, + package: Optional["NginxConfigurationPackage"] = None, + root_file: Optional[str] = None, + **kwargs + ): + """ + :keyword provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :paramtype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :keyword files: + :paramtype files: list[~azure.mgmt.nginx.models.NginxConfigurationFile] + :keyword package: + :paramtype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage + :keyword root_file: + :paramtype root_file: str + """ + super(NginxConfigurationProperties, self).__init__(**kwargs) + self.provisioning_state = provisioning_state + self.files = files + self.package = package + self.root_file = root_file + + +class NginxDeployment(msrest.serialization.Model): + """NginxDeployment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar type: + :vartype type: str + :ivar identity: + :vartype identity: ~azure.mgmt.nginx.models.IdentityProperties + :ivar properties: + :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentProperties + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] + :ivar sku: + :vartype sku: ~azure.mgmt.nginx.models.ResourceSku + :ivar location: + :vartype location: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, + 'properties': {'key': 'properties', 'type': 'NginxDeploymentProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'ResourceSku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + identity: Optional["IdentityProperties"] = None, + properties: Optional["NginxDeploymentProperties"] = None, + tags: Optional[Dict[str, str]] = None, + sku: Optional["ResourceSku"] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword identity: + :paramtype identity: ~azure.mgmt.nginx.models.IdentityProperties + :keyword properties: + :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentProperties + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + :keyword sku: + :paramtype sku: ~azure.mgmt.nginx.models.ResourceSku + :keyword location: + :paramtype location: str + """ + super(NginxDeployment, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.identity = identity + self.properties = properties + self.tags = tags + self.sku = sku + self.location = location + self.system_data = None + + +class NginxDeploymentListResponse(msrest.serialization.Model): + """NginxDeploymentListResponse. + + :ivar value: + :vartype value: list[~azure.mgmt.nginx.models.NginxDeployment] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NginxDeployment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["NginxDeployment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.nginx.models.NginxDeployment] + :keyword next_link: + :paramtype next_link: str + """ + super(NginxDeploymentListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class NginxDeploymentProperties(msrest.serialization.Model): + """NginxDeploymentProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :ivar nginx_version: + :vartype nginx_version: str + :ivar managed_resource_group: The managed resource group to deploy VNet injection related + network resources. + :vartype managed_resource_group: str + :ivar network_profile: + :vartype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile + :ivar ip_address: The IP address of the deployment. + :vartype ip_address: str + :ivar enable_diagnostics_support: + :vartype enable_diagnostics_support: bool + """ + + _validation = { + 'nginx_version': {'readonly': True}, + 'ip_address': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nginx_version': {'key': 'nginxVersion', 'type': 'str'}, + 'managed_resource_group': {'key': 'managedResourceGroup', 'type': 'str'}, + 'network_profile': {'key': 'networkProfile', 'type': 'NginxNetworkProfile'}, + 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + 'enable_diagnostics_support': {'key': 'enableDiagnosticsSupport', 'type': 'bool'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + managed_resource_group: Optional[str] = None, + network_profile: Optional["NginxNetworkProfile"] = None, + enable_diagnostics_support: Optional[bool] = None, + **kwargs + ): + """ + :keyword provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :paramtype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :keyword managed_resource_group: The managed resource group to deploy VNet injection related + network resources. + :paramtype managed_resource_group: str + :keyword network_profile: + :paramtype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile + :keyword enable_diagnostics_support: + :paramtype enable_diagnostics_support: bool + """ + super(NginxDeploymentProperties, self).__init__(**kwargs) + self.provisioning_state = provisioning_state + self.nginx_version = None + self.managed_resource_group = managed_resource_group + self.network_profile = network_profile + self.ip_address = None + self.enable_diagnostics_support = enable_diagnostics_support + + +class NginxDeploymentUpdateParameters(msrest.serialization.Model): + """NginxDeploymentUpdateParameters. + + :ivar identity: + :vartype identity: ~azure.mgmt.nginx.models.IdentityProperties + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] + :ivar sku: + :vartype sku: ~azure.mgmt.nginx.models.ResourceSku + :ivar location: + :vartype location: str + :ivar properties: + :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentUpdateProperties + """ + + _attribute_map = { + 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'ResourceSku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'NginxDeploymentUpdateProperties'}, + } + + def __init__( + self, + *, + identity: Optional["IdentityProperties"] = None, + tags: Optional[Dict[str, str]] = None, + sku: Optional["ResourceSku"] = None, + location: Optional[str] = None, + properties: Optional["NginxDeploymentUpdateProperties"] = None, + **kwargs + ): + """ + :keyword identity: + :paramtype identity: ~azure.mgmt.nginx.models.IdentityProperties + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + :keyword sku: + :paramtype sku: ~azure.mgmt.nginx.models.ResourceSku + :keyword location: + :paramtype location: str + :keyword properties: + :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentUpdateProperties + """ + super(NginxDeploymentUpdateParameters, self).__init__(**kwargs) + self.identity = identity + self.tags = tags + self.sku = sku + self.location = location + self.properties = properties + + +class NginxDeploymentUpdateProperties(msrest.serialization.Model): + """NginxDeploymentUpdateProperties. + + :ivar enable_diagnostics_support: + :vartype enable_diagnostics_support: bool + """ + + _attribute_map = { + 'enable_diagnostics_support': {'key': 'enableDiagnosticsSupport', 'type': 'bool'}, + } + + def __init__( + self, + *, + enable_diagnostics_support: Optional[bool] = None, + **kwargs + ): + """ + :keyword enable_diagnostics_support: + :paramtype enable_diagnostics_support: bool + """ + super(NginxDeploymentUpdateProperties, self).__init__(**kwargs) + self.enable_diagnostics_support = enable_diagnostics_support + + +class NginxFrontendIPConfiguration(msrest.serialization.Model): + """NginxFrontendIPConfiguration. + + :ivar public_ip_addresses: + :vartype public_ip_addresses: list[~azure.mgmt.nginx.models.NginxPublicIPAddress] + :ivar private_ip_addresses: + :vartype private_ip_addresses: list[~azure.mgmt.nginx.models.NginxPrivateIPAddress] + """ + + _attribute_map = { + 'public_ip_addresses': {'key': 'publicIPAddresses', 'type': '[NginxPublicIPAddress]'}, + 'private_ip_addresses': {'key': 'privateIPAddresses', 'type': '[NginxPrivateIPAddress]'}, + } + + def __init__( + self, + *, + public_ip_addresses: Optional[List["NginxPublicIPAddress"]] = None, + private_ip_addresses: Optional[List["NginxPrivateIPAddress"]] = None, + **kwargs + ): + """ + :keyword public_ip_addresses: + :paramtype public_ip_addresses: list[~azure.mgmt.nginx.models.NginxPublicIPAddress] + :keyword private_ip_addresses: + :paramtype private_ip_addresses: list[~azure.mgmt.nginx.models.NginxPrivateIPAddress] + """ + super(NginxFrontendIPConfiguration, self).__init__(**kwargs) + self.public_ip_addresses = public_ip_addresses + self.private_ip_addresses = private_ip_addresses + + +class NginxNetworkInterfaceConfiguration(msrest.serialization.Model): + """NginxNetworkInterfaceConfiguration. + + :ivar subnet_id: + :vartype subnet_id: str + """ + + _attribute_map = { + 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + } + + def __init__( + self, + *, + subnet_id: Optional[str] = None, + **kwargs + ): + """ + :keyword subnet_id: + :paramtype subnet_id: str + """ + super(NginxNetworkInterfaceConfiguration, self).__init__(**kwargs) + self.subnet_id = subnet_id + + +class NginxNetworkProfile(msrest.serialization.Model): + """NginxNetworkProfile. + + :ivar front_end_ip_configuration: + :vartype front_end_ip_configuration: ~azure.mgmt.nginx.models.NginxFrontendIPConfiguration + :ivar network_interface_configuration: + :vartype network_interface_configuration: + ~azure.mgmt.nginx.models.NginxNetworkInterfaceConfiguration + """ + + _attribute_map = { + 'front_end_ip_configuration': {'key': 'frontEndIPConfiguration', 'type': 'NginxFrontendIPConfiguration'}, + 'network_interface_configuration': {'key': 'networkInterfaceConfiguration', 'type': 'NginxNetworkInterfaceConfiguration'}, + } + + def __init__( + self, + *, + front_end_ip_configuration: Optional["NginxFrontendIPConfiguration"] = None, + network_interface_configuration: Optional["NginxNetworkInterfaceConfiguration"] = None, + **kwargs + ): + """ + :keyword front_end_ip_configuration: + :paramtype front_end_ip_configuration: ~azure.mgmt.nginx.models.NginxFrontendIPConfiguration + :keyword network_interface_configuration: + :paramtype network_interface_configuration: + ~azure.mgmt.nginx.models.NginxNetworkInterfaceConfiguration + """ + super(NginxNetworkProfile, self).__init__(**kwargs) + self.front_end_ip_configuration = front_end_ip_configuration + self.network_interface_configuration = network_interface_configuration + + +class NginxPrivateIPAddress(msrest.serialization.Model): + """NginxPrivateIPAddress. + + :ivar private_ip_address: + :vartype private_ip_address: str + :ivar private_ip_allocation_method: Possible values include: "Static", "Dynamic". + :vartype private_ip_allocation_method: str or + ~azure.mgmt.nginx.models.NginxPrivateIPAllocationMethod + :ivar subnet_id: + :vartype subnet_id: str + """ + + _attribute_map = { + 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, + 'private_ip_allocation_method': {'key': 'privateIPAllocationMethod', 'type': 'str'}, + 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + } + + def __init__( + self, + *, + private_ip_address: Optional[str] = None, + private_ip_allocation_method: Optional[Union[str, "NginxPrivateIPAllocationMethod"]] = None, + subnet_id: Optional[str] = None, + **kwargs + ): + """ + :keyword private_ip_address: + :paramtype private_ip_address: str + :keyword private_ip_allocation_method: Possible values include: "Static", "Dynamic". + :paramtype private_ip_allocation_method: str or + ~azure.mgmt.nginx.models.NginxPrivateIPAllocationMethod + :keyword subnet_id: + :paramtype subnet_id: str + """ + super(NginxPrivateIPAddress, self).__init__(**kwargs) + self.private_ip_address = private_ip_address + self.private_ip_allocation_method = private_ip_allocation_method + self.subnet_id = subnet_id + + +class NginxPublicIPAddress(msrest.serialization.Model): + """NginxPublicIPAddress. + + :ivar id: + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: + :paramtype id: str + """ + super(NginxPublicIPAddress, self).__init__(**kwargs) + self.id = id + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Nginx.NginxPlus. + :vartype provider: str + :ivar resource: Type on which the operation is performed, e.g., 'deployments'. + :vartype resource: str + :ivar operation: Operation type, e.g., read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation, e.g., 'Write deployments'. + :vartype description: str + """ + + _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: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Nginx.NginxPlus. + :paramtype provider: str + :keyword resource: Type on which the operation is performed, e.g., 'deployments'. + :paramtype resource: str + :keyword operation: Operation type, e.g., read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation, e.g., 'Write deployments'. + :paramtype description: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of GET request to list Nginx.NginxPlus operations. + + :ivar value: List of operations supported by the Nginx.NginxPlus provider. + :vartype value: list[~azure.mgmt.nginx.models.OperationResult] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OperationResult"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of operations supported by the Nginx.NginxPlus provider. + :paramtype value: list[~azure.mgmt.nginx.models.OperationResult] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationResult(msrest.serialization.Model): + """A Nginx.NginxPlus REST API operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.nginx.models.OperationDisplay + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + is_data_action: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.nginx.models.OperationDisplay + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + """ + super(OperationResult, self).__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = is_data_action + + +class ResourceProviderDefaultErrorResponse(msrest.serialization.Model): + """ResourceProviderDefaultErrorResponse. + + :ivar error: + :vartype error: ~azure.mgmt.nginx.models.ErrorResponseBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponseBody"] = None, + **kwargs + ): + """ + :keyword error: + :paramtype error: ~azure.mgmt.nginx.models.ErrorResponseBody + """ + super(ResourceProviderDefaultErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ResourceSku(msrest.serialization.Model): + """ResourceSku. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Name of the SKU. + :vartype name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. Name of the SKU. + :paramtype name: str + """ + super(ResourceSku, self).__init__(**kwargs) + self.name = name + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.nginx.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.nginx.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.nginx.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.nginx.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 UserIdentityProperties(msrest.serialization.Model): + """UserIdentityProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: + :vartype principal_id: str + :ivar client_id: + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserIdentityProperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py new file mode 100644 index 000000000000..010d48ae2627 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class NginxPrivateIPAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + STATIC = "Static" + DYNAMIC = "Dynamic" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + ACCEPTED = "Accepted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + NOT_SPECIFIED = "NotSpecified" diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py new file mode 100644 index 000000000000..43e7ffb09d78 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py @@ -0,0 +1,19 @@ +# 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 ._certificates_operations import CertificatesOperations +from ._configurations_operations import ConfigurationsOperations +from ._deployments_operations import DeploymentsOperations +from ._operations import Operations + +__all__ = [ + 'CertificatesOperations', + 'ConfigurationsOperations', + 'DeploymentsOperations', + 'Operations', +] diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py new file mode 100644 index 000000000000..f894d093f099 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py @@ -0,0 +1,577 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class CertificatesOperations(object): + """CertificatesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.NginxCertificate": + """Get a certificate of given Nginx deployment. + + Get a certificate of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param certificate_name: The name of certificate. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NginxCertificate, or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxCertificate + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NginxCertificate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + + def _create_initial( + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + body: Optional["_models.NginxCertificate"] = None, + **kwargs: Any + ) -> "_models.NginxCertificate": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxCertificate') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxCertificate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxCertificate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + body: Optional["_models.NginxCertificate"] = None, + **kwargs: Any + ) -> LROPoller["_models.NginxCertificate"]: + """Create or update the Nginx certificates for given Nginx deployment. + + Create or update the Nginx certificates for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param certificate_name: The name of certificate. + :type certificate_name: str + :param body: The certificate. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxCertificate + :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 NginxCertificate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxCertificate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificate"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxCertificate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + certificate_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a certificate from the nginx deployment. + + Deletes a certificate from the nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param certificate_name: The name of certificate. + :type certificate_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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + certificate_name=certificate_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> Iterable["_models.NginxCertificateListResponse"]: + """List all certificates of given Nginx deployment. + + List all certificates of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NginxCertificateListResponse or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxCertificateListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxCertificateListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxCertificateListResponse", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py new file mode 100644 index 000000000000..932fceb75b48 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py @@ -0,0 +1,580 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + headers=_header_parameters, + **kwargs + ) + +class ConfigurationsOperations(object): + """ConfigurationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> Iterable["_models.NginxConfigurationListResponse"]: + """List the Nginx configuration of given Nginx deployment. + + List the Nginx configuration of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NginxConfigurationListResponse or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxConfigurationListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfigurationListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxConfigurationListResponse", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any + ) -> "_models.NginxConfiguration": + """Get the Nginx configuration of given Nginx deployment. + + Get the Nginx configuration of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param configuration_name: The name of configuration, only 'default' is supported value due to + the singleton of Nginx conf. + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NginxConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NginxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + body: Optional["_models.NginxConfiguration"] = None, + **kwargs: Any + ) -> "_models.NginxConfiguration": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxConfiguration') + else: + _json = None + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxConfiguration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + body: Optional["_models.NginxConfiguration"] = None, + **kwargs: Any + ) -> LROPoller["_models.NginxConfiguration"]: + """Create or update the Nginx configuration for given Nginx deployment. + + Create or update the Nginx configuration for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param configuration_name: The name of configuration, only 'default' is supported value due to + the singleton of Nginx conf. + :type configuration_name: str + :param body: The Nginx configuration. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxConfiguration + :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 NginxConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxConfiguration"] + 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_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxConfiguration', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Reset the Nginx configuration of given Nginx deployment to default. + + Reset the Nginx configuration of given Nginx deployment to default. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param configuration_name: The name of configuration, only 'default' is supported value due to + the singleton of Nginx conf. + :type configuration_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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + configuration_name=configuration_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py new file mode 100644 index 000000000000..8c618954662e --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py @@ -0,0 +1,799 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}") # 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), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Nginx.NginxPlus/nginxDeployments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + headers=_header_parameters, + **kwargs + ) + +class DeploymentsOperations(object): + """DeploymentsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> "_models.NginxDeployment": + """Get the Nginx deployment. + + Get the Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NginxDeployment, or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeployment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NginxDeployment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + def _create_initial( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeployment"] = None, + **kwargs: Any + ) -> "_models.NginxDeployment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxDeployment') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxDeployment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxDeployment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeployment"] = None, + **kwargs: Any + ) -> LROPoller["_models.NginxDeployment"]: + """Create or update the Nginx deployment. + + Create or update the Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeployment + :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 NginxDeployment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxDeployment] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxDeployment', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeploymentUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.NginxDeployment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'NginxDeploymentUpdateParameters') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('NginxDeployment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('NginxDeployment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + deployment_name: str, + body: Optional["_models.NginxDeploymentUpdateParameters"] = None, + **kwargs: Any + ) -> LROPoller["_models.NginxDeployment"]: + """Update the Nginx deployment. + + Update the Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeploymentUpdateParameters + :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 NginxDeployment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxDeployment] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeployment"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('NginxDeployment', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + deployment_name=deployment_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + deployment_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete the Nginx deployment resource. + + Delete the Nginx deployment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of targeted Nginx deployment. + :type deployment_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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.NginxDeploymentListResponse"]: + """List the Nginx deployments resources. + + List the Nginx deployments resources. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NginxDeploymentListResponse or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeploymentListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeploymentListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Nginx.NginxPlus/nginxDeployments"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.NginxDeploymentListResponse"]: + """List all Nginx deployments under the specified resource group. + + List all Nginx deployments under the specified 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 NginxDeploymentListResponse or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeploymentListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NginxDeploymentListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", 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.ResourceProviderDefaultErrorResponse, 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/Nginx.NginxPlus/nginxDeployments"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py new file mode 100644 index 000000000000..944b37644bc9 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py @@ -0,0 +1,146 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Nginx.NginxPlus/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.nginx.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """List all operations provided by Nginx.NginxPlus for the 2021-05-01-preview api version. + + List all operations provided by Nginx.NginxPlus for the 2021-05-01-preview api version. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", 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.ResourceProviderDefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Nginx.NginxPlus/operations"} # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/py.typed b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/sdk_packaging.toml b/sdk/nginx/azure-mgmt-nginx/sdk_packaging.toml new file mode 100644 index 000000000000..15f832165304 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-nginx" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Nginx Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/nginx/azure-mgmt-nginx/setup.py b/sdk/nginx/azure-mgmt-nginx/setup.py new file mode 100644 index 000000000000..b1d2ba904d1d --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/setup.py @@ -0,0 +1,78 @@ +#!/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-nginx" +PACKAGE_PPRINT_NAME = "Nginx Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/nginx/ci.yml b/sdk/nginx/ci.yml new file mode 100644 index 000000000000..efb4d5a515dd --- /dev/null +++ b/sdk/nginx/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/nginx/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/nginx/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: nginx + Artifacts: + - name: azure-mgmt-nginx + safeName: azuremgmtnginx diff --git a/shared_requirements.txt b/shared_requirements.txt index c7c777d9e951..216f72d111a3 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -367,3 +367,5 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-logic azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-communication msrest>=0.6.21 #override azure-mgmt-communication azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-nginx msrest>=0.6.21 +#override azure-mgmt-nginx azure-mgmt-core>=1.3.0,<2.0.0