diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/CHANGELOG.md b/sdk/managednetwork/azure-mgmt-managednetwork/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/LICENSE b/sdk/managednetwork/azure-mgmt-managednetwork/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/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/managednetwork/azure-mgmt-managednetwork/MANIFEST.in b/sdk/managednetwork/azure-mgmt-managednetwork/MANIFEST.in new file mode 100644 index 000000000000..18bb5aeb06aa --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/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/managednetwork/py.typed diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/README.md b/sdk/managednetwork/azure-mgmt-managednetwork/README.md new file mode 100644 index 000000000000..3f15aece4517 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-managednetwork%2FREADME.png) diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/_meta.json b/sdk/managednetwork/azure-mgmt-managednetwork/_meta.json new file mode 100644 index 000000000000..937533c4146f --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "163e27c0ca7570bc39e00a46f255740d9b3ba3cb", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/managednetwork/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/managednetwork/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/__init__.py new file mode 100644 index 000000000000..e76bf170ac56 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/__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 ._managed_network_management_client import ManagedNetworkManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['ManagedNetworkManagementClient'] + +# `._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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_configuration.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_configuration.py new file mode 100644 index 000000000000..110fd4a81766 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_configuration.py @@ -0,0 +1,74 @@ +# 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 ManagedNetworkManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ManagedNetworkManagementClient. + + 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: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-06-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(ManagedNetworkManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-06-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-managednetwork/{}'.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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_managed_network_management_client.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_managed_network_management_client.py new file mode 100644 index 000000000000..ae2700b8c56d --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_managed_network_management_client.py @@ -0,0 +1,114 @@ +# 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 ManagedNetworkManagementClientConfiguration +from .operations import ManagedNetworkGroupsOperations, ManagedNetworkPeeringPoliciesOperations, ManagedNetworksOperations, Operations, ScopeAssignmentsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ManagedNetworkManagementClient: + """The Microsoft Azure Managed Network management API provides a RESTful set of web services that + interact with Microsoft Azure Networks service to programmatically view, control, change, and + monitor your entire Azure network centrally and with ease. + + :ivar managed_networks: ManagedNetworksOperations operations + :vartype managed_networks: azure.mgmt.managednetwork.operations.ManagedNetworksOperations + :ivar scope_assignments: ScopeAssignmentsOperations operations + :vartype scope_assignments: azure.mgmt.managednetwork.operations.ScopeAssignmentsOperations + :ivar managed_network_groups: ManagedNetworkGroupsOperations operations + :vartype managed_network_groups: + azure.mgmt.managednetwork.operations.ManagedNetworkGroupsOperations + :ivar managed_network_peering_policies: ManagedNetworkPeeringPoliciesOperations operations + :vartype managed_network_peering_policies: + azure.mgmt.managednetwork.operations.ManagedNetworkPeeringPoliciesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.managednetwork.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ManagedNetworkManagementClientConfiguration(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.managed_networks = ManagedNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_assignments = ScopeAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_network_groups = ManagedNetworkGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_network_peering_policies = ManagedNetworkPeeringPoliciesOperations(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: () -> ManagedNetworkManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_patch.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_vendor.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_version.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_version.py new file mode 100644 index 000000000000..d399cc5b5546 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/_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 = "2019-06-01T00:00:00.000Z" diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/__init__.py new file mode 100644 index 000000000000..0b458277b83f --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/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 ._managed_network_management_client import ManagedNetworkManagementClient +__all__ = ['ManagedNetworkManagementClient'] + +# `._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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_configuration.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_configuration.py new file mode 100644 index 000000000000..68826219dd6e --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_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 ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ManagedNetworkManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ManagedNetworkManagementClient. + + 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: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-06-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(ManagedNetworkManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-06-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-managednetwork/{}'.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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_managed_network_management_client.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_managed_network_management_client.py new file mode 100644 index 000000000000..42708fd8eaee --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_managed_network_management_client.py @@ -0,0 +1,111 @@ +# 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 ManagedNetworkManagementClientConfiguration +from .operations import ManagedNetworkGroupsOperations, ManagedNetworkPeeringPoliciesOperations, ManagedNetworksOperations, Operations, ScopeAssignmentsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ManagedNetworkManagementClient: + """The Microsoft Azure Managed Network management API provides a RESTful set of web services that + interact with Microsoft Azure Networks service to programmatically view, control, change, and + monitor your entire Azure network centrally and with ease. + + :ivar managed_networks: ManagedNetworksOperations operations + :vartype managed_networks: azure.mgmt.managednetwork.aio.operations.ManagedNetworksOperations + :ivar scope_assignments: ScopeAssignmentsOperations operations + :vartype scope_assignments: azure.mgmt.managednetwork.aio.operations.ScopeAssignmentsOperations + :ivar managed_network_groups: ManagedNetworkGroupsOperations operations + :vartype managed_network_groups: + azure.mgmt.managednetwork.aio.operations.ManagedNetworkGroupsOperations + :ivar managed_network_peering_policies: ManagedNetworkPeeringPoliciesOperations operations + :vartype managed_network_peering_policies: + azure.mgmt.managednetwork.aio.operations.ManagedNetworkPeeringPoliciesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.managednetwork.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ManagedNetworkManagementClientConfiguration(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.managed_networks = ManagedNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_assignments = ScopeAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_network_groups = ManagedNetworkGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_network_peering_policies = ManagedNetworkPeeringPoliciesOperations(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) -> "ManagedNetworkManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_patch.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/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/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/__init__.py new file mode 100644 index 000000000000..4f382e2b2364 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._managed_networks_operations import ManagedNetworksOperations +from ._scope_assignments_operations import ScopeAssignmentsOperations +from ._managed_network_groups_operations import ManagedNetworkGroupsOperations +from ._managed_network_peering_policies_operations import ManagedNetworkPeeringPoliciesOperations +from ._operations import Operations + +__all__ = [ + 'ManagedNetworksOperations', + 'ScopeAssignmentsOperations', + 'ManagedNetworkGroupsOperations', + 'ManagedNetworkPeeringPoliciesOperations', + 'Operations', +] diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_network_groups_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_network_groups_operations.py new file mode 100644 index 000000000000..b36e6b38018e --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_network_groups_operations.py @@ -0,0 +1,457 @@ +# 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._managed_network_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_managed_network_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagedNetworkGroupsOperations: + """ManagedNetworkGroupsOperations 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.managednetwork.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, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any + ) -> "_models.ManagedNetworkGroup": + """The Get ManagedNetworkGroups operation gets a Managed Network Group specified by the resource + group, Managed Network name, and group name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_group_name: The name of the Managed Network Group. + :type managed_network_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetworkGroup, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetworkGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedNetworkGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + managed_network_group: "_models.ManagedNetworkGroup", + **kwargs: Any + ) -> "_models.ManagedNetworkGroup": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(managed_network_group, 'ManagedNetworkGroup') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + 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('ManagedNetworkGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetworkGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + managed_network_group: "_models.ManagedNetworkGroup", + **kwargs: Any + ) -> AsyncLROPoller["_models.ManagedNetworkGroup"]: + """The Put ManagedNetworkGroups operation creates or updates a Managed Network Group resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_group_name: The name of the Managed Network Group. + :type managed_network_group_name: str + :param managed_network_group: Parameters supplied to the create/update a Managed Network Group + resource. + :type managed_network_group: ~azure.mgmt.managednetwork.models.ManagedNetworkGroup + :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 ManagedNetworkGroup or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managednetwork.models.ManagedNetworkGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroup"] + 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, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + managed_network_group=managed_network_group, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ManagedNetworkGroup', 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/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Delete ManagedNetworkGroups operation deletes a Managed Network Group specified by the + resource group, Managed Network name, and group name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_group_name: The name of the Managed Network Group. + :type managed_network_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + @distributed_trace + def list_by_managed_network( + self, + resource_group_name: str, + managed_network_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ManagedNetworkGroupListResult"]: + """The ListByManagedNetwork ManagedNetworkGroup operation retrieves all the Managed Network Groups + in a specified Managed Networks in a paginated format. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroupListResult"] + 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_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_managed_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkGroupListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_managed_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_network_peering_policies_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_network_peering_policies_operations.py new file mode 100644 index 000000000000..72fe3e346876 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_network_peering_policies_operations.py @@ -0,0 +1,458 @@ +# 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._managed_network_peering_policies_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_managed_network_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagedNetworkPeeringPoliciesOperations: + """ManagedNetworkPeeringPoliciesOperations 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.managednetwork.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, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any + ) -> "_models.ManagedNetworkPeeringPolicy": + """The Get ManagedNetworkPeeringPolicies operation gets a Managed Network Peering Policy resource, + specified by the resource group, Managed Network name, and peering policy name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_peering_policy_name: The name of the Managed Network Peering Policy. + :type managed_network_peering_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetworkPeeringPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedNetworkPeeringPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + managed_network_policy: "_models.ManagedNetworkPeeringPolicy", + **kwargs: Any + ) -> "_models.ManagedNetworkPeeringPolicy": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(managed_network_policy, 'ManagedNetworkPeeringPolicy') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + 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('ManagedNetworkPeeringPolicy', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetworkPeeringPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + managed_network_policy: "_models.ManagedNetworkPeeringPolicy", + **kwargs: Any + ) -> AsyncLROPoller["_models.ManagedNetworkPeeringPolicy"]: + """The Put ManagedNetworkPeeringPolicies operation creates/updates a new Managed Network Peering + Policy. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_peering_policy_name: The name of the Managed Network Peering Policy. + :type managed_network_peering_policy_name: str + :param managed_network_policy: Parameters supplied to create/update a Managed Network Peering + Policy. + :type managed_network_policy: ~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy + :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 ManagedNetworkPeeringPolicy or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicy"] + 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, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + managed_network_policy=managed_network_policy, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ManagedNetworkPeeringPolicy', 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/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Delete ManagedNetworkPeeringPolicies operation deletes a Managed Network Peering Policy, + specified by the resource group, Managed Network name, and peering policy name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_peering_policy_name: The name of the Managed Network Peering Policy. + :type managed_network_peering_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + @distributed_trace + def list_by_managed_network( + self, + resource_group_name: str, + managed_network_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ManagedNetworkPeeringPolicyListResult"]: + """The ListByManagedNetwork PeeringPolicies operation retrieves all the Managed Network Peering + Policies in a specified Managed Network, in a paginated format. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkPeeringPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicyListResult"] + 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_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_managed_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkPeeringPolicyListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_managed_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_networks_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_networks_operations.py new file mode 100644 index 000000000000..d1ff42ab3b5f --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_managed_networks_operations.py @@ -0,0 +1,594 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._managed_networks_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagedNetworksOperations: + """ManagedNetworksOperations 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.managednetwork.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, + managed_network_name: str, + **kwargs: Any + ) -> "_models.ManagedNetwork": + """The Get ManagedNetworks operation gets a Managed Network Resource, specified by the resource + group and Managed Network name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_network_name: str, + managed_network: "_models.ManagedNetwork", + **kwargs: Any + ) -> "_models.ManagedNetwork": + """The Put ManagedNetworks operation creates/updates a Managed Network Resource, specified by + resource group and Managed Network name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network: Parameters supplied to the create/update a Managed Network Resource. + :type managed_network: ~azure.mgmt.managednetwork.models.ManagedNetwork + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(managed_network, 'ManagedNetwork') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Delete ManagedNetworks operation deletes a Managed Network Resource, specified by the + resource group and Managed Network name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + managed_network_name: str, + parameters: "_models.ManagedNetworkUpdate", + **kwargs: Any + ) -> "_models.ManagedNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedNetworkUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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('ManagedNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + managed_network_name: str, + parameters: "_models.ManagedNetworkUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.ManagedNetwork"]: + """Updates the specified Managed Network resource tags. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param parameters: Parameters supplied to update application gateway tags and/or scope. + :type parameters: ~azure.mgmt.managednetwork.models.ManagedNetworkUpdate + :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 ManagedNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managednetwork.models.ManagedNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + 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, + managed_network_name=managed_network_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ManagedNetworkListResult"]: + """The ListByResourceGroup ManagedNetwork operation retrieves all the Managed Network resources in + a resource group in a paginated format. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ManagedNetworkListResult"]: + """The ListBySubscription ManagedNetwork operation retrieves all the Managed Network Resources in + the current subscription in a paginated format. + + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedNetwork/managedNetworks"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_operations.py new file mode 100644 index 000000000000..dc01a73db084 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_operations.py @@ -0,0 +1,116 @@ +# 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.managednetwork.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"]: + """Lists all of the available MNC operations. + + :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.managednetwork.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ManagedNetwork/operations"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_scope_assignments_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_scope_assignments_operations.py new file mode 100644 index 000000000000..1807bd8e590d --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/aio/operations/_scope_assignments_operations.py @@ -0,0 +1,309 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._scope_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ScopeAssignmentsOperations: + """ScopeAssignmentsOperations 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.managednetwork.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, + scope: str, + scope_assignment_name: str, + **kwargs: Any + ) -> "_models.ScopeAssignment": + """Get the specified scope assignment. + + :param scope: The base resource of the scope assignment. + :type scope: str + :param scope_assignment_name: The name of the scope assignment to get. + :type scope_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ScopeAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + scope=scope, + scope_assignment_name=scope_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ScopeAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + scope: str, + scope_assignment_name: str, + parameters: "_models.ScopeAssignment", + **kwargs: Any + ) -> "_models.ScopeAssignment": + """Creates a scope assignment. + + :param scope: The base resource of the scope assignment to create. The scope can be any REST + resource instance. For example, use 'subscriptions/{subscription-id}' for a subscription, + 'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, + and + 'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' + for a resource. + :type scope: str + :param scope_assignment_name: The name of the scope assignment to create. + :type scope_assignment_name: str + :param parameters: Parameters supplied to the specify which Managed Network this scope is being + assigned. + :type parameters: ~azure.mgmt.managednetwork.models.ScopeAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ScopeAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopeAssignment') + + request = build_create_or_update_request( + scope=scope, + scope_assignment_name=scope_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ScopeAssignment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ScopeAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + scope: str, + scope_assignment_name: str, + **kwargs: Any + ) -> None: + """Deletes a scope assignment. + + :param scope: The scope of the scope assignment to delete. + :type scope: str + :param scope_assignment_name: The name of the scope assignment to delete. + :type scope_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request( + scope=scope, + scope_assignment_name=scope_assignment_name, + api_version=api_version, + template_url=self.delete.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}"} # type: ignore + + + @distributed_trace + def list( + self, + scope: str, + **kwargs: Any + ) -> AsyncIterable["_models.ScopeAssignmentListResult"]: + """Get the specified scope assignment. + + :param scope: The base resource of the scope assignment. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScopeAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managednetwork.models.ScopeAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeAssignmentListResult"] + 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( + scope=scope, + 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( + scope=scope, + 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("ScopeAssignmentListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/__init__.py new file mode 100644 index 000000000000..d933ce23ea3d --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/__init__.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 ._models_py3 import ConnectivityCollection +from ._models_py3 import ErrorResponse +from ._models_py3 import HubAndSpokePeeringPolicyProperties +from ._models_py3 import ManagedNetwork +from ._models_py3 import ManagedNetworkGroup +from ._models_py3 import ManagedNetworkGroupListResult +from ._models_py3 import ManagedNetworkGroupProperties +from ._models_py3 import ManagedNetworkListResult +from ._models_py3 import ManagedNetworkPeeringPolicy +from ._models_py3 import ManagedNetworkPeeringPolicyListResult +from ._models_py3 import ManagedNetworkPeeringPolicyProperties +from ._models_py3 import ManagedNetworkProperties +from ._models_py3 import ManagedNetworkUpdate +from ._models_py3 import MeshPeeringPolicyProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourceId +from ._models_py3 import ResourceProperties +from ._models_py3 import Scope +from ._models_py3 import ScopeAssignment +from ._models_py3 import ScopeAssignmentListResult +from ._models_py3 import ScopeAssignmentProperties +from ._models_py3 import TrackedResource + + +from ._managed_network_management_client_enums import ( + Kind, + ProvisioningState, + Type, +) + +__all__ = [ + 'ConnectivityCollection', + 'ErrorResponse', + 'HubAndSpokePeeringPolicyProperties', + 'ManagedNetwork', + 'ManagedNetworkGroup', + 'ManagedNetworkGroupListResult', + 'ManagedNetworkGroupProperties', + 'ManagedNetworkListResult', + 'ManagedNetworkPeeringPolicy', + 'ManagedNetworkPeeringPolicyListResult', + 'ManagedNetworkPeeringPolicyProperties', + 'ManagedNetworkProperties', + 'ManagedNetworkUpdate', + 'MeshPeeringPolicyProperties', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'ResourceId', + 'ResourceProperties', + 'Scope', + 'ScopeAssignment', + 'ScopeAssignmentListResult', + 'ScopeAssignmentProperties', + 'TrackedResource', + 'Kind', + 'ProvisioningState', + 'Type', +] diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/_managed_network_management_client_enums.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/_managed_network_management_client_enums.py new file mode 100644 index 000000000000..b2a55c3751bb --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/_managed_network_management_client_enums.py @@ -0,0 +1,34 @@ +# 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 Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Responsibility role under which this Managed Network Group will be created + """ + + CONNECTIVITY = "Connectivity" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Provisioning state of the ManagedNetwork resource. + """ + + UPDATING = "Updating" + DELETING = "Deleting" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + +class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets the connectivity type of a network structure policy + """ + + HUB_AND_SPOKE_TOPOLOGY = "HubAndSpokeTopology" + MESH_TOPOLOGY = "MeshTopology" diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/_models_py3.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/_models_py3.py new file mode 100644 index 000000000000..e8168a410260 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/models/_models_py3.py @@ -0,0 +1,1193 @@ +# 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 Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._managed_network_management_client_enums import * + + +class ConnectivityCollection(msrest.serialization.Model): + """The collection of Connectivity related groups and policies within the Managed Network. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar groups: The collection of connectivity related Managed Network Groups within the Managed + Network. + :vartype groups: list[~azure.mgmt.managednetwork.models.ManagedNetworkGroup] + :ivar peerings: The collection of Managed Network Peering Policies within the Managed Network. + :vartype peerings: list[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy] + """ + + _validation = { + 'groups': {'readonly': True}, + 'peerings': {'readonly': True}, + } + + _attribute_map = { + 'groups': {'key': 'groups', 'type': '[ManagedNetworkGroup]'}, + 'peerings': {'key': 'peerings', 'type': '[ManagedNetworkPeeringPolicy]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ConnectivityCollection, self).__init__(**kwargs) + self.groups = None + self.peerings = None + + +class ErrorResponse(msrest.serialization.Model): + """The error response that indicates why an operation has failed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + + +class ResourceProperties(msrest.serialization.Model): + """Base for resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ResourceProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.etag = None + + +class ManagedNetworkPeeringPolicyProperties(ResourceProperties): + """Properties of a Managed Network Peering Policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar type: Required. Gets or sets the connectivity type of a network structure policy. + Possible values include: "HubAndSpokeTopology", "MeshTopology". + :vartype type: str or ~azure.mgmt.managednetwork.models.Type + :ivar hub: Gets or sets the hub virtual network ID. + :vartype hub: ~azure.mgmt.managednetwork.models.ResourceId + :ivar spokes: Gets or sets the spokes group IDs. + :vartype spokes: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar mesh: Gets or sets the mesh group IDs. + :vartype mesh: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'hub': {'key': 'hub', 'type': 'ResourceId'}, + 'spokes': {'key': 'spokes', 'type': '[ResourceId]'}, + 'mesh': {'key': 'mesh', 'type': '[ResourceId]'}, + } + + def __init__( + self, + *, + type: Union[str, "Type"], + hub: Optional["ResourceId"] = None, + spokes: Optional[List["ResourceId"]] = None, + mesh: Optional[List["ResourceId"]] = None, + **kwargs + ): + """ + :keyword type: Required. Gets or sets the connectivity type of a network structure policy. + Possible values include: "HubAndSpokeTopology", "MeshTopology". + :paramtype type: str or ~azure.mgmt.managednetwork.models.Type + :keyword hub: Gets or sets the hub virtual network ID. + :paramtype hub: ~azure.mgmt.managednetwork.models.ResourceId + :keyword spokes: Gets or sets the spokes group IDs. + :paramtype spokes: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword mesh: Gets or sets the mesh group IDs. + :paramtype mesh: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + super(ManagedNetworkPeeringPolicyProperties, self).__init__(**kwargs) + self.type = type + self.hub = hub + self.spokes = spokes + self.mesh = mesh + + +class HubAndSpokePeeringPolicyProperties(ManagedNetworkPeeringPolicyProperties): + """Properties of a Hub and Spoke Peering Policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar type: Required. Gets or sets the connectivity type of a network structure policy. + Possible values include: "HubAndSpokeTopology", "MeshTopology". + :vartype type: str or ~azure.mgmt.managednetwork.models.Type + :ivar hub: Gets or sets the hub virtual network ID. + :vartype hub: ~azure.mgmt.managednetwork.models.ResourceId + :ivar spokes: Gets or sets the spokes group IDs. + :vartype spokes: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar mesh: Gets or sets the mesh group IDs. + :vartype mesh: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'hub': {'key': 'hub', 'type': 'ResourceId'}, + 'spokes': {'key': 'spokes', 'type': '[ResourceId]'}, + 'mesh': {'key': 'mesh', 'type': '[ResourceId]'}, + } + + def __init__( + self, + *, + type: Union[str, "Type"], + hub: Optional["ResourceId"] = None, + spokes: Optional[List["ResourceId"]] = None, + mesh: Optional[List["ResourceId"]] = None, + **kwargs + ): + """ + :keyword type: Required. Gets or sets the connectivity type of a network structure policy. + Possible values include: "HubAndSpokeTopology", "MeshTopology". + :paramtype type: str or ~azure.mgmt.managednetwork.models.Type + :keyword hub: Gets or sets the hub virtual network ID. + :paramtype hub: ~azure.mgmt.managednetwork.models.ResourceId + :keyword spokes: Gets or sets the spokes group IDs. + :paramtype spokes: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword mesh: Gets or sets the mesh group IDs. + :paramtype mesh: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + super(HubAndSpokePeeringPolicyProperties, self).__init__(type=type, hub=hub, spokes=spokes, mesh=mesh, **kwargs) + + +class Resource(msrest.serialization.Model): + """The general resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + + +class TrackedResource(Resource): + """The resource model definition for a ARM tracked top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(TrackedResource, self).__init__(location=location, **kwargs) + self.tags = tags + + +class ManagedNetwork(TrackedResource): + """The Managed Network resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar scope: The collection of management groups, subscriptions, virtual networks, and subnets + by the Managed Network. This is a read-only property that is reflective of all ScopeAssignments + for this Managed Network. + :vartype scope: ~azure.mgmt.managednetwork.models.Scope + :ivar connectivity: The collection of groups and policies concerned with connectivity. + :vartype connectivity: ~azure.mgmt.managednetwork.models.ConnectivityCollection + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + 'connectivity': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'etag': {'key': 'properties.etag', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'connectivity': {'key': 'properties.connectivity', 'type': 'ConnectivityCollection'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + scope: Optional["Scope"] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword scope: The collection of management groups, subscriptions, virtual networks, and + subnets by the Managed Network. This is a read-only property that is reflective of all + ScopeAssignments for this Managed Network. + :paramtype scope: ~azure.mgmt.managednetwork.models.Scope + """ + super(ManagedNetwork, self).__init__(location=location, tags=tags, **kwargs) + self.provisioning_state = None + self.etag = None + self.scope = scope + self.connectivity = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + """ + super(ProxyResource, self).__init__(location=location, **kwargs) + + +class ManagedNetworkGroup(ProxyResource): + """The Managed Network Group resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar kind: Responsibility role under which this Managed Network Group will be created. + Possible values include: "Connectivity". + :vartype kind: str or ~azure.mgmt.managednetwork.models.Kind + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar management_groups: The collection of management groups covered by the Managed Network. + :vartype management_groups: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar subscriptions: The collection of subscriptions covered by the Managed Network. + :vartype subscriptions: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar virtual_networks: The collection of virtual nets covered by the Managed Network. + :vartype virtual_networks: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar subnets: The collection of subnets covered by the Managed Network. + :vartype subnets: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'etag': {'key': 'properties.etag', 'type': 'str'}, + 'management_groups': {'key': 'properties.managementGroups', 'type': '[ResourceId]'}, + 'subscriptions': {'key': 'properties.subscriptions', 'type': '[ResourceId]'}, + 'virtual_networks': {'key': 'properties.virtualNetworks', 'type': '[ResourceId]'}, + 'subnets': {'key': 'properties.subnets', 'type': '[ResourceId]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + kind: Optional[Union[str, "Kind"]] = None, + management_groups: Optional[List["ResourceId"]] = None, + subscriptions: Optional[List["ResourceId"]] = None, + virtual_networks: Optional[List["ResourceId"]] = None, + subnets: Optional[List["ResourceId"]] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword kind: Responsibility role under which this Managed Network Group will be created. + Possible values include: "Connectivity". + :paramtype kind: str or ~azure.mgmt.managednetwork.models.Kind + :keyword management_groups: The collection of management groups covered by the Managed Network. + :paramtype management_groups: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword subscriptions: The collection of subscriptions covered by the Managed Network. + :paramtype subscriptions: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword virtual_networks: The collection of virtual nets covered by the Managed Network. + :paramtype virtual_networks: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword subnets: The collection of subnets covered by the Managed Network. + :paramtype subnets: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + super(ManagedNetworkGroup, self).__init__(location=location, **kwargs) + self.kind = kind + self.provisioning_state = None + self.etag = None + self.management_groups = management_groups + self.subscriptions = subscriptions + self.virtual_networks = virtual_networks + self.subnets = subnets + + +class ManagedNetworkGroupListResult(msrest.serialization.Model): + """Result of the request to list Managed Network Groups. It contains a list of groups and a URL link to get the next set of results. + + :ivar value: Gets a page of ManagedNetworkGroup. + :vartype value: list[~azure.mgmt.managednetwork.models.ManagedNetworkGroup] + :ivar next_link: Gets the URL to get the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedNetworkGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ManagedNetworkGroup"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets a page of ManagedNetworkGroup. + :paramtype value: list[~azure.mgmt.managednetwork.models.ManagedNetworkGroup] + :keyword next_link: Gets the URL to get the next set of results. + :paramtype next_link: str + """ + super(ManagedNetworkGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ManagedNetworkGroupProperties(ResourceProperties): + """Properties of a Managed Network Group. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar management_groups: The collection of management groups covered by the Managed Network. + :vartype management_groups: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar subscriptions: The collection of subscriptions covered by the Managed Network. + :vartype subscriptions: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar virtual_networks: The collection of virtual nets covered by the Managed Network. + :vartype virtual_networks: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar subnets: The collection of subnets covered by the Managed Network. + :vartype subnets: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'management_groups': {'key': 'managementGroups', 'type': '[ResourceId]'}, + 'subscriptions': {'key': 'subscriptions', 'type': '[ResourceId]'}, + 'virtual_networks': {'key': 'virtualNetworks', 'type': '[ResourceId]'}, + 'subnets': {'key': 'subnets', 'type': '[ResourceId]'}, + } + + def __init__( + self, + *, + management_groups: Optional[List["ResourceId"]] = None, + subscriptions: Optional[List["ResourceId"]] = None, + virtual_networks: Optional[List["ResourceId"]] = None, + subnets: Optional[List["ResourceId"]] = None, + **kwargs + ): + """ + :keyword management_groups: The collection of management groups covered by the Managed Network. + :paramtype management_groups: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword subscriptions: The collection of subscriptions covered by the Managed Network. + :paramtype subscriptions: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword virtual_networks: The collection of virtual nets covered by the Managed Network. + :paramtype virtual_networks: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword subnets: The collection of subnets covered by the Managed Network. + :paramtype subnets: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + super(ManagedNetworkGroupProperties, self).__init__(**kwargs) + self.management_groups = management_groups + self.subscriptions = subscriptions + self.virtual_networks = virtual_networks + self.subnets = subnets + + +class ManagedNetworkListResult(msrest.serialization.Model): + """Result of the request to list Managed Network. It contains a list of Managed Networks and a URL link to get the next set of results. + + :ivar value: Gets a page of ManagedNetworks. + :vartype value: list[~azure.mgmt.managednetwork.models.ManagedNetwork] + :ivar next_link: Gets the URL to get the next page of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedNetwork]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ManagedNetwork"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets a page of ManagedNetworks. + :paramtype value: list[~azure.mgmt.managednetwork.models.ManagedNetwork] + :keyword next_link: Gets the URL to get the next page of results. + :paramtype next_link: str + """ + super(ManagedNetworkListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ManagedNetworkPeeringPolicy(ProxyResource): + """The Managed Network Peering Policy resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar properties: Gets or sets the properties of a Managed Network Policy. + :vartype properties: ~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicyProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ManagedNetworkPeeringPolicyProperties'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["ManagedNetworkPeeringPolicyProperties"] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword properties: Gets or sets the properties of a Managed Network Policy. + :paramtype properties: ~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicyProperties + """ + super(ManagedNetworkPeeringPolicy, self).__init__(location=location, **kwargs) + self.properties = properties + + +class ManagedNetworkPeeringPolicyListResult(msrest.serialization.Model): + """Result of the request to list Managed Network Peering Policies. It contains a list of policies and a URL link to get the next set of results. + + :ivar value: Gets a page of Peering Policies. + :vartype value: list[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy] + :ivar next_link: Gets the URL to get the next page of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagedNetworkPeeringPolicy]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ManagedNetworkPeeringPolicy"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets a page of Peering Policies. + :paramtype value: list[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy] + :keyword next_link: Gets the URL to get the next page of results. + :paramtype next_link: str + """ + super(ManagedNetworkPeeringPolicyListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ManagedNetworkProperties(ResourceProperties): + """Properties of Managed Network. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar scope: The collection of management groups, subscriptions, virtual networks, and subnets + by the Managed Network. This is a read-only property that is reflective of all ScopeAssignments + for this Managed Network. + :vartype scope: ~azure.mgmt.managednetwork.models.Scope + :ivar connectivity: The collection of groups and policies concerned with connectivity. + :vartype connectivity: ~azure.mgmt.managednetwork.models.ConnectivityCollection + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + 'connectivity': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'connectivity': {'key': 'connectivity', 'type': 'ConnectivityCollection'}, + } + + def __init__( + self, + *, + scope: Optional["Scope"] = None, + **kwargs + ): + """ + :keyword scope: The collection of management groups, subscriptions, virtual networks, and + subnets by the Managed Network. This is a read-only property that is reflective of all + ScopeAssignments for this Managed Network. + :paramtype scope: ~azure.mgmt.managednetwork.models.Scope + """ + super(ManagedNetworkProperties, self).__init__(**kwargs) + self.scope = scope + self.connectivity = None + + +class ManagedNetworkUpdate(msrest.serialization.Model): + """Update Tags of Managed Network. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(ManagedNetworkUpdate, self).__init__(**kwargs) + self.tags = tags + + +class MeshPeeringPolicyProperties(ManagedNetworkPeeringPolicyProperties): + """Properties of a Mesh Peering Policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar type: Required. Gets or sets the connectivity type of a network structure policy. + Possible values include: "HubAndSpokeTopology", "MeshTopology". + :vartype type: str or ~azure.mgmt.managednetwork.models.Type + :ivar hub: Gets or sets the hub virtual network ID. + :vartype hub: ~azure.mgmt.managednetwork.models.ResourceId + :ivar spokes: Gets or sets the spokes group IDs. + :vartype spokes: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar mesh: Gets or sets the mesh group IDs. + :vartype mesh: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'hub': {'key': 'hub', 'type': 'ResourceId'}, + 'spokes': {'key': 'spokes', 'type': '[ResourceId]'}, + 'mesh': {'key': 'mesh', 'type': '[ResourceId]'}, + } + + def __init__( + self, + *, + type: Union[str, "Type"], + hub: Optional["ResourceId"] = None, + spokes: Optional[List["ResourceId"]] = None, + mesh: Optional[List["ResourceId"]] = None, + **kwargs + ): + """ + :keyword type: Required. Gets or sets the connectivity type of a network structure policy. + Possible values include: "HubAndSpokeTopology", "MeshTopology". + :paramtype type: str or ~azure.mgmt.managednetwork.models.Type + :keyword hub: Gets or sets the hub virtual network ID. + :paramtype hub: ~azure.mgmt.managednetwork.models.ResourceId + :keyword spokes: Gets or sets the spokes group IDs. + :paramtype spokes: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword mesh: Gets or sets the mesh group IDs. + :paramtype mesh: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + super(MeshPeeringPolicyProperties, self).__init__(type=type, hub=hub, spokes=spokes, mesh=mesh, **kwargs) + + +class Operation(msrest.serialization.Model): + """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.managednetwork.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.managednetwork.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.ManagedNetwork. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft.ManagedNetwork. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Managed Network operations. It contains a list of operations and a URL link to get the next set of results. + + :ivar value: List of Resource Provider operations supported by the Managed Network resource + provider. + :vartype value: list[~azure.mgmt.managednetwork.models.Operation] + :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': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of Resource Provider operations supported by the Managed Network resource + provider. + :paramtype value: list[~azure.mgmt.managednetwork.models.Operation] + :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 ResourceId(msrest.serialization.Model): + """Generic pointer to a resource. + + :ivar id: Resource Id. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ + super(ResourceId, self).__init__(**kwargs) + self.id = id + + +class Scope(msrest.serialization.Model): + """Scope of a Managed Network. + + :ivar management_groups: The collection of management groups covered by the Managed Network. + :vartype management_groups: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar subscriptions: The collection of subscriptions covered by the Managed Network. + :vartype subscriptions: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar virtual_networks: The collection of virtual nets covered by the Managed Network. + :vartype virtual_networks: list[~azure.mgmt.managednetwork.models.ResourceId] + :ivar subnets: The collection of subnets covered by the Managed Network. + :vartype subnets: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + + _attribute_map = { + 'management_groups': {'key': 'managementGroups', 'type': '[ResourceId]'}, + 'subscriptions': {'key': 'subscriptions', 'type': '[ResourceId]'}, + 'virtual_networks': {'key': 'virtualNetworks', 'type': '[ResourceId]'}, + 'subnets': {'key': 'subnets', 'type': '[ResourceId]'}, + } + + def __init__( + self, + *, + management_groups: Optional[List["ResourceId"]] = None, + subscriptions: Optional[List["ResourceId"]] = None, + virtual_networks: Optional[List["ResourceId"]] = None, + subnets: Optional[List["ResourceId"]] = None, + **kwargs + ): + """ + :keyword management_groups: The collection of management groups covered by the Managed Network. + :paramtype management_groups: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword subscriptions: The collection of subscriptions covered by the Managed Network. + :paramtype subscriptions: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword virtual_networks: The collection of virtual nets covered by the Managed Network. + :paramtype virtual_networks: list[~azure.mgmt.managednetwork.models.ResourceId] + :keyword subnets: The collection of subnets covered by the Managed Network. + :paramtype subnets: list[~azure.mgmt.managednetwork.models.ResourceId] + """ + super(Scope, self).__init__(**kwargs) + self.management_groups = management_groups + self.subscriptions = subscriptions + self.virtual_networks = virtual_networks + self.subnets = subnets + + +class ScopeAssignment(ProxyResource): + """The Managed Network resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar assigned_managed_network: The managed network ID with scope will be assigned to. + :vartype assigned_managed_network: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'etag': {'key': 'properties.etag', 'type': 'str'}, + 'assigned_managed_network': {'key': 'properties.assignedManagedNetwork', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + assigned_managed_network: Optional[str] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword assigned_managed_network: The managed network ID with scope will be assigned to. + :paramtype assigned_managed_network: str + """ + super(ScopeAssignment, self).__init__(location=location, **kwargs) + self.provisioning_state = None + self.etag = None + self.assigned_managed_network = assigned_managed_network + + +class ScopeAssignmentListResult(msrest.serialization.Model): + """Result of the request to list ScopeAssignment. It contains a list of groups and a URL link to get the next set of results. + + :ivar value: Gets a page of ScopeAssignment. + :vartype value: list[~azure.mgmt.managednetwork.models.ScopeAssignment] + :ivar next_link: Gets the URL to get the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ScopeAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ScopeAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets a page of ScopeAssignment. + :paramtype value: list[~azure.mgmt.managednetwork.models.ScopeAssignment] + :keyword next_link: Gets the URL to get the next set of results. + :paramtype next_link: str + """ + super(ScopeAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ScopeAssignmentProperties(ResourceProperties): + """Properties of Managed Network. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the ManagedNetwork resource. Possible values + include: "Updating", "Deleting", "Failed", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.managednetwork.models.ProvisioningState + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar assigned_managed_network: The managed network ID with scope will be assigned to. + :vartype assigned_managed_network: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'etag': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'assigned_managed_network': {'key': 'assignedManagedNetwork', 'type': 'str'}, + } + + def __init__( + self, + *, + assigned_managed_network: Optional[str] = None, + **kwargs + ): + """ + :keyword assigned_managed_network: The managed network ID with scope will be assigned to. + :paramtype assigned_managed_network: str + """ + super(ScopeAssignmentProperties, self).__init__(**kwargs) + self.assigned_managed_network = assigned_managed_network diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/__init__.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/__init__.py new file mode 100644 index 000000000000..4f382e2b2364 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._managed_networks_operations import ManagedNetworksOperations +from ._scope_assignments_operations import ScopeAssignmentsOperations +from ._managed_network_groups_operations import ManagedNetworkGroupsOperations +from ._managed_network_peering_policies_operations import ManagedNetworkPeeringPoliciesOperations +from ._operations import Operations + +__all__ = [ + 'ManagedNetworksOperations', + 'ScopeAssignmentsOperations', + 'ManagedNetworkGroupsOperations', + 'ManagedNetworkPeeringPoliciesOperations', + 'Operations', +] diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_network_groups_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_network_groups_operations.py new file mode 100644 index 000000000000..071e3afd674b --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_network_groups_operations.py @@ -0,0 +1,624 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, 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, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, 'str'), + "managedNetworkGroupName": _SERIALIZER.url("managed_network_group_name", managed_network_group_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_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, 'str'), + "managedNetworkGroupName": _SERIALIZER.url("managed_network_group_name", managed_network_group_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] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, 'str'), + "managedNetworkGroupName": _SERIALIZER.url("managed_network_group_name", managed_network_group_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="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_managed_network_request( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + *, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_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') + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=20, minimum=1) + if skiptoken is not None: + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, '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 ManagedNetworkGroupsOperations(object): + """ManagedNetworkGroupsOperations 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.managednetwork.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, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any + ) -> "_models.ManagedNetworkGroup": + """The Get ManagedNetworkGroups operation gets a Managed Network Group specified by the resource + group, Managed Network name, and group name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_group_name: The name of the Managed Network Group. + :type managed_network_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetworkGroup, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetworkGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedNetworkGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + managed_network_group: "_models.ManagedNetworkGroup", + **kwargs: Any + ) -> "_models.ManagedNetworkGroup": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(managed_network_group, 'ManagedNetworkGroup') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + 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('ManagedNetworkGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetworkGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + managed_network_group: "_models.ManagedNetworkGroup", + **kwargs: Any + ) -> LROPoller["_models.ManagedNetworkGroup"]: + """The Put ManagedNetworkGroups operation creates or updates a Managed Network Group resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_group_name: The name of the Managed Network Group. + :type managed_network_group_name: str + :param managed_network_group: Parameters supplied to the create/update a Managed Network Group + resource. + :type managed_network_group: ~azure.mgmt.managednetwork.models.ManagedNetworkGroup + :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 ManagedNetworkGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managednetwork.models.ManagedNetworkGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroup"] + 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, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + managed_network_group=managed_network_group, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ManagedNetworkGroup', 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/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """The Delete ManagedNetworkGroups operation deletes a Managed Network Group specified by the + resource group, Managed Network name, and group name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_group_name: The name of the Managed Network Group. + :type managed_network_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_group_name=managed_network_group_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}"} # type: ignore + + @distributed_trace + def list_by_managed_network( + self, + resource_group_name: str, + managed_network_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedNetworkGroupListResult"]: + """The ListByManagedNetwork ManagedNetworkGroup operation retrieves all the Managed Network Groups + in a specified Managed Networks in a paginated format. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkGroupListResult"] + 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_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_managed_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkGroupListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_managed_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_network_peering_policies_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_network_peering_policies_operations.py new file mode 100644 index 000000000000..c92cb1f479bf --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_network_peering_policies_operations.py @@ -0,0 +1,626 @@ +# 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, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, 'str'), + "managedNetworkPeeringPolicyName": _SERIALIZER.url("managed_network_peering_policy_name", managed_network_peering_policy_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_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, 'str'), + "managedNetworkPeeringPolicyName": _SERIALIZER.url("managed_network_peering_policy_name", managed_network_peering_policy_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] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, 'str'), + "managedNetworkPeeringPolicyName": _SERIALIZER.url("managed_network_peering_policy_name", managed_network_peering_policy_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="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_managed_network_request( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + *, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_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') + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=20, minimum=1) + if skiptoken is not None: + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, '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 ManagedNetworkPeeringPoliciesOperations(object): + """ManagedNetworkPeeringPoliciesOperations 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.managednetwork.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, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any + ) -> "_models.ManagedNetworkPeeringPolicy": + """The Get ManagedNetworkPeeringPolicies operation gets a Managed Network Peering Policy resource, + specified by the resource group, Managed Network name, and peering policy name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_peering_policy_name: The name of the Managed Network Peering Policy. + :type managed_network_peering_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetworkPeeringPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedNetworkPeeringPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + managed_network_policy: "_models.ManagedNetworkPeeringPolicy", + **kwargs: Any + ) -> "_models.ManagedNetworkPeeringPolicy": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(managed_network_policy, 'ManagedNetworkPeeringPolicy') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + 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('ManagedNetworkPeeringPolicy', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetworkPeeringPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + managed_network_policy: "_models.ManagedNetworkPeeringPolicy", + **kwargs: Any + ) -> LROPoller["_models.ManagedNetworkPeeringPolicy"]: + """The Put ManagedNetworkPeeringPolicies operation creates/updates a new Managed Network Peering + Policy. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_peering_policy_name: The name of the Managed Network Peering Policy. + :type managed_network_peering_policy_name: str + :param managed_network_policy: Parameters supplied to create/update a Managed Network Peering + Policy. + :type managed_network_policy: ~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy + :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 ManagedNetworkPeeringPolicy or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicy] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicy"] + 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, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + managed_network_policy=managed_network_policy, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ManagedNetworkPeeringPolicy', 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/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + managed_network_peering_policy_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """The Delete ManagedNetworkPeeringPolicies operation deletes a Managed Network Peering Policy, + specified by the resource group, Managed Network name, and peering policy name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network_peering_policy_name: The name of the Managed Network Peering Policy. + :type managed_network_peering_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + managed_network_peering_policy_name=managed_network_peering_policy_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}"} # type: ignore + + @distributed_trace + def list_by_managed_network( + self, + resource_group_name: str, + managed_network_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedNetworkPeeringPolicyListResult"]: + """The ListByManagedNetwork PeeringPolicies operation retrieves all the Managed Network Peering + Policies in a specified Managed Network, in a paginated format. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkPeeringPolicyListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkPeeringPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkPeeringPolicyListResult"] + 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_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_managed_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_managed_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkPeeringPolicyListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_managed_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_networks_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_networks_operations.py new file mode 100644 index 000000000000..93361bcac023 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_managed_networks_operations.py @@ -0,0 +1,837 @@ +# 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, + managed_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_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_create_or_update_request( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_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] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_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="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + managed_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_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] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _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') + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=20, minimum=1) + if skiptoken is not None: + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + *, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedNetwork/managedNetworks") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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') + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=20, minimum=1) + if skiptoken is not None: + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, '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 ManagedNetworksOperations(object): + """ManagedNetworksOperations 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.managednetwork.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, + managed_network_name: str, + **kwargs: Any + ) -> "_models.ManagedNetwork": + """The Get ManagedNetworks operation gets a Managed Network Resource, specified by the resource + group and Managed Network name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_network_name: str, + managed_network: "_models.ManagedNetwork", + **kwargs: Any + ) -> "_models.ManagedNetwork": + """The Put ManagedNetworks operation creates/updates a Managed Network Resource, specified by + resource group and Managed Network name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param managed_network: Parameters supplied to the create/update a Managed Network Resource. + :type managed_network: ~azure.mgmt.managednetwork.models.ManagedNetwork + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ManagedNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(managed_network, 'ManagedNetwork') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_network_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """The Delete ManagedNetworks operation deletes a Managed Network Resource, specified by the + resource group and Managed Network name. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + managed_network_name: str, + parameters: "_models.ManagedNetworkUpdate", + **kwargs: Any + ) -> "_models.ManagedNetwork": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagedNetworkUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + managed_network_name=managed_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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('ManagedNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + managed_network_name: str, + parameters: "_models.ManagedNetworkUpdate", + **kwargs: Any + ) -> LROPoller["_models.ManagedNetwork"]: + """Updates the specified Managed Network resource tags. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param managed_network_name: The name of the Managed Network. + :type managed_network_name: str + :param parameters: Parameters supplied to update application gateway tags and/or scope. + :type parameters: ~azure.mgmt.managednetwork.models.ManagedNetworkUpdate + :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 ManagedNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managednetwork.models.ManagedNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetwork"] + 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, + managed_network_name=managed_network_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ManagedNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedNetworkListResult"]: + """The ListByResourceGroup ManagedNetwork operation retrieves all the Managed Network resources in + a resource group in a paginated format. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedNetworkListResult"]: + """The ListBySubscription ManagedNetwork operation retrieves all the Managed Network Resources in + the current subscription in a paginated format. + + :param top: May be used to limit the number of results in a page for list queries. Default + value is None. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element will include + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ManagedNetworkListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managednetwork.models.ManagedNetworkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedNetworkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + skiptoken=skiptoken, + 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("ManagedNetworkListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedNetwork/managedNetworks"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_operations.py new file mode 100644 index 000000000000..89fad148b417 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_operations.py @@ -0,0 +1,144 @@ +# 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', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ManagedNetwork/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.managednetwork.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"]: + """Lists all of the available MNC operations. + + :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.managednetwork.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ManagedNetwork/operations"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_scope_assignments_operations.py b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_scope_assignments_operations.py new file mode 100644 index 000000000000..69dfde0ca24d --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/operations/_scope_assignments_operations.py @@ -0,0 +1,448 @@ +# 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, _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( + scope: str, + scope_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scopeAssignmentName": _SERIALIZER.url("scope_assignment_name", scope_assignment_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_create_or_update_request( + scope: str, + scope_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scopeAssignmentName": _SERIALIZER.url("scope_assignment_name", scope_assignment_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] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + scope_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scopeAssignmentName": _SERIALIZER.url("scope_assignment_name", scope_assignment_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') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_list_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _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 ScopeAssignmentsOperations(object): + """ScopeAssignmentsOperations 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.managednetwork.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, + scope: str, + scope_assignment_name: str, + **kwargs: Any + ) -> "_models.ScopeAssignment": + """Get the specified scope assignment. + + :param scope: The base resource of the scope assignment. + :type scope: str + :param scope_assignment_name: The name of the scope assignment to get. + :type scope_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ScopeAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_get_request( + scope=scope, + scope_assignment_name=scope_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ScopeAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + scope: str, + scope_assignment_name: str, + parameters: "_models.ScopeAssignment", + **kwargs: Any + ) -> "_models.ScopeAssignment": + """Creates a scope assignment. + + :param scope: The base resource of the scope assignment to create. The scope can be any REST + resource instance. For example, use 'subscriptions/{subscription-id}' for a subscription, + 'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, + and + 'subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' + for a resource. + :type scope: str + :param scope_assignment_name: The name of the scope assignment to create. + :type scope_assignment_name: str + :param parameters: Parameters supplied to the specify which Managed Network this scope is being + assigned. + :type parameters: ~azure.mgmt.managednetwork.models.ScopeAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.managednetwork.models.ScopeAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopeAssignment') + + request = build_create_or_update_request( + scope=scope, + scope_assignment_name=scope_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ScopeAssignment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ScopeAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + scope: str, + scope_assignment_name: str, + **kwargs: Any + ) -> None: + """Deletes a scope assignment. + + :param scope: The scope of the scope assignment to delete. + :type scope: str + :param scope_assignment_name: The name of the scope assignment to delete. + :type scope_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + + request = build_delete_request( + scope=scope, + scope_assignment_name=scope_assignment_name, + api_version=api_version, + template_url=self.delete.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}"} # type: ignore + + + @distributed_trace + def list( + self, + scope: str, + **kwargs: Any + ) -> Iterable["_models.ScopeAssignmentListResult"]: + """Get the specified scope assignment. + + :param scope: The base resource of the scope assignment. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScopeAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managednetwork.models.ScopeAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeAssignmentListResult"] + 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( + scope=scope, + 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( + scope=scope, + 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("ScopeAssignmentListResult", 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments"} # type: ignore diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/py.typed b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/azure/mgmt/managednetwork/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/sdk_packaging.toml b/sdk/managednetwork/azure-mgmt-managednetwork/sdk_packaging.toml new file mode 100644 index 000000000000..016ee893fdbc --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-managednetwork" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/managednetwork/azure-mgmt-managednetwork/setup.py b/sdk/managednetwork/azure-mgmt-managednetwork/setup.py new file mode 100644 index 000000000000..6f1968759237 --- /dev/null +++ b/sdk/managednetwork/azure-mgmt-managednetwork/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-managednetwork" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + 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/managednetwork/ci.yml b/sdk/managednetwork/ci.yml new file mode 100644 index 000000000000..58f08285a824 --- /dev/null +++ b/sdk/managednetwork/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/managednetwork/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/managednetwork/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: managednetwork + Artifacts: + - name: azure-mgmt-managednetwork + safeName: azuremgmtmanagednetwork