From 7dd04cb31612e49b41e095832d9f2c3449435822 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 15 Mar 2022 08:33:06 +0000 Subject: [PATCH] CodeGen from PR 18229 in Azure/azure-rest-api-specs Merge cba6c8790f19cebf81fa7104a249ee795c945216 into 5f211aa39ff4fa8891fbdf7da840d13ef8ac5fcd --- sdk/peering/azure-mgmt-peering/_meta.json | 11 +- .../azure/mgmt/peering/__init__.py | 9 +- .../azure/mgmt/peering/_configuration.py | 21 +- .../azure/mgmt/peering/_metadata.json | 45 +- .../azure/mgmt/peering/_patch.py | 31 + .../peering/_peering_management_client.py | 144 +- .../azure/mgmt/peering/_vendor.py | 27 + .../azure/mgmt/peering/_version.py | 2 +- .../azure/mgmt/peering/aio/__init__.py | 5 + .../azure/mgmt/peering/aio/_configuration.py | 8 +- .../azure/mgmt/peering/aio/_patch.py | 31 + .../peering/aio/_peering_management_client.py | 130 +- .../mgmt/peering/aio/operations/__init__.py | 16 +- .../_cdn_peering_prefixes_operations.py | 118 ++ .../_connection_monitor_tests_operations.py | 303 +++ .../operations/_legacy_peerings_operations.py | 69 +- .../operations/_looking_glass_operations.py | 105 + .../peering/aio/operations/_operations.py | 46 +- .../aio/operations/_peer_asns_operations.py | 160 +- .../_peering_locations_operations.py | 75 +- .../_peering_management_client_operations.py | 52 +- .../_peering_service_countries_operations.py | 113 ++ .../_peering_service_locations_operations.py | 67 +- .../_peering_service_prefixes_operations.py | 239 --- .../_peering_service_providers_operations.py | 60 +- .../_peering_services_operations.py | 309 +-- .../aio/operations/_peerings_operations.py | 257 ++- .../aio/operations/_prefixes_operations.py | 262 ++- .../operations/_received_routes_operations.py | 152 ++ .../operations/_registered_asns_operations.py | 302 +++ .../_registered_prefixes_operations.py | 302 +++ .../azure/mgmt/peering/models/__init__.py | 169 +- .../azure/mgmt/peering/models/_models.py | 1191 ------------ .../azure/mgmt/peering/models/_models_py3.py | 1726 ++++++++++++++--- .../_peering_management_client_enums.py | 129 +- .../azure/mgmt/peering/operations/__init__.py | 16 +- .../_cdn_peering_prefixes_operations.py | 152 ++ .../_connection_monitor_tests_operations.py | 460 +++++ .../operations/_legacy_peerings_operations.py | 124 +- .../operations/_looking_glass_operations.py | 147 ++ .../mgmt/peering/operations/_operations.py | 85 +- .../operations/_peer_asns_operations.py | 331 ++-- .../_peering_locations_operations.py | 123 +- .../_peering_management_client_operations.py | 108 +- .../_peering_service_countries_operations.py | 145 ++ .../_peering_service_locations_operations.py | 116 +- .../_peering_service_prefixes_operations.py | 246 --- .../_peering_service_providers_operations.py | 105 +- .../_peering_services_operations.py | 608 ++++-- .../operations/_peerings_operations.py | 531 +++-- .../operations/_prefixes_operations.py | 437 ++++- .../operations/_received_routes_operations.py | 203 ++ .../operations/_registered_asns_operations.py | 458 +++++ .../_registered_prefixes_operations.py | 459 +++++ 54 files changed, 7972 insertions(+), 3568 deletions(-) create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_patch.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_vendor.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_patch.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_cdn_peering_prefixes_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_connection_monitor_tests_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_looking_glass_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_countries_operations.py delete mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_prefixes_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_received_routes_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_asns_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_prefixes_operations.py delete mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_cdn_peering_prefixes_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_connection_monitor_tests_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_looking_glass_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_countries_operations.py delete mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_prefixes_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_received_routes_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_asns_operations.py create mode 100644 sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_prefixes_operations.py diff --git a/sdk/peering/azure-mgmt-peering/_meta.json b/sdk/peering/azure-mgmt-peering/_meta.json index 0b99ef6e37e6..529ed0ac5063 100644 --- a/sdk/peering/azure-mgmt-peering/_meta.json +++ b/sdk/peering/azure-mgmt-peering/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "e304f0d89247ec7d983167f5cfa6ed975a5e8a12", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "7abc4511b9cac664f6d977b6c5de789dabe45c1a", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/peering/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "autorest_command": "autorest specification/peering/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/peering/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/__init__.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/__init__.py index c0f79fcd0b4f..b3c7bb504960 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/__init__.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PeeringManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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/peering/azure-mgmt-peering/azure/mgmt/peering/_configuration.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_configuration.py index 4bfcbfb84f3a..92cb07ed6305 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_configuration.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,20 +33,19 @@ class PeeringManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(PeeringManagementClientConfiguration, self).__init__(**kwargs) 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.") - super(PeeringManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-08-01-preview" + self.api_version = "2022-01-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-peering/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +65,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_metadata.json b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_metadata.json index 6edfed47f4b3..d89aaa3eddc9 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_metadata.json +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2019-08-01-preview", - "total_api_version_list": ["2019-08-01-preview"], + "chosen_version": "2022-01-01", + "total_api_version_list": ["2022-01-01"], "client": { "name": "PeeringManagementClient", "filename": "_peering_management_client", "description": "Peering Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PeeringManagementClientConfiguration\"], \"._operations_mixin\": [\"PeeringManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PeeringManagementClientConfiguration\"], \"._operations_mixin\": [\"PeeringManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PeeringManagementClientConfiguration\"], \"._operations_mixin\": [\"PeeringManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PeeringManagementClientConfiguration\"], \"._operations_mixin\": [\"PeeringManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,37 +91,42 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { + "cdn_peering_prefixes": "CdnPeeringPrefixesOperations", "legacy_peerings": "LegacyPeeringsOperations", + "looking_glass": "LookingGlassOperations", "operations": "Operations", "peer_asns": "PeerAsnsOperations", "peering_locations": "PeeringLocationsOperations", + "registered_asns": "RegisteredAsnsOperations", + "registered_prefixes": "RegisteredPrefixesOperations", "peerings": "PeeringsOperations", + "received_routes": "ReceivedRoutesOperations", + "connection_monitor_tests": "ConnectionMonitorTestsOperations", + "peering_service_countries": "PeeringServiceCountriesOperations", "peering_service_locations": "PeeringServiceLocationsOperations", - "peering_service_prefixes": "PeeringServicePrefixesOperations", "prefixes": "PrefixesOperations", "peering_service_providers": "PeeringServiceProvidersOperations", "peering_services": "PeeringServicesOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\", \"Union\"]}}}", "operations": { "check_service_provider_availability" : { "sync": { - "signature": "def check_service_provider_availability(\n self,\n check_service_provider_availability_input, # type: \"_models.CheckServiceProviderAvailabilityInput\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks if the peering service provider is present within 1000 miles of customer\u0027s location.\n\n:param check_service_provider_availability_input: The CheckServiceProviderAvailabilityInput\n indicating customer location and service provider.\n:type check_service_provider_availability_input: ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Enum0, or the result of cls(response)\n:rtype: str or ~azure.mgmt.peering.models.Enum0\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_service_provider_availability(\n self,\n check_service_provider_availability_input, # type: \"_models.CheckServiceProviderAvailabilityInput\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e Union[str, \"_models.Enum0\"]\n", + "doc": "\"\"\"Checks if the peering service provider is present within 1000 miles of customer\u0027s location.\n\n:param check_service_provider_availability_input: The CheckServiceProviderAvailabilityInput\n indicating customer location and service provider.\n:type check_service_provider_availability_input:\n ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Enum0, or the result of cls(response)\n:rtype: str or ~azure.mgmt.peering.models.Enum0\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, - "signature": "async def check_service_provider_availability(\n self,\n check_service_provider_availability_input: \"_models.CheckServiceProviderAvailabilityInput\",\n **kwargs\n) -\u003e Union[str, \"_models.Enum0\"]:\n", - "doc": "\"\"\"Checks if the peering service provider is present within 1000 miles of customer\u0027s location.\n\n:param check_service_provider_availability_input: The CheckServiceProviderAvailabilityInput\n indicating customer location and service provider.\n:type check_service_provider_availability_input: ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Enum0, or the result of cls(response)\n:rtype: str or ~azure.mgmt.peering.models.Enum0\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "async def check_service_provider_availability(\n self,\n check_service_provider_availability_input: \"_models.CheckServiceProviderAvailabilityInput\",\n **kwargs: Any\n) -\u003e Union[str, \"_models.Enum0\"]:\n", + "doc": "\"\"\"Checks if the peering service provider is present within 1000 miles of customer\u0027s location.\n\n:param check_service_provider_availability_input: The CheckServiceProviderAvailabilityInput\n indicating customer location and service provider.\n:type check_service_provider_availability_input:\n ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Enum0, or the result of cls(response)\n:rtype: str or ~azure.mgmt.peering.models.Enum0\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "check_service_provider_availability_input" } diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_patch.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_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/peering/azure-mgmt-peering/azure/mgmt/peering/_peering_management_client.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_peering_management_client.py index 84c4d27846ed..d5fa7ee816a3 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_peering_management_client.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_peering_management_client.py @@ -6,119 +6,125 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PeeringManagementClientConfiguration +from .operations import CdnPeeringPrefixesOperations, ConnectionMonitorTestsOperations, LegacyPeeringsOperations, LookingGlassOperations, Operations, PeerAsnsOperations, PeeringLocationsOperations, PeeringManagementClientOperationsMixin, PeeringServiceCountriesOperations, PeeringServiceLocationsOperations, PeeringServiceProvidersOperations, PeeringServicesOperations, PeeringsOperations, PrefixesOperations, ReceivedRoutesOperations, RegisteredAsnsOperations, RegisteredPrefixesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PeeringManagementClientConfiguration -from .operations import PeeringManagementClientOperationsMixin -from .operations import LegacyPeeringsOperations -from .operations import Operations -from .operations import PeerAsnsOperations -from .operations import PeeringLocationsOperations -from .operations import PeeringsOperations -from .operations import PeeringServiceLocationsOperations -from .operations import PeeringServicePrefixesOperations -from .operations import PrefixesOperations -from .operations import PeeringServiceProvidersOperations -from .operations import PeeringServicesOperations -from . import models - class PeeringManagementClient(PeeringManagementClientOperationsMixin): """Peering Client. + :ivar cdn_peering_prefixes: CdnPeeringPrefixesOperations operations + :vartype cdn_peering_prefixes: azure.mgmt.peering.operations.CdnPeeringPrefixesOperations :ivar legacy_peerings: LegacyPeeringsOperations operations :vartype legacy_peerings: azure.mgmt.peering.operations.LegacyPeeringsOperations + :ivar looking_glass: LookingGlassOperations operations + :vartype looking_glass: azure.mgmt.peering.operations.LookingGlassOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.peering.operations.Operations :ivar peer_asns: PeerAsnsOperations operations :vartype peer_asns: azure.mgmt.peering.operations.PeerAsnsOperations :ivar peering_locations: PeeringLocationsOperations operations :vartype peering_locations: azure.mgmt.peering.operations.PeeringLocationsOperations + :ivar registered_asns: RegisteredAsnsOperations operations + :vartype registered_asns: azure.mgmt.peering.operations.RegisteredAsnsOperations + :ivar registered_prefixes: RegisteredPrefixesOperations operations + :vartype registered_prefixes: azure.mgmt.peering.operations.RegisteredPrefixesOperations :ivar peerings: PeeringsOperations operations :vartype peerings: azure.mgmt.peering.operations.PeeringsOperations + :ivar received_routes: ReceivedRoutesOperations operations + :vartype received_routes: azure.mgmt.peering.operations.ReceivedRoutesOperations + :ivar connection_monitor_tests: ConnectionMonitorTestsOperations operations + :vartype connection_monitor_tests: + azure.mgmt.peering.operations.ConnectionMonitorTestsOperations + :ivar peering_service_countries: PeeringServiceCountriesOperations operations + :vartype peering_service_countries: + azure.mgmt.peering.operations.PeeringServiceCountriesOperations :ivar peering_service_locations: PeeringServiceLocationsOperations operations - :vartype peering_service_locations: azure.mgmt.peering.operations.PeeringServiceLocationsOperations - :ivar peering_service_prefixes: PeeringServicePrefixesOperations operations - :vartype peering_service_prefixes: azure.mgmt.peering.operations.PeeringServicePrefixesOperations + :vartype peering_service_locations: + azure.mgmt.peering.operations.PeeringServiceLocationsOperations :ivar prefixes: PrefixesOperations operations :vartype prefixes: azure.mgmt.peering.operations.PrefixesOperations :ivar peering_service_providers: PeeringServiceProvidersOperations operations - :vartype peering_service_providers: azure.mgmt.peering.operations.PeeringServiceProvidersOperations + :vartype peering_service_providers: + azure.mgmt.peering.operations.PeeringServiceProvidersOperations :ivar peering_services: PeeringServicesOperations operations :vartype peering_services: azure.mgmt.peering.operations.PeeringServicesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PeeringManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = PeeringManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.legacy_peerings = LegacyPeeringsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.peer_asns = PeerAsnsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_locations = PeeringLocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peerings = PeeringsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_service_locations = PeeringServiceLocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_service_prefixes = PeeringServicePrefixesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.prefixes = PrefixesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_service_providers = PeeringServiceProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_services = PeeringServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.cdn_peering_prefixes = CdnPeeringPrefixesOperations(self._client, self._config, self._serialize, self._deserialize) + self.legacy_peerings = LegacyPeeringsOperations(self._client, self._config, self._serialize, self._deserialize) + self.looking_glass = LookingGlassOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.peer_asns = PeerAsnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_locations = PeeringLocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registered_asns = RegisteredAsnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registered_prefixes = RegisteredPrefixesOperations(self._client, self._config, self._serialize, self._deserialize) + self.peerings = PeeringsOperations(self._client, self._config, self._serialize, self._deserialize) + self.received_routes = ReceivedRoutesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connection_monitor_tests = ConnectionMonitorTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_service_countries = PeeringServiceCountriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_service_locations = PeeringServiceLocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.prefixes = PrefixesOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_service_providers = PeeringServiceProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_services = PeeringServicesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_vendor.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_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/peering/azure-mgmt-peering/azure/mgmt/peering/_version.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_version.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/__init__.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/__init__.py index 0a779308d8f0..b9f923203f40 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/__init__.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/__init__.py @@ -8,3 +8,8 @@ from ._peering_management_client import PeeringManagementClient __all__ = ['PeeringManagementClient'] + +# `._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/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_configuration.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_configuration.py index 52b4e0ae8333..b87d0f28f594 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_configuration.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PeeringManagementClientConfiguration, self).__init__(**kwargs) 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.") - super(PeeringManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-08-01-preview" + self.api_version = "2022-01-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-peering/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_patch.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/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/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_peering_management_client.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_peering_management_client.py index 1d6c6e5e7219..6ffe497bb9e7 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_peering_management_client.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/_peering_management_client.py @@ -6,115 +6,125 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PeeringManagementClientConfiguration +from .operations import CdnPeeringPrefixesOperations, ConnectionMonitorTestsOperations, LegacyPeeringsOperations, LookingGlassOperations, Operations, PeerAsnsOperations, PeeringLocationsOperations, PeeringManagementClientOperationsMixin, PeeringServiceCountriesOperations, PeeringServiceLocationsOperations, PeeringServiceProvidersOperations, PeeringServicesOperations, PeeringsOperations, PrefixesOperations, ReceivedRoutesOperations, RegisteredAsnsOperations, RegisteredPrefixesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PeeringManagementClientConfiguration -from .operations import PeeringManagementClientOperationsMixin -from .operations import LegacyPeeringsOperations -from .operations import Operations -from .operations import PeerAsnsOperations -from .operations import PeeringLocationsOperations -from .operations import PeeringsOperations -from .operations import PeeringServiceLocationsOperations -from .operations import PeeringServicePrefixesOperations -from .operations import PrefixesOperations -from .operations import PeeringServiceProvidersOperations -from .operations import PeeringServicesOperations -from .. import models - - class PeeringManagementClient(PeeringManagementClientOperationsMixin): """Peering Client. + :ivar cdn_peering_prefixes: CdnPeeringPrefixesOperations operations + :vartype cdn_peering_prefixes: azure.mgmt.peering.aio.operations.CdnPeeringPrefixesOperations :ivar legacy_peerings: LegacyPeeringsOperations operations :vartype legacy_peerings: azure.mgmt.peering.aio.operations.LegacyPeeringsOperations + :ivar looking_glass: LookingGlassOperations operations + :vartype looking_glass: azure.mgmt.peering.aio.operations.LookingGlassOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.peering.aio.operations.Operations :ivar peer_asns: PeerAsnsOperations operations :vartype peer_asns: azure.mgmt.peering.aio.operations.PeerAsnsOperations :ivar peering_locations: PeeringLocationsOperations operations :vartype peering_locations: azure.mgmt.peering.aio.operations.PeeringLocationsOperations + :ivar registered_asns: RegisteredAsnsOperations operations + :vartype registered_asns: azure.mgmt.peering.aio.operations.RegisteredAsnsOperations + :ivar registered_prefixes: RegisteredPrefixesOperations operations + :vartype registered_prefixes: azure.mgmt.peering.aio.operations.RegisteredPrefixesOperations :ivar peerings: PeeringsOperations operations :vartype peerings: azure.mgmt.peering.aio.operations.PeeringsOperations + :ivar received_routes: ReceivedRoutesOperations operations + :vartype received_routes: azure.mgmt.peering.aio.operations.ReceivedRoutesOperations + :ivar connection_monitor_tests: ConnectionMonitorTestsOperations operations + :vartype connection_monitor_tests: + azure.mgmt.peering.aio.operations.ConnectionMonitorTestsOperations + :ivar peering_service_countries: PeeringServiceCountriesOperations operations + :vartype peering_service_countries: + azure.mgmt.peering.aio.operations.PeeringServiceCountriesOperations :ivar peering_service_locations: PeeringServiceLocationsOperations operations - :vartype peering_service_locations: azure.mgmt.peering.aio.operations.PeeringServiceLocationsOperations - :ivar peering_service_prefixes: PeeringServicePrefixesOperations operations - :vartype peering_service_prefixes: azure.mgmt.peering.aio.operations.PeeringServicePrefixesOperations + :vartype peering_service_locations: + azure.mgmt.peering.aio.operations.PeeringServiceLocationsOperations :ivar prefixes: PrefixesOperations operations :vartype prefixes: azure.mgmt.peering.aio.operations.PrefixesOperations :ivar peering_service_providers: PeeringServiceProvidersOperations operations - :vartype peering_service_providers: azure.mgmt.peering.aio.operations.PeeringServiceProvidersOperations + :vartype peering_service_providers: + azure.mgmt.peering.aio.operations.PeeringServiceProvidersOperations :ivar peering_services: PeeringServicesOperations operations :vartype peering_services: azure.mgmt.peering.aio.operations.PeeringServicesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = PeeringManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = PeeringManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.cdn_peering_prefixes = CdnPeeringPrefixesOperations(self._client, self._config, self._serialize, self._deserialize) + self.legacy_peerings = LegacyPeeringsOperations(self._client, self._config, self._serialize, self._deserialize) + self.looking_glass = LookingGlassOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.peer_asns = PeerAsnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_locations = PeeringLocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registered_asns = RegisteredAsnsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registered_prefixes = RegisteredPrefixesOperations(self._client, self._config, self._serialize, self._deserialize) + self.peerings = PeeringsOperations(self._client, self._config, self._serialize, self._deserialize) + self.received_routes = ReceivedRoutesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connection_monitor_tests = ConnectionMonitorTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_service_countries = PeeringServiceCountriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_service_locations = PeeringServiceLocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.prefixes = PrefixesOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_service_providers = PeeringServiceProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.peering_services = PeeringServicesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.legacy_peerings = LegacyPeeringsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.peer_asns = PeerAsnsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_locations = PeeringLocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peerings = PeeringsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_service_locations = PeeringServiceLocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_service_prefixes = PeeringServicePrefixesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.prefixes = PrefixesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_service_providers = PeeringServiceProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.peering_services = PeeringServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/__init__.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/__init__.py index 2c62d44850a9..ceb6794fa18e 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/__init__.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/__init__.py @@ -6,27 +6,39 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._cdn_peering_prefixes_operations import CdnPeeringPrefixesOperations from ._peering_management_client_operations import PeeringManagementClientOperationsMixin from ._legacy_peerings_operations import LegacyPeeringsOperations +from ._looking_glass_operations import LookingGlassOperations from ._operations import Operations from ._peer_asns_operations import PeerAsnsOperations from ._peering_locations_operations import PeeringLocationsOperations +from ._registered_asns_operations import RegisteredAsnsOperations +from ._registered_prefixes_operations import RegisteredPrefixesOperations from ._peerings_operations import PeeringsOperations +from ._received_routes_operations import ReceivedRoutesOperations +from ._connection_monitor_tests_operations import ConnectionMonitorTestsOperations +from ._peering_service_countries_operations import PeeringServiceCountriesOperations from ._peering_service_locations_operations import PeeringServiceLocationsOperations -from ._peering_service_prefixes_operations import PeeringServicePrefixesOperations from ._prefixes_operations import PrefixesOperations from ._peering_service_providers_operations import PeeringServiceProvidersOperations from ._peering_services_operations import PeeringServicesOperations __all__ = [ + 'CdnPeeringPrefixesOperations', 'PeeringManagementClientOperationsMixin', 'LegacyPeeringsOperations', + 'LookingGlassOperations', 'Operations', 'PeerAsnsOperations', 'PeeringLocationsOperations', + 'RegisteredAsnsOperations', + 'RegisteredPrefixesOperations', 'PeeringsOperations', + 'ReceivedRoutesOperations', + 'ConnectionMonitorTestsOperations', + 'PeeringServiceCountriesOperations', 'PeeringServiceLocationsOperations', - 'PeeringServicePrefixesOperations', 'PrefixesOperations', 'PeeringServiceProvidersOperations', 'PeeringServicesOperations', diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_cdn_peering_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_cdn_peering_prefixes_operations.py new file mode 100644 index 000000000000..38623051c07e --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_cdn_peering_prefixes_operations.py @@ -0,0 +1,118 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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._cdn_peering_prefixes_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CdnPeeringPrefixesOperations: + """CdnPeeringPrefixesOperations 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.peering.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, + peering_location: str, + **kwargs: Any + ) -> AsyncIterable["_models.CdnPeeringPrefixListResult"]: + """Lists all of the advertised prefixes for the specified peering location. + + :param peering_location: The peering location. + :type peering_location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CdnPeeringPrefixListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.CdnPeeringPrefixListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CdnPeeringPrefixListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + 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("CdnPeeringPrefixListResult", 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(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': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/cdnPeeringPrefixes'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_connection_monitor_tests_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_connection_monitor_tests_operations.py new file mode 100644 index 000000000000..7de67ccef3e7 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_connection_monitor_tests_operations.py @@ -0,0 +1,303 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +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._connection_monitor_tests_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_peering_service_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConnectionMonitorTestsOperations: + """ConnectionMonitorTestsOperations 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.peering.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, + peering_service_name: str, + connection_monitor_test_name: str, + **kwargs: Any + ) -> "_models.ConnectionMonitorTest": + """Gets an existing connection monitor test with the specified name under the given subscription, + resource group and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param connection_monitor_test_name: The name of the connection monitor test. + :type connection_monitor_test_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectionMonitorTest, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.ConnectionMonitorTest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionMonitorTest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + connection_monitor_test_name=connection_monitor_test_name, + subscription_id=self._config.subscription_id, + 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(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('ConnectionMonitorTest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + connection_monitor_test: "_models.ConnectionMonitorTest", + **kwargs: Any + ) -> "_models.ConnectionMonitorTest": + """Creates or updates a connection monitor test with the specified name under the given + subscription, resource group and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param connection_monitor_test_name: The name of the connection monitor test. + :type connection_monitor_test_name: str + :param connection_monitor_test: The properties needed to create a connection monitor test. + :type connection_monitor_test: ~azure.mgmt.peering.models.ConnectionMonitorTest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectionMonitorTest, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.ConnectionMonitorTest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionMonitorTest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(connection_monitor_test, 'ConnectionMonitorTest') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + connection_monitor_test_name=connection_monitor_test_name, + subscription_id=self._config.subscription_id, + 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(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('ConnectionMonitorTest', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConnectionMonitorTest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing connection monitor test with the specified name under the given + subscription, resource group and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param connection_monitor_test_name: The name of the connection monitor test. + :type connection_monitor_test_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + connection_monitor_test_name=connection_monitor_test_name, + subscription_id=self._config.subscription_id, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}'} # type: ignore + + + @distributed_trace + def list_by_peering_service( + self, + resource_group_name: str, + peering_service_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ConnectionMonitorTestListResult"]: + """Lists all connection monitor tests under the given subscription, resource group and peering + service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectionMonitorTestListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.ConnectionMonitorTestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionMonitorTestListResult"] + 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_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_peering_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectionMonitorTestListResult", 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(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_peering_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_legacy_peerings_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_legacy_peerings_operations.py index c11197e94e75..abaadcec01b1 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_legacy_peerings_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_legacy_peerings_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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, HttpRequest +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._legacy_peerings_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, peering_location: str, - kind: Union[str, "_models.Enum1"], - **kwargs + kind: Union[str, "_models.LegacyPeeringsKind"], + asn: Optional[int] = None, + **kwargs: Any ) -> AsyncIterable["_models.PeeringListResult"]: """Lists all of the legacy peerings under the given subscription matching the specified kind and location. @@ -53,7 +60,9 @@ def list( :param peering_location: The location of the peering. :type peering_location: str :param kind: The kind of the peering. - :type kind: str or ~azure.mgmt.peering.models.Enum1 + :type kind: str or ~azure.mgmt.peering.models.LegacyPeeringsKind + :param asn: The ASN number associated with a legacy peering. + :type asn: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PeeringListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringListResult] @@ -64,36 +73,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['peeringLocation'] = self._serialize.query("peering_location", peering_location, 'str') - query_parameters['kind'] = self._serialize.query("kind", kind, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + kind=kind, + asn=asn, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + kind=kind, + asn=asn, + 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('PeeringListResult', pipeline_response) + deserialized = self._deserialize("PeeringListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,12 +114,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_looking_glass_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_looking_glass_operations.py new file mode 100644 index 000000000000..717d512f3131 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_looking_glass_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +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_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._looking_glass_operations import build_invoke_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LookingGlassOperations: + """LookingGlassOperations 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.peering.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 invoke( + self, + command: Union[str, "_models.LookingGlassCommand"], + source_type: Union[str, "_models.LookingGlassSourceType"], + source_location: str, + destination_ip: str, + **kwargs: Any + ) -> "_models.LookingGlassOutput": + """Run looking glass functionality. + + :param command: The command to be executed: ping, traceroute, bgpRoute. + :type command: str or ~azure.mgmt.peering.models.LookingGlassCommand + :param source_type: The type of the source: Edge site or Azure Region. + :type source_type: str or ~azure.mgmt.peering.models.LookingGlassSourceType + :param source_location: The location of the source. + :type source_location: str + :param destination_ip: The IP address of the destination. + :type destination_ip: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LookingGlassOutput, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.LookingGlassOutput + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LookingGlassOutput"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_invoke_request( + subscription_id=self._config.subscription_id, + command=command, + source_type=source_type, + source_location=source_location, + destination_ip=destination_ip, + template_url=self.invoke.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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('LookingGlassOutput', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + invoke.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/lookingGlass'} # type: ignore + diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_operations.py index 5d790b1b2369..364a0e69f018 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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, HttpRequest +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._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,9 +46,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available API operations for peering resources. @@ -57,30 +63,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + 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) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +96,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peer_asns_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peer_asns_operations.py index 5f994e2648d4..9d865467630f 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peer_asns_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peer_asns_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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, HttpRequest +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._peer_asns_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,10 +46,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, peer_asn_name: str, - **kwargs + **kwargs: Any ) -> "_models.PeerAsn": """Gets the peer ASN with the specified name under the given subscription. @@ -60,32 +66,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'peerAsnName': self._serialize.url("peer_asn_name", peer_asn_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + peer_asn_name=peer_asn_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PeerAsn', pipeline_response) @@ -94,13 +90,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, peer_asn_name: str, peer_asn: "_models.PeerAsn", - **kwargs + **kwargs: Any ) -> "_models.PeerAsn": """Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription. @@ -119,37 +118,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'peerAsnName': self._serialize.url("peer_asn_name", peer_asn_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(peer_asn, 'PeerAsn') + + request = build_create_or_update_request( + peer_asn_name=peer_asn_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peer_asn, 'PeerAsn') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -162,12 +151,15 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}'} # type: ignore + + @distributed_trace_async async def delete( self, peer_asn_name: str, - **kwargs + **kwargs: Any ) -> None: """Deletes an existing peer ASN with the specified name under the given subscription. @@ -183,32 +175,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'peerAsnName': self._serialize.url("peer_asn_name", peer_asn_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + peer_asn_name=peer_asn_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -216,9 +198,11 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PeerAsnListResult"]: """Lists all of the peer ASNs under the given subscription. @@ -232,34 +216,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PeerAsnListResult', pipeline_response) + deserialized = self._deserialize("PeerAsnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,12 +251,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_locations_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_locations_operations.py index f58059bf6026..9759d6cd0825 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_locations_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_locations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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, HttpRequest +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._peering_locations_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,21 +46,24 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - kind: Union[str, "_models.Enum14"], - direct_peering_type: Optional[Union[str, "_models.Enum15"]] = None, - **kwargs + kind: Union[str, "_models.PeeringLocationsKind"], + direct_peering_type: Optional[Union[str, "_models.PeeringLocationsDirectPeeringType"]] = None, + **kwargs: Any ) -> AsyncIterable["_models.PeeringLocationListResult"]: """Lists all of the available peering locations for the specified kind of peering. :param kind: The kind of the peering. - :type kind: str or ~azure.mgmt.peering.models.Enum14 + :type kind: str or ~azure.mgmt.peering.models.PeeringLocationsKind :param direct_peering_type: The type of direct peering. - :type direct_peering_type: str or ~azure.mgmt.peering.models.Enum15 + :type direct_peering_type: str or ~azure.mgmt.peering.models.PeeringLocationsDirectPeeringType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringLocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringLocationListResult] + :return: An iterator like instance of either PeeringLocationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringLocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringLocationListResult"] @@ -63,37 +71,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['kind'] = self._serialize.query("kind", kind, 'str') - if direct_peering_type is not None: - query_parameters['directPeeringType'] = self._serialize.query("direct_peering_type", direct_peering_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + kind=kind, + direct_peering_type=direct_peering_type, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + kind=kind, + direct_peering_type=direct_peering_type, + 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('PeeringLocationListResult', pipeline_response) + deserialized = self._deserialize("PeeringLocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,12 +110,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_management_client_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_management_client_operations.py index 1add2531d0f3..68b77eaa8ee9 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_management_client_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_management_client_operations.py @@ -5,31 +5,37 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +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._peering_management_client_operations import build_check_service_provider_availability_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PeeringManagementClientOperationsMixin: + @distributed_trace_async async def check_service_provider_availability( self, check_service_provider_availability_input: "_models.CheckServiceProviderAvailabilityInput", - **kwargs + **kwargs: Any ) -> Union[str, "_models.Enum0"]: """Checks if the peering service provider is present within 1000 miles of customer's location. :param check_service_provider_availability_input: The CheckServiceProviderAvailabilityInput - indicating customer location and service provider. - :type check_service_provider_availability_input: ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput + indicating customer location and service provider. + :type check_service_provider_availability_input: + ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput :keyword callable cls: A custom type or function that will be passed the direct response :return: Enum0, or the result of cls(response) :rtype: str or ~azure.mgmt.peering.models.Enum0 @@ -40,36 +46,26 @@ async def check_service_provider_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self.check_service_provider_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _json = self._serialize.body(check_service_provider_availability_input, 'CheckServiceProviderAvailabilityInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_service_provider_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_service_provider_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_service_provider_availability_input, 'CheckServiceProviderAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('str', pipeline_response) @@ -78,4 +74,6 @@ async def check_service_provider_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_service_provider_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/CheckServiceProviderAvailability'} # type: ignore + + check_service_provider_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/checkServiceProviderAvailability'} # type: ignore + diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_countries_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_countries_operations.py new file mode 100644 index 000000000000..38c67e67c9e1 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_countries_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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._peering_service_countries_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PeeringServiceCountriesOperations: + """PeeringServiceCountriesOperations 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.peering.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.PeeringServiceCountryListResult"]: + """Lists all of the available countries for peering service. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringServiceCountryListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceCountryListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceCountryListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PeeringServiceCountryListResult", 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(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': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceCountries'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_locations_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_locations_operations.py index a255a7df841b..16c6d90d2fef 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_locations_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_locations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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, HttpRequest +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._peering_service_locations_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,21 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + country: Optional[str] = None, + **kwargs: Any ) -> AsyncIterable["_models.PeeringServiceLocationListResult"]: - """Lists all of the available peering service locations for the specified kind of peering. + """Lists all of the available locations for peering service. + :param country: The country of interest, in which the locations are to be present. + :type country: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceLocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceLocationListResult] + :return: An iterator like instance of either PeeringServiceLocationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceLocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceLocationListResult"] @@ -57,34 +68,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + country=country, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + country=country, + 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('PeeringServiceLocationListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceLocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +105,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_prefixes_operations.py deleted file mode 100644 index 08f17fd13de1..000000000000 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_prefixes_operations.py +++ /dev/null @@ -1,239 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PeeringServicePrefixesOperations: - """PeeringServicePrefixesOperations 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.peering.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - resource_group_name: str, - peering_service_name: str, - prefix_name: str, - **kwargs - ) -> "_models.PeeringServicePrefix": - """Gets the peering service prefix. - - :param resource_group_name: The resource group name. - :type resource_group_name: str - :param peering_service_name: The peering service name. - :type peering_service_name: str - :param prefix_name: The prefix name. - :type prefix_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PeeringServicePrefix, or the result of cls(response) - :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'prefixName': self._serialize.url("prefix_name", prefix_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - peering_service_name: str, - prefix_name: str, - peering_service_prefix: "_models.PeeringServicePrefix", - **kwargs - ) -> "_models.PeeringServicePrefix": - """Creates or updates the peering prefix. - - :param resource_group_name: The resource group name. - :type resource_group_name: str - :param peering_service_name: The peering service name. - :type peering_service_name: str - :param prefix_name: The prefix name. - :type prefix_name: str - :param peering_service_prefix: The IP prefix for an peering. - :type peering_service_prefix: ~azure.mgmt.peering.models.PeeringServicePrefix - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PeeringServicePrefix, or the result of cls(response) - :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'prefixName': self._serialize.url("prefix_name", prefix_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peering_service_prefix, 'PeeringServicePrefix') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - peering_service_name: str, - prefix_name: str, - **kwargs - ) -> None: - """removes the peering prefix. - - :param resource_group_name: The resource group name. - :type resource_group_name: str - :param peering_service_name: The peering service name. - :type peering_service_name: str - :param prefix_name: The prefix name. - :type prefix_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 = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'prefixName': self._serialize.url("prefix_name", prefix_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_providers_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_providers_operations.py index a3a9238db4ce..184c9d8a9fa5 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_providers_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_service_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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, HttpRequest +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._peering_service_providers_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PeeringServiceProviderListResult"]: """Lists all of the available peering service locations for the specified kind of peering. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceProviderListResult] + :return: An iterator like instance of either PeeringServiceProviderListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceProviderListResult"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringServiceProviderListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +100,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_services_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_services_operations.py index ccd6b47b11b7..444e4d6ce178 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_services_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peering_services_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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, HttpRequest +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._peering_services_operations import build_create_or_update_request, build_delete_request, build_get_request, build_initialize_connection_monitor_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, peering_service_name: str, - **kwargs + **kwargs: Any ) -> "_models.PeeringService": """Gets an existing peering service with the specified name under the given subscription and resource group. @@ -64,33 +70,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PeeringService', pipeline_response) @@ -99,14 +95,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, peering_service_name: str, peering_service: "_models.PeeringService", - **kwargs + **kwargs: Any ) -> "_models.PeeringService": """Creates a new peering service or updates an existing peering with the specified name under the given subscription and resource group. @@ -127,38 +126,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(peering_service, 'PeeringService') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peering_service, 'PeeringService') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -171,13 +160,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, peering_service_name: str, - **kwargs + **kwargs: Any ) -> None: """Deletes an existing peering service with the specified name under the given subscription and resource group. @@ -196,33 +188,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -230,12 +212,14 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, peering_service_name: str, tags: "_models.ResourceTags", - **kwargs + **kwargs: Any ) -> "_models.PeeringService": """Updates tags for a peering service with the specified name under the given subscription and resource group. @@ -256,38 +240,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(tags, 'ResourceTags') + + request = build_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(tags, 'ResourceTags') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PeeringService', pipeline_response) @@ -296,20 +270,25 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PeeringServiceListResult"]: """Lists all of the peering services under the given subscription and resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceListResult] + :return: An iterator like instance of either PeeringServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceListResult"] @@ -317,35 +296,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringServiceListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,26 +333,30 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Peering/peeringServices'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PeeringServiceListResult"]: """Lists all of the peerings under the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceListResult] + :return: An iterator like instance of either PeeringServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceListResult"] @@ -385,34 +364,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringServiceListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -425,13 +399,54 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Peering/peeringServices'} # type: ignore + + @distributed_trace_async + async def initialize_connection_monitor( + self, + **kwargs: Any + ) -> None: + """Initialize Peering Service for Connection Monitor functionality. + + :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', {})) + + + request = build_initialize_connection_monitor_request( + subscription_id=self._config.subscription_id, + template_url=self.initialize_connection_monitor.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + initialize_connection_monitor.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/initializeConnectionMonitor'} # type: ignore + diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peerings_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peerings_operations.py index cd3e27869ae6..3f628e70f5c2 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peerings_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_peerings_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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, HttpRequest +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._peerings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, peering_name: str, - **kwargs + **kwargs: Any ) -> "_models.Peering": """Gets an existing peering with the specified name under the given subscription and resource group. @@ -64,33 +70,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Peering', pipeline_response) @@ -99,14 +95,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, peering_name: str, peering: "_models.Peering", - **kwargs + **kwargs: Any ) -> "_models.Peering": """Creates a new peering or updates an existing peering with the specified name under the given subscription and resource group. @@ -127,38 +126,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(peering, 'Peering') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peering, 'Peering') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -171,13 +160,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, peering_name: str, - **kwargs + **kwargs: Any ) -> None: """Deletes an existing peering with the specified name under the given subscription and resource group. @@ -196,33 +188,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -230,12 +212,14 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, peering_name: str, tags: "_models.ResourceTags", - **kwargs + **kwargs: Any ) -> "_models.Peering": """Updates tags for a peering with the specified name under the given subscription and resource group. @@ -256,38 +240,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(tags, 'ResourceTags') + + request = build_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(tags, 'ResourceTags') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Peering', pipeline_response) @@ -296,12 +270,15 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PeeringListResult"]: """Lists all of the peerings under the given subscription and resource group. @@ -317,35 +294,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringListResult', pipeline_response) + deserialized = self._deserialize("PeeringListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,20 +331,22 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Peering/peerings'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PeeringListResult"]: """Lists all of the peerings under the given subscription. @@ -385,34 +360,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringListResult', pipeline_response) + deserialized = self._deserialize("PeeringListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -425,12 +395,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_prefixes_operations.py index d12f1b574770..46566dd57edf 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_prefixes_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_prefixes_operations.py @@ -5,17 +5,22 @@ # 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, Generic, Optional, TypeVar +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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, HttpRequest +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._prefixes_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_peering_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,21 +46,210 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async + async def get( + self, + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.PeeringServicePrefix": + """Gets an existing prefix with the specified name under the given subscription, resource group + and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param prefix_name: The name of the prefix. + :type prefix_name: str + :param expand: The properties to be expanded. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringServicePrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + prefix_name=prefix_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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(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('PeeringServicePrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + peering_service_prefix: "_models.PeeringServicePrefix", + **kwargs: Any + ) -> "_models.PeeringServicePrefix": + """Creates a new prefix with the specified name under the given subscription, resource group and + peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param prefix_name: The name of the prefix. + :type prefix_name: str + :param peering_service_prefix: The properties needed to create a prefix. + :type peering_service_prefix: ~azure.mgmt.peering.models.PeeringServicePrefix + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringServicePrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(peering_service_prefix, 'PeeringServicePrefix') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + prefix_name=prefix_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringServicePrefix', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing prefix with the specified name under the given subscription, resource group + and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param prefix_name: The name of the prefix. + :type prefix_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + prefix_name=prefix_name, + subscription_id=self._config.subscription_id, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore + + + @distributed_trace def list_by_peering_service( self, resource_group_name: str, peering_service_name: str, - **kwargs + expand: Optional[str] = None, + **kwargs: Any ) -> AsyncIterable["_models.PeeringServicePrefixListResult"]: - """Lists the peerings prefix in the resource group. + """Lists all prefixes under the given subscription, resource group and peering service. - :param resource_group_name: The resource group name. + :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param peering_service_name: The peering service name. + :param peering_service_name: The name of the peering service. :type peering_service_name: str + :param expand: The properties to be expanded. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServicePrefixListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServicePrefixListResult] + :return: An iterator like instance of either PeeringServicePrefixListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringServicePrefixListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefixListResult"] @@ -63,36 +257,35 @@ def list_by_peering_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_peering_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_peering_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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('PeeringServicePrefixListResult', pipeline_response) + deserialized = self._deserialize("PeeringServicePrefixListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,12 +298,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_received_routes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_received_routes_operations.py new file mode 100644 index 000000000000..6edcc0bdec55 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_received_routes_operations.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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._received_routes_operations import build_list_by_peering_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ReceivedRoutesOperations: + """ReceivedRoutesOperations 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.peering.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_peering( + self, + resource_group_name: str, + peering_name: str, + prefix: Optional[str] = None, + as_path: Optional[str] = None, + origin_as_validation_state: Optional[str] = None, + rpki_validation_state: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PeeringReceivedRouteListResult"]: + """Lists the prefixes received over the specified peering under the given subscription and + resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param prefix: The optional prefix that can be used to filter the routes. + :type prefix: str + :param as_path: The optional AS path that can be used to filter the routes. + :type as_path: str + :param origin_as_validation_state: The optional origin AS validation state that can be used to + filter the routes. + :type origin_as_validation_state: str + :param rpki_validation_state: The optional RPKI validation state that can be used to filter the + routes. + :type rpki_validation_state: str + :param skip_token: The optional page continuation token that is used in the event of paginated + result. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringReceivedRouteListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringReceivedRouteListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringReceivedRouteListResult"] + 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_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + prefix=prefix, + as_path=as_path, + origin_as_validation_state=origin_as_validation_state, + rpki_validation_state=rpki_validation_state, + skip_token=skip_token, + template_url=self.list_by_peering.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + prefix=prefix, + as_path=as_path, + origin_as_validation_state=origin_as_validation_state, + rpki_validation_state=rpki_validation_state, + skip_token=skip_token, + 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("PeeringReceivedRouteListResult", 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(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_peering.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/receivedRoutes'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_asns_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_asns_operations.py new file mode 100644 index 000000000000..efc2cb0cc08b --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_asns_operations.py @@ -0,0 +1,302 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +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._registered_asns_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_peering_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RegisteredAsnsOperations: + """RegisteredAsnsOperations 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.peering.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, + peering_name: str, + registered_asn_name: str, + **kwargs: Any + ) -> "_models.PeeringRegisteredAsn": + """Gets an existing registered ASN with the specified name under the given subscription, resource + group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_asn_name: The name of the registered ASN. + :type registered_asn_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredAsn, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredAsn + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredAsn"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_asn_name=registered_asn_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringRegisteredAsn', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + registered_asn: "_models.PeeringRegisteredAsn", + **kwargs: Any + ) -> "_models.PeeringRegisteredAsn": + """Creates a new registered ASN with the specified name under the given subscription, resource + group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_asn_name: The name of the ASN. + :type registered_asn_name: str + :param registered_asn: The properties needed to create a registered ASN. + :type registered_asn: ~azure.mgmt.peering.models.PeeringRegisteredAsn + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredAsn, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredAsn + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredAsn"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(registered_asn, 'PeeringRegisteredAsn') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_asn_name=registered_asn_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringRegisteredAsn', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PeeringRegisteredAsn', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing registered ASN with the specified name under the given subscription, + resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_asn_name: The name of the registered ASN. + :type registered_asn_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_asn_name=registered_asn_name, + subscription_id=self._config.subscription_id, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}'} # type: ignore + + + @distributed_trace + def list_by_peering( + self, + resource_group_name: str, + peering_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PeeringRegisteredAsnListResult"]: + """Lists all registered ASNs under the given subscription, resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringRegisteredAsnListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringRegisteredAsnListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredAsnListResult"] + 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_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_peering.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PeeringRegisteredAsnListResult", 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(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_peering.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_prefixes_operations.py new file mode 100644 index 000000000000..8be65c9dafd7 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/aio/operations/_registered_prefixes_operations.py @@ -0,0 +1,302 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +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._registered_prefixes_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_peering_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RegisteredPrefixesOperations: + """RegisteredPrefixesOperations 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.peering.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, + peering_name: str, + registered_prefix_name: str, + **kwargs: Any + ) -> "_models.PeeringRegisteredPrefix": + """Gets an existing registered prefix with the specified name under the given subscription, + resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_prefix_name: The name of the registered prefix. + :type registered_prefix_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredPrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredPrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredPrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_prefix_name=registered_prefix_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringRegisteredPrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + registered_prefix: "_models.PeeringRegisteredPrefix", + **kwargs: Any + ) -> "_models.PeeringRegisteredPrefix": + """Creates a new registered prefix with the specified name under the given subscription, resource + group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_prefix_name: The name of the registered prefix. + :type registered_prefix_name: str + :param registered_prefix: The properties needed to create a registered prefix. + :type registered_prefix: ~azure.mgmt.peering.models.PeeringRegisteredPrefix + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredPrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredPrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredPrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(registered_prefix, 'PeeringRegisteredPrefix') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_prefix_name=registered_prefix_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringRegisteredPrefix', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PeeringRegisteredPrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing registered prefix with the specified name under the given subscription, + resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_prefix_name: The name of the registered prefix. + :type registered_prefix_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_prefix_name=registered_prefix_name, + subscription_id=self._config.subscription_id, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}'} # type: ignore + + + @distributed_trace + def list_by_peering( + self, + resource_group_name: str, + peering_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PeeringRegisteredPrefixListResult"]: + """Lists all registered prefixes under the given subscription, resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringRegisteredPrefixListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.peering.models.PeeringRegisteredPrefixListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredPrefixListResult"] + 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_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_peering.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PeeringRegisteredPrefixListResult", 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(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_peering.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/__init__.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/__init__.py index 7ecac278e357..d27749bbba4a 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/__init__.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/__init__.py @@ -6,90 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import BgpSession - from ._models_py3 import CheckServiceProviderAvailabilityInput - from ._models_py3 import ContactInfo - from ._models_py3 import DirectConnection - from ._models_py3 import DirectPeeringFacility - from ._models_py3 import ErrorResponse - from ._models_py3 import ExchangeConnection - from ._models_py3 import ExchangePeeringFacility - from ._models_py3 import Operation - from ._models_py3 import OperationDisplayInfo - from ._models_py3 import OperationListResult - from ._models_py3 import PeerAsn - from ._models_py3 import PeerAsnListResult - from ._models_py3 import Peering - from ._models_py3 import PeeringBandwidthOffer - from ._models_py3 import PeeringListResult - from ._models_py3 import PeeringLocation - from ._models_py3 import PeeringLocationListResult - from ._models_py3 import PeeringLocationPropertiesDirect - from ._models_py3 import PeeringLocationPropertiesExchange - from ._models_py3 import PeeringPropertiesDirect - from ._models_py3 import PeeringPropertiesExchange - from ._models_py3 import PeeringService - from ._models_py3 import PeeringServiceListResult - from ._models_py3 import PeeringServiceLocation - from ._models_py3 import PeeringServiceLocationListResult - from ._models_py3 import PeeringServicePrefix - from ._models_py3 import PeeringServicePrefixListResult - from ._models_py3 import PeeringServiceProvider - from ._models_py3 import PeeringServiceProviderListResult - from ._models_py3 import PeeringSku - from ._models_py3 import Resource - from ._models_py3 import ResourceTags - from ._models_py3 import SubResource -except (SyntaxError, ImportError): - from ._models import BgpSession # type: ignore - from ._models import CheckServiceProviderAvailabilityInput # type: ignore - from ._models import ContactInfo # type: ignore - from ._models import DirectConnection # type: ignore - from ._models import DirectPeeringFacility # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExchangeConnection # type: ignore - from ._models import ExchangePeeringFacility # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplayInfo # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PeerAsn # type: ignore - from ._models import PeerAsnListResult # type: ignore - from ._models import Peering # type: ignore - from ._models import PeeringBandwidthOffer # type: ignore - from ._models import PeeringListResult # type: ignore - from ._models import PeeringLocation # type: ignore - from ._models import PeeringLocationListResult # type: ignore - from ._models import PeeringLocationPropertiesDirect # type: ignore - from ._models import PeeringLocationPropertiesExchange # type: ignore - from ._models import PeeringPropertiesDirect # type: ignore - from ._models import PeeringPropertiesExchange # type: ignore - from ._models import PeeringService # type: ignore - from ._models import PeeringServiceListResult # type: ignore - from ._models import PeeringServiceLocation # type: ignore - from ._models import PeeringServiceLocationListResult # type: ignore - from ._models import PeeringServicePrefix # type: ignore - from ._models import PeeringServicePrefixListResult # type: ignore - from ._models import PeeringServiceProvider # type: ignore - from ._models import PeeringServiceProviderListResult # type: ignore - from ._models import PeeringSku # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceTags # type: ignore - from ._models import SubResource # type: ignore +from ._models_py3 import BgpSession +from ._models_py3 import CdnPeeringPrefix +from ._models_py3 import CdnPeeringPrefixListResult +from ._models_py3 import CheckServiceProviderAvailabilityInput +from ._models_py3 import ConnectionMonitorTest +from ._models_py3 import ConnectionMonitorTestListResult +from ._models_py3 import ContactDetail +from ._models_py3 import DirectConnection +from ._models_py3 import DirectPeeringFacility +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExchangeConnection +from ._models_py3 import ExchangePeeringFacility +from ._models_py3 import LogAnalyticsWorkspaceProperties +from ._models_py3 import LookingGlassOutput +from ._models_py3 import MetricDimension +from ._models_py3 import MetricSpecification +from ._models_py3 import Operation +from ._models_py3 import OperationDisplayInfo +from ._models_py3 import OperationListResult +from ._models_py3 import PeerAsn +from ._models_py3 import PeerAsnListResult +from ._models_py3 import Peering +from ._models_py3 import PeeringBandwidthOffer +from ._models_py3 import PeeringListResult +from ._models_py3 import PeeringLocation +from ._models_py3 import PeeringLocationListResult +from ._models_py3 import PeeringLocationPropertiesDirect +from ._models_py3 import PeeringLocationPropertiesExchange +from ._models_py3 import PeeringPropertiesDirect +from ._models_py3 import PeeringPropertiesExchange +from ._models_py3 import PeeringReceivedRoute +from ._models_py3 import PeeringReceivedRouteListResult +from ._models_py3 import PeeringRegisteredAsn +from ._models_py3 import PeeringRegisteredAsnListResult +from ._models_py3 import PeeringRegisteredPrefix +from ._models_py3 import PeeringRegisteredPrefixListResult +from ._models_py3 import PeeringService +from ._models_py3 import PeeringServiceCountry +from ._models_py3 import PeeringServiceCountryListResult +from ._models_py3 import PeeringServiceListResult +from ._models_py3 import PeeringServiceLocation +from ._models_py3 import PeeringServiceLocationListResult +from ._models_py3 import PeeringServicePrefix +from ._models_py3 import PeeringServicePrefixEvent +from ._models_py3 import PeeringServicePrefixListResult +from ._models_py3 import PeeringServiceProvider +from ._models_py3 import PeeringServiceProviderListResult +from ._models_py3 import PeeringServiceSku +from ._models_py3 import PeeringSku +from ._models_py3 import Resource +from ._models_py3 import ResourceTags +from ._models_py3 import ServiceSpecification +from ._models_py3 import SubResource + from ._peering_management_client_enums import ( + Command, ConnectionState, DirectPeeringType, Enum0, - Enum1, - Enum14, - Enum15, Family, Kind, LearnedType, - Name, + LegacyPeeringsKind, + LookingGlassCommand, + LookingGlassSourceType, + PeeringLocationsDirectPeeringType, + PeeringLocationsKind, PrefixValidationState, ProvisioningState, + Role, SessionAddressProvider, SessionStateV4, SessionStateV6, @@ -100,13 +88,22 @@ __all__ = [ 'BgpSession', + 'CdnPeeringPrefix', + 'CdnPeeringPrefixListResult', 'CheckServiceProviderAvailabilityInput', - 'ContactInfo', + 'ConnectionMonitorTest', + 'ConnectionMonitorTestListResult', + 'ContactDetail', 'DirectConnection', 'DirectPeeringFacility', + 'ErrorDetail', 'ErrorResponse', 'ExchangeConnection', 'ExchangePeeringFacility', + 'LogAnalyticsWorkspaceProperties', + 'LookingGlassOutput', + 'MetricDimension', + 'MetricSpecification', 'Operation', 'OperationDisplayInfo', 'OperationListResult', @@ -121,30 +118,44 @@ 'PeeringLocationPropertiesExchange', 'PeeringPropertiesDirect', 'PeeringPropertiesExchange', + 'PeeringReceivedRoute', + 'PeeringReceivedRouteListResult', + 'PeeringRegisteredAsn', + 'PeeringRegisteredAsnListResult', + 'PeeringRegisteredPrefix', + 'PeeringRegisteredPrefixListResult', 'PeeringService', + 'PeeringServiceCountry', + 'PeeringServiceCountryListResult', 'PeeringServiceListResult', 'PeeringServiceLocation', 'PeeringServiceLocationListResult', 'PeeringServicePrefix', + 'PeeringServicePrefixEvent', 'PeeringServicePrefixListResult', 'PeeringServiceProvider', 'PeeringServiceProviderListResult', + 'PeeringServiceSku', 'PeeringSku', 'Resource', 'ResourceTags', + 'ServiceSpecification', 'SubResource', + 'Command', 'ConnectionState', 'DirectPeeringType', 'Enum0', - 'Enum1', - 'Enum14', - 'Enum15', 'Family', 'Kind', 'LearnedType', - 'Name', + 'LegacyPeeringsKind', + 'LookingGlassCommand', + 'LookingGlassSourceType', + 'PeeringLocationsDirectPeeringType', + 'PeeringLocationsKind', 'PrefixValidationState', 'ProvisioningState', + 'Role', 'SessionAddressProvider', 'SessionStateV4', 'SessionStateV6', diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models.py deleted file mode 100644 index 798562f58906..000000000000 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models.py +++ /dev/null @@ -1,1191 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class BgpSession(msrest.serialization.Model): - """The properties that define a BGP session. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param session_prefix_v4: The IPv4 prefix that contains both ends' IPv4 addresses. - :type session_prefix_v4: str - :param session_prefix_v6: The IPv6 prefix that contains both ends' IPv6 addresses. - :type session_prefix_v6: str - :ivar microsoft_session_i_pv4_address: The IPv4 session address on Microsoft's end. - :vartype microsoft_session_i_pv4_address: str - :ivar microsoft_session_i_pv6_address: The IPv6 session address on Microsoft's end. - :vartype microsoft_session_i_pv6_address: str - :param peer_session_i_pv4_address: The IPv4 session address on peer's end. - :type peer_session_i_pv4_address: str - :param peer_session_i_pv6_address: The IPv6 session address on peer's end. - :type peer_session_i_pv6_address: str - :ivar session_state_v4: The state of the IPv4 session. Possible values include: "None", "Idle", - "Connect", "Active", "OpenSent", "OpenConfirm", "OpenReceived", "Established", "PendingAdd", - "PendingUpdate", "PendingRemove". - :vartype session_state_v4: str or ~azure.mgmt.peering.models.SessionStateV4 - :ivar session_state_v6: The state of the IPv6 session. Possible values include: "None", "Idle", - "Connect", "Active", "OpenSent", "OpenConfirm", "OpenReceived", "Established", "PendingAdd", - "PendingUpdate", "PendingRemove". - :vartype session_state_v6: str or ~azure.mgmt.peering.models.SessionStateV6 - :param max_prefixes_advertised_v4: The maximum number of prefixes advertised over the IPv4 - session. - :type max_prefixes_advertised_v4: int - :param max_prefixes_advertised_v6: The maximum number of prefixes advertised over the IPv6 - session. - :type max_prefixes_advertised_v6: int - :param md5_authentication_key: The MD5 authentication key of the session. - :type md5_authentication_key: str - """ - - _validation = { - 'microsoft_session_i_pv4_address': {'readonly': True}, - 'microsoft_session_i_pv6_address': {'readonly': True}, - 'session_state_v4': {'readonly': True}, - 'session_state_v6': {'readonly': True}, - } - - _attribute_map = { - 'session_prefix_v4': {'key': 'sessionPrefixV4', 'type': 'str'}, - 'session_prefix_v6': {'key': 'sessionPrefixV6', 'type': 'str'}, - 'microsoft_session_i_pv4_address': {'key': 'microsoftSessionIPv4Address', 'type': 'str'}, - 'microsoft_session_i_pv6_address': {'key': 'microsoftSessionIPv6Address', 'type': 'str'}, - 'peer_session_i_pv4_address': {'key': 'peerSessionIPv4Address', 'type': 'str'}, - 'peer_session_i_pv6_address': {'key': 'peerSessionIPv6Address', 'type': 'str'}, - 'session_state_v4': {'key': 'sessionStateV4', 'type': 'str'}, - 'session_state_v6': {'key': 'sessionStateV6', 'type': 'str'}, - 'max_prefixes_advertised_v4': {'key': 'maxPrefixesAdvertisedV4', 'type': 'int'}, - 'max_prefixes_advertised_v6': {'key': 'maxPrefixesAdvertisedV6', 'type': 'int'}, - 'md5_authentication_key': {'key': 'md5AuthenticationKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BgpSession, self).__init__(**kwargs) - self.session_prefix_v4 = kwargs.get('session_prefix_v4', None) - self.session_prefix_v6 = kwargs.get('session_prefix_v6', None) - self.microsoft_session_i_pv4_address = None - self.microsoft_session_i_pv6_address = None - self.peer_session_i_pv4_address = kwargs.get('peer_session_i_pv4_address', None) - self.peer_session_i_pv6_address = kwargs.get('peer_session_i_pv6_address', None) - self.session_state_v4 = None - self.session_state_v6 = None - self.max_prefixes_advertised_v4 = kwargs.get('max_prefixes_advertised_v4', None) - self.max_prefixes_advertised_v6 = kwargs.get('max_prefixes_advertised_v6', None) - self.md5_authentication_key = kwargs.get('md5_authentication_key', None) - - -class CheckServiceProviderAvailabilityInput(msrest.serialization.Model): - """Class for CheckServiceProviderAvailabilityInput. - - :param peering_service_location: Gets or sets the PeeringServiceLocation. - :type peering_service_location: str - :param peering_service_provider: Gets or sets the PeeringServiceProvider. - :type peering_service_provider: str - """ - - _attribute_map = { - 'peering_service_location': {'key': 'peeringServiceLocation', 'type': 'str'}, - 'peering_service_provider': {'key': 'peeringServiceProvider', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckServiceProviderAvailabilityInput, self).__init__(**kwargs) - self.peering_service_location = kwargs.get('peering_service_location', None) - self.peering_service_provider = kwargs.get('peering_service_provider', None) - - -class ContactInfo(msrest.serialization.Model): - """The contact information of the peer. - - :param emails: The list of email addresses. - :type emails: list[str] - :param phone: The list of contact numbers. - :type phone: list[str] - """ - - _attribute_map = { - 'emails': {'key': 'emails', 'type': '[str]'}, - 'phone': {'key': 'phone', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactInfo, self).__init__(**kwargs) - self.emails = kwargs.get('emails', None) - self.phone = kwargs.get('phone', None) - - -class DirectConnection(msrest.serialization.Model): - """The properties that define a direct connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param bandwidth_in_mbps: The bandwidth of the connection. - :type bandwidth_in_mbps: int - :param provisioned_bandwidth_in_mbps: The bandwidth that is actually provisioned. - :type provisioned_bandwidth_in_mbps: int - :param session_address_provider: The field indicating if Microsoft provides session ip - addresses. Possible values include: "Microsoft", "Peer". - :type session_address_provider: str or ~azure.mgmt.peering.models.SessionAddressProvider - :param use_for_peering_service: The flag that indicates whether or not the connection is used - for peering service. - :type use_for_peering_service: bool - :param peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection has - to be set up. - :type peering_db_facility_id: int - :ivar connection_state: The state of the connection. Possible values include: "None", - "PendingApproval", "Approved", "ProvisioningStarted", "ProvisioningFailed", - "ProvisioningCompleted", "Validating", "Active". - :vartype connection_state: str or ~azure.mgmt.peering.models.ConnectionState - :param bgp_session: The BGP session associated with the connection. - :type bgp_session: ~azure.mgmt.peering.models.BgpSession - :param connection_identifier: The unique identifier (GUID) for the connection. - :type connection_identifier: str - """ - - _validation = { - 'connection_state': {'readonly': True}, - } - - _attribute_map = { - 'bandwidth_in_mbps': {'key': 'bandwidthInMbps', 'type': 'int'}, - 'provisioned_bandwidth_in_mbps': {'key': 'provisionedBandwidthInMbps', 'type': 'int'}, - 'session_address_provider': {'key': 'sessionAddressProvider', 'type': 'str'}, - 'use_for_peering_service': {'key': 'useForPeeringService', 'type': 'bool'}, - 'peering_db_facility_id': {'key': 'peeringDBFacilityId', 'type': 'int'}, - 'connection_state': {'key': 'connectionState', 'type': 'str'}, - 'bgp_session': {'key': 'bgpSession', 'type': 'BgpSession'}, - 'connection_identifier': {'key': 'connectionIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DirectConnection, self).__init__(**kwargs) - self.bandwidth_in_mbps = kwargs.get('bandwidth_in_mbps', None) - self.provisioned_bandwidth_in_mbps = kwargs.get('provisioned_bandwidth_in_mbps', None) - self.session_address_provider = kwargs.get('session_address_provider', None) - self.use_for_peering_service = kwargs.get('use_for_peering_service', None) - self.peering_db_facility_id = kwargs.get('peering_db_facility_id', None) - self.connection_state = None - self.bgp_session = kwargs.get('bgp_session', None) - self.connection_identifier = kwargs.get('connection_identifier', None) - - -class DirectPeeringFacility(msrest.serialization.Model): - """The properties that define a direct peering facility. - - :param address: The address of the direct peering facility. - :type address: str - :param direct_peering_type: The type of the direct peering. Possible values include: "Edge", - "Transit", "Cdn", "Internal". - :type direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType - :param peering_db_facility_id: The PeeringDB.com ID of the facility. - :type peering_db_facility_id: int - :param peering_db_facility_link: The PeeringDB.com URL of the facility. - :type peering_db_facility_link: str - """ - - _attribute_map = { - 'address': {'key': 'address', 'type': 'str'}, - 'direct_peering_type': {'key': 'directPeeringType', 'type': 'str'}, - 'peering_db_facility_id': {'key': 'peeringDBFacilityId', 'type': 'int'}, - 'peering_db_facility_link': {'key': 'peeringDBFacilityLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DirectPeeringFacility, self).__init__(**kwargs) - self.address = kwargs.get('address', None) - self.direct_peering_type = kwargs.get('direct_peering_type', None) - self.peering_db_facility_id = kwargs.get('peering_db_facility_id', None) - self.peering_db_facility_link = kwargs.get('peering_db_facility_link', 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 ExchangeConnection(msrest.serialization.Model): - """The properties that define an exchange connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection has - to be set up. - :type peering_db_facility_id: int - :ivar connection_state: The state of the connection. Possible values include: "None", - "PendingApproval", "Approved", "ProvisioningStarted", "ProvisioningFailed", - "ProvisioningCompleted", "Validating", "Active". - :vartype connection_state: str or ~azure.mgmt.peering.models.ConnectionState - :param bgp_session: The BGP session associated with the connection. - :type bgp_session: ~azure.mgmt.peering.models.BgpSession - :param connection_identifier: The unique identifier (GUID) for the connection. - :type connection_identifier: str - """ - - _validation = { - 'connection_state': {'readonly': True}, - } - - _attribute_map = { - 'peering_db_facility_id': {'key': 'peeringDBFacilityId', 'type': 'int'}, - 'connection_state': {'key': 'connectionState', 'type': 'str'}, - 'bgp_session': {'key': 'bgpSession', 'type': 'BgpSession'}, - 'connection_identifier': {'key': 'connectionIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExchangeConnection, self).__init__(**kwargs) - self.peering_db_facility_id = kwargs.get('peering_db_facility_id', None) - self.connection_state = None - self.bgp_session = kwargs.get('bgp_session', None) - self.connection_identifier = kwargs.get('connection_identifier', None) - - -class ExchangePeeringFacility(msrest.serialization.Model): - """The properties that define an exchange peering facility. - - :param exchange_name: The name of the exchange peering facility. - :type exchange_name: str - :param bandwidth_in_mbps: The bandwidth of the connection between Microsoft and the exchange - peering facility. - :type bandwidth_in_mbps: int - :param microsoft_i_pv4_address: The IPv4 address of Microsoft at the exchange peering facility. - :type microsoft_i_pv4_address: str - :param microsoft_i_pv6_address: The IPv6 address of Microsoft at the exchange peering facility. - :type microsoft_i_pv6_address: str - :param facility_i_pv4_prefix: The IPv4 prefixes associated with the exchange peering facility. - :type facility_i_pv4_prefix: str - :param facility_i_pv6_prefix: The IPv6 prefixes associated with the exchange peering facility. - :type facility_i_pv6_prefix: str - :param peering_db_facility_id: The PeeringDB.com ID of the facility. - :type peering_db_facility_id: int - :param peering_db_facility_link: The PeeringDB.com URL of the facility. - :type peering_db_facility_link: str - """ - - _attribute_map = { - 'exchange_name': {'key': 'exchangeName', 'type': 'str'}, - 'bandwidth_in_mbps': {'key': 'bandwidthInMbps', 'type': 'int'}, - 'microsoft_i_pv4_address': {'key': 'microsoftIPv4Address', 'type': 'str'}, - 'microsoft_i_pv6_address': {'key': 'microsoftIPv6Address', 'type': 'str'}, - 'facility_i_pv4_prefix': {'key': 'facilityIPv4Prefix', 'type': 'str'}, - 'facility_i_pv6_prefix': {'key': 'facilityIPv6Prefix', 'type': 'str'}, - 'peering_db_facility_id': {'key': 'peeringDBFacilityId', 'type': 'int'}, - 'peering_db_facility_link': {'key': 'peeringDBFacilityLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExchangePeeringFacility, self).__init__(**kwargs) - self.exchange_name = kwargs.get('exchange_name', None) - self.bandwidth_in_mbps = kwargs.get('bandwidth_in_mbps', None) - self.microsoft_i_pv4_address = kwargs.get('microsoft_i_pv4_address', None) - self.microsoft_i_pv6_address = kwargs.get('microsoft_i_pv6_address', None) - self.facility_i_pv4_prefix = kwargs.get('facility_i_pv4_prefix', None) - self.facility_i_pv6_prefix = kwargs.get('facility_i_pv6_prefix', None) - self.peering_db_facility_id = kwargs.get('peering_db_facility_id', None) - self.peering_db_facility_link = kwargs.get('peering_db_facility_link', None) - - -class Operation(msrest.serialization.Model): - """The peering API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation. - :vartype name: str - :ivar display: The information related to the operation. - :vartype display: ~azure.mgmt.peering.models.OperationDisplayInfo - :ivar is_data_action: The flag that indicates whether the operation applies to data plane. - :vartype is_data_action: bool - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - 'is_data_action': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - self.is_data_action = None - - -class OperationDisplayInfo(msrest.serialization.Model): - """The information related to the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The name of the resource provider. - :vartype provider: str - :ivar resource: The type of the resource. - :vartype resource: str - :ivar operation: The name of the operation. - :vartype operation: str - :ivar description: The description of the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplayInfo, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The paginated list of peering API operations. - - :param value: The list of peering API operations. - :type value: list[~azure.mgmt.peering.models.Operation] - :param next_link: The link to fetch the next page of peering API operations. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Resource(msrest.serialization.Model): - """The ARM resource class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None - - -class PeerAsn(Resource): - """The essential information related to the peer's ASN. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param peer_asn: The Autonomous System Number (ASN) of the peer. - :type peer_asn: int - :param peer_contact_info: The contact information of the peer. - :type peer_contact_info: ~azure.mgmt.peering.models.ContactInfo - :param peer_name: The name of the peer. - :type peer_name: str - :param validation_state: The validation state of the ASN associated with the peer. Possible - values include: "None", "Pending", "Approved", "Failed". - :type validation_state: str or ~azure.mgmt.peering.models.ValidationState - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'peer_asn': {'key': 'properties.peerAsn', 'type': 'int'}, - 'peer_contact_info': {'key': 'properties.peerContactInfo', 'type': 'ContactInfo'}, - 'peer_name': {'key': 'properties.peerName', 'type': 'str'}, - 'validation_state': {'key': 'properties.validationState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeerAsn, self).__init__(**kwargs) - self.peer_asn = kwargs.get('peer_asn', None) - self.peer_contact_info = kwargs.get('peer_contact_info', None) - self.peer_name = kwargs.get('peer_name', None) - self.validation_state = kwargs.get('validation_state', None) - - -class PeerAsnListResult(msrest.serialization.Model): - """The paginated list of peer ASNs. - - :param value: The list of peer ASNs. - :type value: list[~azure.mgmt.peering.models.PeerAsn] - :param next_link: The link to fetch the next page of peer ASNs. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PeerAsn]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeerAsnListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Peering(Resource): - """Peering is a logical representation of a set of connections to the Microsoft Cloud Edge at a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param sku: Required. The SKU that defines the tier and kind of the peering. - :type sku: ~azure.mgmt.peering.models.PeeringSku - :param kind: Required. The kind of the peering. Possible values include: "Direct", "Exchange". - :type kind: str or ~azure.mgmt.peering.models.Kind - :param location: Required. The location of the resource. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param direct: The properties that define a direct peering. - :type direct: ~azure.mgmt.peering.models.PeeringPropertiesDirect - :param exchange: The properties that define an exchange peering. - :type exchange: ~azure.mgmt.peering.models.PeeringPropertiesExchange - :param peering_location: The location of the peering. - :type peering_location: str - :ivar provisioning_state: The provisioning state of the resource. Possible values include: - "Succeeded", "Updating", "Deleting", "Failed". - :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PeeringSku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'direct': {'key': 'properties.direct', 'type': 'PeeringPropertiesDirect'}, - 'exchange': {'key': 'properties.exchange', 'type': 'PeeringPropertiesExchange'}, - 'peering_location': {'key': 'properties.peeringLocation', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Peering, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.kind = kwargs['kind'] - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.direct = kwargs.get('direct', None) - self.exchange = kwargs.get('exchange', None) - self.peering_location = kwargs.get('peering_location', None) - self.provisioning_state = None - - -class PeeringBandwidthOffer(msrest.serialization.Model): - """The properties that define a peering bandwidth offer. - - :param offer_name: The name of the bandwidth offer. - :type offer_name: str - :param value_in_mbps: The value of the bandwidth offer in Mbps. - :type value_in_mbps: int - """ - - _attribute_map = { - 'offer_name': {'key': 'offerName', 'type': 'str'}, - 'value_in_mbps': {'key': 'valueInMbps', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringBandwidthOffer, self).__init__(**kwargs) - self.offer_name = kwargs.get('offer_name', None) - self.value_in_mbps = kwargs.get('value_in_mbps', None) - - -class PeeringListResult(msrest.serialization.Model): - """The paginated list of peerings. - - :param value: The list of peerings. - :type value: list[~azure.mgmt.peering.models.Peering] - :param next_link: The link to fetch the next page of peerings. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Peering]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PeeringLocation(Resource): - """Peering location is where connectivity could be established to the Microsoft Cloud Edge. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param kind: The kind of peering that the peering location supports. Possible values include: - "Direct", "Exchange". - :type kind: str or ~azure.mgmt.peering.models.Kind - :param direct: The properties that define a direct peering location. - :type direct: ~azure.mgmt.peering.models.PeeringLocationPropertiesDirect - :param exchange: The properties that define an exchange peering location. - :type exchange: ~azure.mgmt.peering.models.PeeringLocationPropertiesExchange - :param peering_location: The name of the peering location. - :type peering_location: str - :param country: The country in which the peering location exists. - :type country: str - :param azure_region: The Azure region associated with the peering location. - :type azure_region: str - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'direct': {'key': 'properties.direct', 'type': 'PeeringLocationPropertiesDirect'}, - 'exchange': {'key': 'properties.exchange', 'type': 'PeeringLocationPropertiesExchange'}, - 'peering_location': {'key': 'properties.peeringLocation', 'type': 'str'}, - 'country': {'key': 'properties.country', 'type': 'str'}, - 'azure_region': {'key': 'properties.azureRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringLocation, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.direct = kwargs.get('direct', None) - self.exchange = kwargs.get('exchange', None) - self.peering_location = kwargs.get('peering_location', None) - self.country = kwargs.get('country', None) - self.azure_region = kwargs.get('azure_region', None) - - -class PeeringLocationListResult(msrest.serialization.Model): - """The paginated list of peering locations. - - :param value: The list of peering locations. - :type value: list[~azure.mgmt.peering.models.PeeringLocation] - :param next_link: The link to fetch the next page of peering locations. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PeeringLocation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringLocationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PeeringLocationPropertiesDirect(msrest.serialization.Model): - """The properties that define a direct peering location. - - :param peering_facilities: The list of direct peering facilities at the peering location. - :type peering_facilities: list[~azure.mgmt.peering.models.DirectPeeringFacility] - :param bandwidth_offers: The list of bandwidth offers available at the peering location. - :type bandwidth_offers: list[~azure.mgmt.peering.models.PeeringBandwidthOffer] - """ - - _attribute_map = { - 'peering_facilities': {'key': 'peeringFacilities', 'type': '[DirectPeeringFacility]'}, - 'bandwidth_offers': {'key': 'bandwidthOffers', 'type': '[PeeringBandwidthOffer]'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringLocationPropertiesDirect, self).__init__(**kwargs) - self.peering_facilities = kwargs.get('peering_facilities', None) - self.bandwidth_offers = kwargs.get('bandwidth_offers', None) - - -class PeeringLocationPropertiesExchange(msrest.serialization.Model): - """The properties that define an exchange peering location. - - :param peering_facilities: The list of exchange peering facilities at the peering location. - :type peering_facilities: list[~azure.mgmt.peering.models.ExchangePeeringFacility] - """ - - _attribute_map = { - 'peering_facilities': {'key': 'peeringFacilities', 'type': '[ExchangePeeringFacility]'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringLocationPropertiesExchange, self).__init__(**kwargs) - self.peering_facilities = kwargs.get('peering_facilities', None) - - -class PeeringPropertiesDirect(msrest.serialization.Model): - """The properties that define a direct peering. - - :param connections: The set of connections that constitute a direct peering. - :type connections: list[~azure.mgmt.peering.models.DirectConnection] - :param use_for_peering_service: The flag that indicates whether or not the peering is used for - peering service. - :type use_for_peering_service: bool - :param peer_asn: The reference of the peer ASN. - :type peer_asn: ~azure.mgmt.peering.models.SubResource - :param direct_peering_type: The type of direct peering. Possible values include: "Edge", - "Transit", "Cdn", "Internal". - :type direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType - """ - - _attribute_map = { - 'connections': {'key': 'connections', 'type': '[DirectConnection]'}, - 'use_for_peering_service': {'key': 'useForPeeringService', 'type': 'bool'}, - 'peer_asn': {'key': 'peerAsn', 'type': 'SubResource'}, - 'direct_peering_type': {'key': 'directPeeringType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringPropertiesDirect, self).__init__(**kwargs) - self.connections = kwargs.get('connections', None) - self.use_for_peering_service = kwargs.get('use_for_peering_service', None) - self.peer_asn = kwargs.get('peer_asn', None) - self.direct_peering_type = kwargs.get('direct_peering_type', None) - - -class PeeringPropertiesExchange(msrest.serialization.Model): - """The properties that define an exchange peering. - - :param connections: The set of connections that constitute an exchange peering. - :type connections: list[~azure.mgmt.peering.models.ExchangeConnection] - :param peer_asn: The reference of the peer ASN. - :type peer_asn: ~azure.mgmt.peering.models.SubResource - """ - - _attribute_map = { - 'connections': {'key': 'connections', 'type': '[ExchangeConnection]'}, - 'peer_asn': {'key': 'peerAsn', 'type': 'SubResource'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringPropertiesExchange, self).__init__(**kwargs) - self.connections = kwargs.get('connections', None) - self.peer_asn = kwargs.get('peer_asn', None) - - -class PeeringService(Resource): - """Peering Service. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param location: Required. The location of the resource. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param peering_service_location: The PeeringServiceLocation of the Customer. - :type peering_service_location: str - :param peering_service_provider: The MAPS Provider Name. - :type peering_service_provider: str - :ivar provisioning_state: The provisioning state of the resource. Possible values include: - "Succeeded", "Updating", "Deleting", "Failed". - :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'peering_service_location': {'key': 'properties.peeringServiceLocation', 'type': 'str'}, - 'peering_service_provider': {'key': 'properties.peeringServiceProvider', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringService, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.peering_service_location = kwargs.get('peering_service_location', None) - self.peering_service_provider = kwargs.get('peering_service_provider', None) - self.provisioning_state = None - - -class PeeringServiceListResult(msrest.serialization.Model): - """The paginated list of peering services. - - :param value: The list of peering services. - :type value: list[~azure.mgmt.peering.models.PeeringService] - :param next_link: The link to fetch the next page of peering services. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PeeringService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServiceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PeeringServiceLocation(Resource): - """PeeringService location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param country: Country of the customer. - :type country: str - :param state: State of the customer. - :type state: str - :param azure_region: Azure region for the location. - :type azure_region: str - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'country': {'key': 'properties.country', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'azure_region': {'key': 'properties.azureRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServiceLocation, self).__init__(**kwargs) - self.country = kwargs.get('country', None) - self.state = kwargs.get('state', None) - self.azure_region = kwargs.get('azure_region', None) - - -class PeeringServiceLocationListResult(msrest.serialization.Model): - """The paginated list of peering service locations. - - :param value: The list of peering service locations. - :type value: list[~azure.mgmt.peering.models.PeeringServiceLocation] - :param next_link: The link to fetch the next page of peering service locations. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PeeringServiceLocation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServiceLocationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PeeringServicePrefix(Resource): - """The peering service prefix class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param prefix: Valid route prefix. - :type prefix: str - :param prefix_validation_state: The prefix validation state. Possible values include: "None", - "Invalid", "Verified", "Failed", "Pending", "Unknown". - :type prefix_validation_state: str or ~azure.mgmt.peering.models.PrefixValidationState - :param learned_type: The prefix learned type. Possible values include: "None", "ViaPartner", - "ViaSession". - :type learned_type: str or ~azure.mgmt.peering.models.LearnedType - :ivar provisioning_state: The provisioning state of the resource. Possible values include: - "Succeeded", "Updating", "Deleting", "Failed". - :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'prefix': {'key': 'properties.prefix', 'type': 'str'}, - 'prefix_validation_state': {'key': 'properties.prefixValidationState', 'type': 'str'}, - 'learned_type': {'key': 'properties.learnedType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServicePrefix, self).__init__(**kwargs) - self.prefix = kwargs.get('prefix', None) - self.prefix_validation_state = kwargs.get('prefix_validation_state', None) - self.learned_type = kwargs.get('learned_type', None) - self.provisioning_state = None - - -class PeeringServicePrefixListResult(msrest.serialization.Model): - """The paginated list of [T]. - - :param value: The list of [T]. - :type value: list[~azure.mgmt.peering.models.PeeringServicePrefix] - :param next_link: The link to fetch the next page of [T]. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PeeringServicePrefix]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServicePrefixListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PeeringServiceProvider(Resource): - """PeeringService provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :param service_provider_name: The name of the service provider. - :type service_provider_name: str - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'service_provider_name': {'key': 'properties.serviceProviderName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServiceProvider, self).__init__(**kwargs) - self.service_provider_name = kwargs.get('service_provider_name', None) - - -class PeeringServiceProviderListResult(msrest.serialization.Model): - """The paginated list of peering service providers. - - :param value: The list of peering service providers. - :type value: list[~azure.mgmt.peering.models.PeeringServiceProvider] - :param next_link: The link to fetch the next page of peering service providers. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PeeringServiceProvider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringServiceProviderListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PeeringSku(msrest.serialization.Model): - """The SKU that defines the tier and kind of the peering. - - :param name: The name of the peering SKU. Possible values include: "Basic_Exchange_Free", - "Basic_Direct_Free", "Premium_Direct_Free", "Premium_Exchange_Metered", - "Premium_Direct_Metered", "Premium_Direct_Unlimited". - :type name: str or ~azure.mgmt.peering.models.Name - :param tier: The tier of the peering SKU. Possible values include: "Basic", "Premium". - :type tier: str or ~azure.mgmt.peering.models.Tier - :param family: The family of the peering SKU. Possible values include: "Direct", "Exchange". - :type family: str or ~azure.mgmt.peering.models.Family - :param size: The size of the peering SKU. Possible values include: "Free", "Metered", - "Unlimited". - :type size: str or ~azure.mgmt.peering.models.Size - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeeringSku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - self.family = kwargs.get('family', None) - self.size = kwargs.get('size', None) - - -class ResourceTags(msrest.serialization.Model): - """The resource tags. - - :param tags: A set of tags. Gets or sets the tags, a dictionary of descriptors arm object. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTags, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class SubResource(msrest.serialization.Model): - """The sub resource. - - :param id: The identifier of the referenced resource. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models_py3.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models_py3.py index d8d0bde9b4a6..9de3863093bb 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models_py3.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_models_py3.py @@ -19,18 +19,18 @@ class BgpSession(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param session_prefix_v4: The IPv4 prefix that contains both ends' IPv4 addresses. - :type session_prefix_v4: str - :param session_prefix_v6: The IPv6 prefix that contains both ends' IPv6 addresses. - :type session_prefix_v6: str + :ivar session_prefix_v4: The IPv4 prefix that contains both ends' IPv4 addresses. + :vartype session_prefix_v4: str + :ivar session_prefix_v6: The IPv6 prefix that contains both ends' IPv6 addresses. + :vartype session_prefix_v6: str :ivar microsoft_session_i_pv4_address: The IPv4 session address on Microsoft's end. :vartype microsoft_session_i_pv4_address: str :ivar microsoft_session_i_pv6_address: The IPv6 session address on Microsoft's end. :vartype microsoft_session_i_pv6_address: str - :param peer_session_i_pv4_address: The IPv4 session address on peer's end. - :type peer_session_i_pv4_address: str - :param peer_session_i_pv6_address: The IPv6 session address on peer's end. - :type peer_session_i_pv6_address: str + :ivar peer_session_i_pv4_address: The IPv4 session address on peer's end. + :vartype peer_session_i_pv4_address: str + :ivar peer_session_i_pv6_address: The IPv6 session address on peer's end. + :vartype peer_session_i_pv6_address: str :ivar session_state_v4: The state of the IPv4 session. Possible values include: "None", "Idle", "Connect", "Active", "OpenSent", "OpenConfirm", "OpenReceived", "Established", "PendingAdd", "PendingUpdate", "PendingRemove". @@ -39,19 +39,17 @@ class BgpSession(msrest.serialization.Model): "Connect", "Active", "OpenSent", "OpenConfirm", "OpenReceived", "Established", "PendingAdd", "PendingUpdate", "PendingRemove". :vartype session_state_v6: str or ~azure.mgmt.peering.models.SessionStateV6 - :param max_prefixes_advertised_v4: The maximum number of prefixes advertised over the IPv4 + :ivar max_prefixes_advertised_v4: The maximum number of prefixes advertised over the IPv4 session. - :type max_prefixes_advertised_v4: int - :param max_prefixes_advertised_v6: The maximum number of prefixes advertised over the IPv6 + :vartype max_prefixes_advertised_v4: int + :ivar max_prefixes_advertised_v6: The maximum number of prefixes advertised over the IPv6 session. - :type max_prefixes_advertised_v6: int - :param md5_authentication_key: The MD5 authentication key of the session. - :type md5_authentication_key: str + :vartype max_prefixes_advertised_v6: int + :ivar md5_authentication_key: The MD5 authentication key of the session. + :vartype md5_authentication_key: str """ _validation = { - 'microsoft_session_i_pv4_address': {'readonly': True}, - 'microsoft_session_i_pv6_address': {'readonly': True}, 'session_state_v4': {'readonly': True}, 'session_state_v6': {'readonly': True}, } @@ -75,6 +73,8 @@ def __init__( *, session_prefix_v4: Optional[str] = None, session_prefix_v6: Optional[str] = None, + microsoft_session_i_pv4_address: Optional[str] = None, + microsoft_session_i_pv6_address: Optional[str] = None, peer_session_i_pv4_address: Optional[str] = None, peer_session_i_pv6_address: Optional[str] = None, max_prefixes_advertised_v4: Optional[int] = None, @@ -82,11 +82,33 @@ def __init__( md5_authentication_key: Optional[str] = None, **kwargs ): + """ + :keyword session_prefix_v4: The IPv4 prefix that contains both ends' IPv4 addresses. + :paramtype session_prefix_v4: str + :keyword session_prefix_v6: The IPv6 prefix that contains both ends' IPv6 addresses. + :paramtype session_prefix_v6: str + :keyword microsoft_session_i_pv4_address: The IPv4 session address on Microsoft's end. + :paramtype microsoft_session_i_pv4_address: str + :keyword microsoft_session_i_pv6_address: The IPv6 session address on Microsoft's end. + :paramtype microsoft_session_i_pv6_address: str + :keyword peer_session_i_pv4_address: The IPv4 session address on peer's end. + :paramtype peer_session_i_pv4_address: str + :keyword peer_session_i_pv6_address: The IPv6 session address on peer's end. + :paramtype peer_session_i_pv6_address: str + :keyword max_prefixes_advertised_v4: The maximum number of prefixes advertised over the IPv4 + session. + :paramtype max_prefixes_advertised_v4: int + :keyword max_prefixes_advertised_v6: The maximum number of prefixes advertised over the IPv6 + session. + :paramtype max_prefixes_advertised_v6: int + :keyword md5_authentication_key: The MD5 authentication key of the session. + :paramtype md5_authentication_key: str + """ super(BgpSession, self).__init__(**kwargs) self.session_prefix_v4 = session_prefix_v4 self.session_prefix_v6 = session_prefix_v6 - self.microsoft_session_i_pv4_address = None - self.microsoft_session_i_pv6_address = None + self.microsoft_session_i_pv4_address = microsoft_session_i_pv4_address + self.microsoft_session_i_pv6_address = microsoft_session_i_pv6_address self.peer_session_i_pv4_address = peer_session_i_pv4_address self.peer_session_i_pv6_address = peer_session_i_pv6_address self.session_state_v4 = None @@ -96,13 +118,141 @@ def __init__( self.md5_authentication_key = md5_authentication_key +class Resource(msrest.serialization.Model): + """The ARM resource class. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the resource. + :vartype name: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + + +class CdnPeeringPrefix(Resource): + """The CDN peering prefix. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the resource. + :vartype name: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str + :ivar prefix: The prefix. + :vartype prefix: str + :ivar azure_region: The Azure region. + :vartype azure_region: str + :ivar azure_service: The Azure service. + :vartype azure_service: str + :ivar is_primary_region: The flag that indicates whether or not this is the primary region. + :vartype is_primary_region: bool + :ivar bgp_community: The BGP Community. + :vartype bgp_community: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'prefix': {'readonly': True}, + 'azure_region': {'readonly': True}, + 'azure_service': {'readonly': True}, + 'is_primary_region': {'readonly': True}, + 'bgp_community': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'prefix': {'key': 'properties.prefix', 'type': 'str'}, + 'azure_region': {'key': 'properties.azureRegion', 'type': 'str'}, + 'azure_service': {'key': 'properties.azureService', 'type': 'str'}, + 'is_primary_region': {'key': 'properties.isPrimaryRegion', 'type': 'bool'}, + 'bgp_community': {'key': 'properties.bgpCommunity', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CdnPeeringPrefix, self).__init__(**kwargs) + self.prefix = None + self.azure_region = None + self.azure_service = None + self.is_primary_region = None + self.bgp_community = None + + +class CdnPeeringPrefixListResult(msrest.serialization.Model): + """The paginated list of CDN peering prefixes. + + :ivar value: The list of CDN peering prefixes. + :vartype value: list[~azure.mgmt.peering.models.CdnPeeringPrefix] + :ivar next_link: The link to fetch the next page of CDN peering prefixes. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CdnPeeringPrefix]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CdnPeeringPrefix"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of CDN peering prefixes. + :paramtype value: list[~azure.mgmt.peering.models.CdnPeeringPrefix] + :keyword next_link: The link to fetch the next page of CDN peering prefixes. + :paramtype next_link: str + """ + super(CdnPeeringPrefixListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class CheckServiceProviderAvailabilityInput(msrest.serialization.Model): """Class for CheckServiceProviderAvailabilityInput. - :param peering_service_location: Gets or sets the PeeringServiceLocation. - :type peering_service_location: str - :param peering_service_provider: Gets or sets the PeeringServiceProvider. - :type peering_service_provider: str + :ivar peering_service_location: Gets or sets the peering service location. + :vartype peering_service_location: str + :ivar peering_service_provider: Gets or sets the peering service provider. + :vartype peering_service_provider: str """ _attribute_map = { @@ -117,34 +267,167 @@ def __init__( peering_service_provider: Optional[str] = None, **kwargs ): + """ + :keyword peering_service_location: Gets or sets the peering service location. + :paramtype peering_service_location: str + :keyword peering_service_provider: Gets or sets the peering service provider. + :paramtype peering_service_provider: str + """ super(CheckServiceProviderAvailabilityInput, self).__init__(**kwargs) self.peering_service_location = peering_service_location self.peering_service_provider = peering_service_provider -class ContactInfo(msrest.serialization.Model): - """The contact information of the peer. +class ConnectionMonitorTest(Resource): + """The Connection Monitor Test class. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the resource. + :vartype name: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str + :ivar source_agent: The Connection Monitor test source agent. + :vartype source_agent: str + :ivar destination: The Connection Monitor test destination. + :vartype destination: str + :ivar destination_port: The Connection Monitor test destination port. + :vartype destination_port: int + :ivar test_frequency_in_sec: The Connection Monitor test frequency in seconds. + :vartype test_frequency_in_sec: int + :ivar is_test_successful: The flag that indicates if the Connection Monitor test is successful + or not. + :vartype is_test_successful: bool + :ivar path: The path representing the Connection Monitor test. + :vartype path: list[str] + :ivar provisioning_state: The provisioning state of the resource. Possible values include: + "Succeeded", "Updating", "Deleting", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'is_test_successful': {'readonly': True}, + 'path': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'source_agent': {'key': 'properties.sourceAgent', 'type': 'str'}, + 'destination': {'key': 'properties.destination', 'type': 'str'}, + 'destination_port': {'key': 'properties.destinationPort', 'type': 'int'}, + 'test_frequency_in_sec': {'key': 'properties.testFrequencyInSec', 'type': 'int'}, + 'is_test_successful': {'key': 'properties.isTestSuccessful', 'type': 'bool'}, + 'path': {'key': 'properties.path', 'type': '[str]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + source_agent: Optional[str] = None, + destination: Optional[str] = None, + destination_port: Optional[int] = None, + test_frequency_in_sec: Optional[int] = None, + **kwargs + ): + """ + :keyword source_agent: The Connection Monitor test source agent. + :paramtype source_agent: str + :keyword destination: The Connection Monitor test destination. + :paramtype destination: str + :keyword destination_port: The Connection Monitor test destination port. + :paramtype destination_port: int + :keyword test_frequency_in_sec: The Connection Monitor test frequency in seconds. + :paramtype test_frequency_in_sec: int + """ + super(ConnectionMonitorTest, self).__init__(**kwargs) + self.source_agent = source_agent + self.destination = destination + self.destination_port = destination_port + self.test_frequency_in_sec = test_frequency_in_sec + self.is_test_successful = None + self.path = None + self.provisioning_state = None - :param emails: The list of email addresses. - :type emails: list[str] - :param phone: The list of contact numbers. - :type phone: list[str] + +class ConnectionMonitorTestListResult(msrest.serialization.Model): + """The paginated list of [T]. + + :ivar value: The list of [T]. + :vartype value: list[~azure.mgmt.peering.models.ConnectionMonitorTest] + :ivar next_link: The link to fetch the next page of [T]. + :vartype next_link: str """ _attribute_map = { - 'emails': {'key': 'emails', 'type': '[str]'}, - 'phone': {'key': 'phone', 'type': '[str]'}, + 'value': {'key': 'value', 'type': '[ConnectionMonitorTest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, *, - emails: Optional[List[str]] = None, - phone: Optional[List[str]] = None, + value: Optional[List["ConnectionMonitorTest"]] = None, + next_link: Optional[str] = None, **kwargs ): - super(ContactInfo, self).__init__(**kwargs) - self.emails = emails + """ + :keyword value: The list of [T]. + :paramtype value: list[~azure.mgmt.peering.models.ConnectionMonitorTest] + :keyword next_link: The link to fetch the next page of [T]. + :paramtype next_link: str + """ + super(ConnectionMonitorTestListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ContactDetail(msrest.serialization.Model): + """The contact detail class. + + :ivar role: The role of the contact. Possible values include: "Noc", "Policy", "Technical", + "Service", "Escalation", "Other". + :vartype role: str or ~azure.mgmt.peering.models.Role + :ivar email: The e-mail address of the contact. + :vartype email: str + :ivar phone: The phone number of the contact. + :vartype phone: str + """ + + _attribute_map = { + 'role': {'key': 'role', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + } + + def __init__( + self, + *, + role: Optional[Union[str, "Role"]] = None, + email: Optional[str] = None, + phone: Optional[str] = None, + **kwargs + ): + """ + :keyword role: The role of the contact. Possible values include: "Noc", "Policy", "Technical", + "Service", "Escalation", "Other". + :paramtype role: str or ~azure.mgmt.peering.models.Role + :keyword email: The e-mail address of the contact. + :paramtype email: str + :keyword phone: The phone number of the contact. + :paramtype phone: str + """ + super(ContactDetail, self).__init__(**kwargs) + self.role = role + self.email = email self.phone = phone @@ -153,31 +436,39 @@ class DirectConnection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param bandwidth_in_mbps: The bandwidth of the connection. - :type bandwidth_in_mbps: int - :param provisioned_bandwidth_in_mbps: The bandwidth that is actually provisioned. - :type provisioned_bandwidth_in_mbps: int - :param session_address_provider: The field indicating if Microsoft provides session ip + :ivar bandwidth_in_mbps: The bandwidth of the connection. + :vartype bandwidth_in_mbps: int + :ivar provisioned_bandwidth_in_mbps: The bandwidth that is actually provisioned. + :vartype provisioned_bandwidth_in_mbps: int + :ivar session_address_provider: The field indicating if Microsoft provides session ip addresses. Possible values include: "Microsoft", "Peer". - :type session_address_provider: str or ~azure.mgmt.peering.models.SessionAddressProvider - :param use_for_peering_service: The flag that indicates whether or not the connection is used + :vartype session_address_provider: str or ~azure.mgmt.peering.models.SessionAddressProvider + :ivar use_for_peering_service: The flag that indicates whether or not the connection is used for peering service. - :type use_for_peering_service: bool - :param peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection has + :vartype use_for_peering_service: bool + :ivar microsoft_tracking_id: The ID used within Microsoft's peering provisioning system to + track the connection. + :vartype microsoft_tracking_id: str + :ivar peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection has to be set up. - :type peering_db_facility_id: int + :vartype peering_db_facility_id: int :ivar connection_state: The state of the connection. Possible values include: "None", "PendingApproval", "Approved", "ProvisioningStarted", "ProvisioningFailed", "ProvisioningCompleted", "Validating", "Active". :vartype connection_state: str or ~azure.mgmt.peering.models.ConnectionState - :param bgp_session: The BGP session associated with the connection. - :type bgp_session: ~azure.mgmt.peering.models.BgpSession - :param connection_identifier: The unique identifier (GUID) for the connection. - :type connection_identifier: str + :ivar bgp_session: The BGP session associated with the connection. + :vartype bgp_session: ~azure.mgmt.peering.models.BgpSession + :ivar connection_identifier: The unique identifier (GUID) for the connection. + :vartype connection_identifier: str + :ivar error_message: The error message related to the connection state, if any. + :vartype error_message: str """ _validation = { + 'provisioned_bandwidth_in_mbps': {'readonly': True}, + 'microsoft_tracking_id': {'readonly': True}, 'connection_state': {'readonly': True}, + 'error_message': {'readonly': True}, } _attribute_map = { @@ -185,17 +476,18 @@ class DirectConnection(msrest.serialization.Model): 'provisioned_bandwidth_in_mbps': {'key': 'provisionedBandwidthInMbps', 'type': 'int'}, 'session_address_provider': {'key': 'sessionAddressProvider', 'type': 'str'}, 'use_for_peering_service': {'key': 'useForPeeringService', 'type': 'bool'}, + 'microsoft_tracking_id': {'key': 'microsoftTrackingId', 'type': 'str'}, 'peering_db_facility_id': {'key': 'peeringDBFacilityId', 'type': 'int'}, 'connection_state': {'key': 'connectionState', 'type': 'str'}, 'bgp_session': {'key': 'bgpSession', 'type': 'BgpSession'}, 'connection_identifier': {'key': 'connectionIdentifier', 'type': 'str'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, } def __init__( self, *, bandwidth_in_mbps: Optional[int] = None, - provisioned_bandwidth_in_mbps: Optional[int] = None, session_address_provider: Optional[Union[str, "SessionAddressProvider"]] = None, use_for_peering_service: Optional[bool] = None, peering_db_facility_id: Optional[int] = None, @@ -203,29 +495,48 @@ def __init__( connection_identifier: Optional[str] = None, **kwargs ): + """ + :keyword bandwidth_in_mbps: The bandwidth of the connection. + :paramtype bandwidth_in_mbps: int + :keyword session_address_provider: The field indicating if Microsoft provides session ip + addresses. Possible values include: "Microsoft", "Peer". + :paramtype session_address_provider: str or ~azure.mgmt.peering.models.SessionAddressProvider + :keyword use_for_peering_service: The flag that indicates whether or not the connection is used + for peering service. + :paramtype use_for_peering_service: bool + :keyword peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection + has to be set up. + :paramtype peering_db_facility_id: int + :keyword bgp_session: The BGP session associated with the connection. + :paramtype bgp_session: ~azure.mgmt.peering.models.BgpSession + :keyword connection_identifier: The unique identifier (GUID) for the connection. + :paramtype connection_identifier: str + """ super(DirectConnection, self).__init__(**kwargs) self.bandwidth_in_mbps = bandwidth_in_mbps - self.provisioned_bandwidth_in_mbps = provisioned_bandwidth_in_mbps + self.provisioned_bandwidth_in_mbps = None self.session_address_provider = session_address_provider self.use_for_peering_service = use_for_peering_service + self.microsoft_tracking_id = None self.peering_db_facility_id = peering_db_facility_id self.connection_state = None self.bgp_session = bgp_session self.connection_identifier = connection_identifier + self.error_message = None class DirectPeeringFacility(msrest.serialization.Model): """The properties that define a direct peering facility. - :param address: The address of the direct peering facility. - :type address: str - :param direct_peering_type: The type of the direct peering. Possible values include: "Edge", - "Transit", "Cdn", "Internal". - :type direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType - :param peering_db_facility_id: The PeeringDB.com ID of the facility. - :type peering_db_facility_id: int - :param peering_db_facility_link: The PeeringDB.com URL of the facility. - :type peering_db_facility_link: str + :ivar address: The address of the direct peering facility. + :vartype address: str + :ivar direct_peering_type: The type of the direct peering. Possible values include: "Edge", + "Transit", "Cdn", "Internal", "Ix", "IxRs", "Voice", "EdgeZoneForOperators". + :vartype direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType + :ivar peering_db_facility_id: The PeeringDB.com ID of the facility. + :vartype peering_db_facility_id: int + :ivar peering_db_facility_link: The PeeringDB.com URL of the facility. + :vartype peering_db_facility_link: str """ _attribute_map = { @@ -244,6 +555,17 @@ def __init__( peering_db_facility_link: Optional[str] = None, **kwargs ): + """ + :keyword address: The address of the direct peering facility. + :paramtype address: str + :keyword direct_peering_type: The type of the direct peering. Possible values include: "Edge", + "Transit", "Cdn", "Internal", "Ix", "IxRs", "Voice", "EdgeZoneForOperators". + :paramtype direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType + :keyword peering_db_facility_id: The PeeringDB.com ID of the facility. + :paramtype peering_db_facility_id: int + :keyword peering_db_facility_link: The PeeringDB.com URL of the facility. + :paramtype peering_db_facility_link: str + """ super(DirectPeeringFacility, self).__init__(**kwargs) self.address = address self.direct_peering_type = direct_peering_type @@ -251,8 +573,8 @@ def __init__( self.peering_db_facility_link = peering_db_facility_link -class ErrorResponse(msrest.serialization.Model): - """The error response that indicates why an operation has failed. +class ErrorDetail(msrest.serialization.Model): + """The error detail that describes why an operation has failed. Variables are only populated by the server, and will be ignored when sending a request. @@ -276,31 +598,61 @@ def __init__( self, **kwargs ): - super(ErrorResponse, self).__init__(**kwargs) + """ + """ + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None +class ErrorResponse(msrest.serialization.Model): + """The error response that indicates why an operation has failed. + + :ivar error: The error detail that describes why an operation has failed. + :vartype error: ~azure.mgmt.peering.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error detail that describes why an operation has failed. + :paramtype error: ~azure.mgmt.peering.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + class ExchangeConnection(msrest.serialization.Model): """The properties that define an exchange connection. Variables are only populated by the server, and will be ignored when sending a request. - :param peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection has + :ivar peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection has to be set up. - :type peering_db_facility_id: int + :vartype peering_db_facility_id: int :ivar connection_state: The state of the connection. Possible values include: "None", "PendingApproval", "Approved", "ProvisioningStarted", "ProvisioningFailed", "ProvisioningCompleted", "Validating", "Active". :vartype connection_state: str or ~azure.mgmt.peering.models.ConnectionState - :param bgp_session: The BGP session associated with the connection. - :type bgp_session: ~azure.mgmt.peering.models.BgpSession - :param connection_identifier: The unique identifier (GUID) for the connection. - :type connection_identifier: str + :ivar bgp_session: The BGP session associated with the connection. + :vartype bgp_session: ~azure.mgmt.peering.models.BgpSession + :ivar connection_identifier: The unique identifier (GUID) for the connection. + :vartype connection_identifier: str + :ivar error_message: The error message related to the connection state, if any. + :vartype error_message: str """ _validation = { 'connection_state': {'readonly': True}, + 'error_message': {'readonly': True}, } _attribute_map = { @@ -308,6 +660,7 @@ class ExchangeConnection(msrest.serialization.Model): 'connection_state': {'key': 'connectionState', 'type': 'str'}, 'bgp_session': {'key': 'bgpSession', 'type': 'BgpSession'}, 'connection_identifier': {'key': 'connectionIdentifier', 'type': 'str'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, } def __init__( @@ -318,33 +671,43 @@ def __init__( connection_identifier: Optional[str] = None, **kwargs ): + """ + :keyword peering_db_facility_id: The PeeringDB.com ID of the facility at which the connection + has to be set up. + :paramtype peering_db_facility_id: int + :keyword bgp_session: The BGP session associated with the connection. + :paramtype bgp_session: ~azure.mgmt.peering.models.BgpSession + :keyword connection_identifier: The unique identifier (GUID) for the connection. + :paramtype connection_identifier: str + """ super(ExchangeConnection, self).__init__(**kwargs) self.peering_db_facility_id = peering_db_facility_id self.connection_state = None self.bgp_session = bgp_session self.connection_identifier = connection_identifier + self.error_message = None class ExchangePeeringFacility(msrest.serialization.Model): """The properties that define an exchange peering facility. - :param exchange_name: The name of the exchange peering facility. - :type exchange_name: str - :param bandwidth_in_mbps: The bandwidth of the connection between Microsoft and the exchange + :ivar exchange_name: The name of the exchange peering facility. + :vartype exchange_name: str + :ivar bandwidth_in_mbps: The bandwidth of the connection between Microsoft and the exchange peering facility. - :type bandwidth_in_mbps: int - :param microsoft_i_pv4_address: The IPv4 address of Microsoft at the exchange peering facility. - :type microsoft_i_pv4_address: str - :param microsoft_i_pv6_address: The IPv6 address of Microsoft at the exchange peering facility. - :type microsoft_i_pv6_address: str - :param facility_i_pv4_prefix: The IPv4 prefixes associated with the exchange peering facility. - :type facility_i_pv4_prefix: str - :param facility_i_pv6_prefix: The IPv6 prefixes associated with the exchange peering facility. - :type facility_i_pv6_prefix: str - :param peering_db_facility_id: The PeeringDB.com ID of the facility. - :type peering_db_facility_id: int - :param peering_db_facility_link: The PeeringDB.com URL of the facility. - :type peering_db_facility_link: str + :vartype bandwidth_in_mbps: int + :ivar microsoft_i_pv4_address: The IPv4 address of Microsoft at the exchange peering facility. + :vartype microsoft_i_pv4_address: str + :ivar microsoft_i_pv6_address: The IPv6 address of Microsoft at the exchange peering facility. + :vartype microsoft_i_pv6_address: str + :ivar facility_i_pv4_prefix: The IPv4 prefixes associated with the exchange peering facility. + :vartype facility_i_pv4_prefix: str + :ivar facility_i_pv6_prefix: The IPv6 prefixes associated with the exchange peering facility. + :vartype facility_i_pv6_prefix: str + :ivar peering_db_facility_id: The PeeringDB.com ID of the facility. + :vartype peering_db_facility_id: int + :ivar peering_db_facility_link: The PeeringDB.com URL of the facility. + :vartype peering_db_facility_link: str """ _attribute_map = { @@ -371,6 +734,29 @@ def __init__( peering_db_facility_link: Optional[str] = None, **kwargs ): + """ + :keyword exchange_name: The name of the exchange peering facility. + :paramtype exchange_name: str + :keyword bandwidth_in_mbps: The bandwidth of the connection between Microsoft and the exchange + peering facility. + :paramtype bandwidth_in_mbps: int + :keyword microsoft_i_pv4_address: The IPv4 address of Microsoft at the exchange peering + facility. + :paramtype microsoft_i_pv4_address: str + :keyword microsoft_i_pv6_address: The IPv6 address of Microsoft at the exchange peering + facility. + :paramtype microsoft_i_pv6_address: str + :keyword facility_i_pv4_prefix: The IPv4 prefixes associated with the exchange peering + facility. + :paramtype facility_i_pv4_prefix: str + :keyword facility_i_pv6_prefix: The IPv6 prefixes associated with the exchange peering + facility. + :paramtype facility_i_pv6_prefix: str + :keyword peering_db_facility_id: The PeeringDB.com ID of the facility. + :paramtype peering_db_facility_id: int + :keyword peering_db_facility_link: The PeeringDB.com URL of the facility. + :paramtype peering_db_facility_link: str + """ super(ExchangePeeringFacility, self).__init__(**kwargs) self.exchange_name = exchange_name self.bandwidth_in_mbps = bandwidth_in_mbps @@ -382,6 +768,165 @@ def __init__( self.peering_db_facility_link = peering_db_facility_link +class LogAnalyticsWorkspaceProperties(msrest.serialization.Model): + """The properties that define a Log Analytics Workspace. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar workspace_id: The Workspace ID. + :vartype workspace_id: str + :ivar key: The Workspace Key. + :vartype key: str + :ivar connected_agents: The list of connected agents. + :vartype connected_agents: list[str] + """ + + _validation = { + 'workspace_id': {'readonly': True}, + 'key': {'readonly': True}, + 'connected_agents': {'readonly': True}, + } + + _attribute_map = { + 'workspace_id': {'key': 'workspaceID', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'str'}, + 'connected_agents': {'key': 'connectedAgents', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LogAnalyticsWorkspaceProperties, self).__init__(**kwargs) + self.workspace_id = None + self.key = None + self.connected_agents = None + + +class LookingGlassOutput(msrest.serialization.Model): + """Looking glass output model. + + :ivar command: Invoked command. Possible values include: "Traceroute", "Ping", "BgpRoute". + :vartype command: str or ~azure.mgmt.peering.models.Command + :ivar output: Output of the command. + :vartype output: str + """ + + _attribute_map = { + 'command': {'key': 'command', 'type': 'str'}, + 'output': {'key': 'output', 'type': 'str'}, + } + + def __init__( + self, + *, + command: Optional[Union[str, "Command"]] = None, + output: Optional[str] = None, + **kwargs + ): + """ + :keyword command: Invoked command. Possible values include: "Traceroute", "Ping", "BgpRoute". + :paramtype command: str or ~azure.mgmt.peering.models.Command + :keyword output: Output of the command. + :paramtype output: str + """ + super(LookingGlassOutput, self).__init__(**kwargs) + self.command = command + self.output = output + + +class MetricDimension(msrest.serialization.Model): + """Dimensions of the metric. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + """ + + _validation = { + 'name': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(MetricDimension, self).__init__(**kwargs) + self.name = None + self.display_name = None + + +class MetricSpecification(msrest.serialization.Model): + """Specifications of the Metrics for Azure Monitoring. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: Unit that makes sense for the metric. + :vartype unit: str + :ivar aggregation_type: Aggregation type will be set to one of the values: Average, Minimum, + Maximum, Total, Count. + :vartype aggregation_type: str + :ivar supported_time_grain_types: Supported time grain types for the metric. + :vartype supported_time_grain_types: list[str] + :ivar dimensions: Dimensions of the metric. + :vartype dimensions: list[~azure.mgmt.peering.models.MetricDimension] + """ + + _validation = { + 'name': {'readonly': True}, + 'display_name': {'readonly': True}, + 'display_description': {'readonly': True}, + 'unit': {'readonly': True}, + 'aggregation_type': {'readonly': True}, + 'supported_time_grain_types': {'readonly': True}, + 'dimensions': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'display_description': {'key': 'displayDescription', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, + 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, + 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(MetricSpecification, self).__init__(**kwargs) + self.name = None + self.display_name = None + self.display_description = None + self.unit = None + self.aggregation_type = None + self.supported_time_grain_types = None + self.dimensions = None + + class Operation(msrest.serialization.Model): """The peering API operation. @@ -393,28 +938,35 @@ class Operation(msrest.serialization.Model): :vartype display: ~azure.mgmt.peering.models.OperationDisplayInfo :ivar is_data_action: The flag that indicates whether the operation applies to data plane. :vartype is_data_action: bool + :ivar service_specification: Service specification payload. + :vartype service_specification: ~azure.mgmt.peering.models.ServiceSpecification """ _validation = { 'name': {'readonly': True}, 'display': {'readonly': True}, 'is_data_action': {'readonly': True}, + 'service_specification': {'readonly': True}, } _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, } def __init__( self, **kwargs ): + """ + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = None self.is_data_action = None + self.service_specification = None class OperationDisplayInfo(msrest.serialization.Model): @@ -450,6 +1002,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplayInfo, self).__init__(**kwargs) self.provider = None self.resource = None @@ -460,10 +1014,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The paginated list of peering API operations. - :param value: The list of peering API operations. - :type value: list[~azure.mgmt.peering.models.Operation] - :param next_link: The link to fetch the next page of peering API operations. - :type next_link: str + :ivar value: The list of peering API operations. + :vartype value: list[~azure.mgmt.peering.models.Operation] + :ivar next_link: The link to fetch the next page of peering API operations. + :vartype next_link: str """ _attribute_map = { @@ -478,44 +1032,15 @@ def __init__( next_link: Optional[str] = None, **kwargs ): - super(OperationListResult, self).__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Resource(msrest.serialization.Model): - """The ARM resource class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource. - :vartype name: str - :ivar id: The ID of the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None + """ + :keyword value: The list of peering API operations. + :paramtype value: list[~azure.mgmt.peering.models.Operation] + :keyword next_link: The link to fetch the next page of peering API operations. + :paramtype next_link: str + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link class PeerAsn(Resource): @@ -529,21 +1054,25 @@ class PeerAsn(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param peer_asn: The Autonomous System Number (ASN) of the peer. - :type peer_asn: int - :param peer_contact_info: The contact information of the peer. - :type peer_contact_info: ~azure.mgmt.peering.models.ContactInfo - :param peer_name: The name of the peer. - :type peer_name: str - :param validation_state: The validation state of the ASN associated with the peer. Possible + :ivar peer_asn: The Autonomous System Number (ASN) of the peer. + :vartype peer_asn: int + :ivar peer_contact_detail: The contact details of the peer. + :vartype peer_contact_detail: list[~azure.mgmt.peering.models.ContactDetail] + :ivar peer_name: The name of the peer. + :vartype peer_name: str + :ivar validation_state: The validation state of the ASN associated with the peer. Possible values include: "None", "Pending", "Approved", "Failed". - :type validation_state: str or ~azure.mgmt.peering.models.ValidationState + :vartype validation_state: str or ~azure.mgmt.peering.models.ValidationState + :ivar error_message: The error message for the validation state. + :vartype error_message: str """ _validation = { 'name': {'readonly': True}, 'id': {'readonly': True}, 'type': {'readonly': True}, + 'validation_state': {'readonly': True}, + 'error_message': {'readonly': True}, } _attribute_map = { @@ -551,34 +1080,43 @@ class PeerAsn(Resource): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'peer_asn': {'key': 'properties.peerAsn', 'type': 'int'}, - 'peer_contact_info': {'key': 'properties.peerContactInfo', 'type': 'ContactInfo'}, + 'peer_contact_detail': {'key': 'properties.peerContactDetail', 'type': '[ContactDetail]'}, 'peer_name': {'key': 'properties.peerName', 'type': 'str'}, 'validation_state': {'key': 'properties.validationState', 'type': 'str'}, + 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, } def __init__( self, *, peer_asn: Optional[int] = None, - peer_contact_info: Optional["ContactInfo"] = None, + peer_contact_detail: Optional[List["ContactDetail"]] = None, peer_name: Optional[str] = None, - validation_state: Optional[Union[str, "ValidationState"]] = None, **kwargs ): + """ + :keyword peer_asn: The Autonomous System Number (ASN) of the peer. + :paramtype peer_asn: int + :keyword peer_contact_detail: The contact details of the peer. + :paramtype peer_contact_detail: list[~azure.mgmt.peering.models.ContactDetail] + :keyword peer_name: The name of the peer. + :paramtype peer_name: str + """ super(PeerAsn, self).__init__(**kwargs) self.peer_asn = peer_asn - self.peer_contact_info = peer_contact_info + self.peer_contact_detail = peer_contact_detail self.peer_name = peer_name - self.validation_state = validation_state + self.validation_state = None + self.error_message = None class PeerAsnListResult(msrest.serialization.Model): """The paginated list of peer ASNs. - :param value: The list of peer ASNs. - :type value: list[~azure.mgmt.peering.models.PeerAsn] - :param next_link: The link to fetch the next page of peer ASNs. - :type next_link: str + :ivar value: The list of peer ASNs. + :vartype value: list[~azure.mgmt.peering.models.PeerAsn] + :ivar next_link: The link to fetch the next page of peer ASNs. + :vartype next_link: str """ _attribute_map = { @@ -593,6 +1131,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peer ASNs. + :paramtype value: list[~azure.mgmt.peering.models.PeerAsn] + :keyword next_link: The link to fetch the next page of peer ASNs. + :paramtype next_link: str + """ super(PeerAsnListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -611,20 +1155,20 @@ class Peering(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param sku: Required. The SKU that defines the tier and kind of the peering. - :type sku: ~azure.mgmt.peering.models.PeeringSku - :param kind: Required. The kind of the peering. Possible values include: "Direct", "Exchange". - :type kind: str or ~azure.mgmt.peering.models.Kind - :param location: Required. The location of the resource. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param direct: The properties that define a direct peering. - :type direct: ~azure.mgmt.peering.models.PeeringPropertiesDirect - :param exchange: The properties that define an exchange peering. - :type exchange: ~azure.mgmt.peering.models.PeeringPropertiesExchange - :param peering_location: The location of the peering. - :type peering_location: str + :ivar sku: Required. The SKU that defines the tier and kind of the peering. + :vartype sku: ~azure.mgmt.peering.models.PeeringSku + :ivar kind: Required. The kind of the peering. Possible values include: "Direct", "Exchange". + :vartype kind: str or ~azure.mgmt.peering.models.Kind + :ivar location: Required. The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar direct: The properties that define a direct peering. + :vartype direct: ~azure.mgmt.peering.models.PeeringPropertiesDirect + :ivar exchange: The properties that define an exchange peering. + :vartype exchange: ~azure.mgmt.peering.models.PeeringPropertiesExchange + :ivar peering_location: The location of the peering. + :vartype peering_location: str :ivar provisioning_state: The provisioning state of the resource. Possible values include: "Succeeded", "Updating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState @@ -666,6 +1210,23 @@ def __init__( peering_location: Optional[str] = None, **kwargs ): + """ + :keyword sku: Required. The SKU that defines the tier and kind of the peering. + :paramtype sku: ~azure.mgmt.peering.models.PeeringSku + :keyword kind: Required. The kind of the peering. Possible values include: "Direct", + "Exchange". + :paramtype kind: str or ~azure.mgmt.peering.models.Kind + :keyword location: Required. The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword direct: The properties that define a direct peering. + :paramtype direct: ~azure.mgmt.peering.models.PeeringPropertiesDirect + :keyword exchange: The properties that define an exchange peering. + :paramtype exchange: ~azure.mgmt.peering.models.PeeringPropertiesExchange + :keyword peering_location: The location of the peering. + :paramtype peering_location: str + """ super(Peering, self).__init__(**kwargs) self.sku = sku self.kind = kind @@ -680,10 +1241,10 @@ def __init__( class PeeringBandwidthOffer(msrest.serialization.Model): """The properties that define a peering bandwidth offer. - :param offer_name: The name of the bandwidth offer. - :type offer_name: str - :param value_in_mbps: The value of the bandwidth offer in Mbps. - :type value_in_mbps: int + :ivar offer_name: The name of the bandwidth offer. + :vartype offer_name: str + :ivar value_in_mbps: The value of the bandwidth offer in Mbps. + :vartype value_in_mbps: int """ _attribute_map = { @@ -698,6 +1259,12 @@ def __init__( value_in_mbps: Optional[int] = None, **kwargs ): + """ + :keyword offer_name: The name of the bandwidth offer. + :paramtype offer_name: str + :keyword value_in_mbps: The value of the bandwidth offer in Mbps. + :paramtype value_in_mbps: int + """ super(PeeringBandwidthOffer, self).__init__(**kwargs) self.offer_name = offer_name self.value_in_mbps = value_in_mbps @@ -706,10 +1273,10 @@ def __init__( class PeeringListResult(msrest.serialization.Model): """The paginated list of peerings. - :param value: The list of peerings. - :type value: list[~azure.mgmt.peering.models.Peering] - :param next_link: The link to fetch the next page of peerings. - :type next_link: str + :ivar value: The list of peerings. + :vartype value: list[~azure.mgmt.peering.models.Peering] + :ivar next_link: The link to fetch the next page of peerings. + :vartype next_link: str """ _attribute_map = { @@ -724,6 +1291,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peerings. + :paramtype value: list[~azure.mgmt.peering.models.Peering] + :keyword next_link: The link to fetch the next page of peerings. + :paramtype next_link: str + """ super(PeeringListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -740,19 +1313,19 @@ class PeeringLocation(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param kind: The kind of peering that the peering location supports. Possible values include: + :ivar kind: The kind of peering that the peering location supports. Possible values include: "Direct", "Exchange". - :type kind: str or ~azure.mgmt.peering.models.Kind - :param direct: The properties that define a direct peering location. - :type direct: ~azure.mgmt.peering.models.PeeringLocationPropertiesDirect - :param exchange: The properties that define an exchange peering location. - :type exchange: ~azure.mgmt.peering.models.PeeringLocationPropertiesExchange - :param peering_location: The name of the peering location. - :type peering_location: str - :param country: The country in which the peering location exists. - :type country: str - :param azure_region: The Azure region associated with the peering location. - :type azure_region: str + :vartype kind: str or ~azure.mgmt.peering.models.Kind + :ivar direct: The properties that define a direct peering location. + :vartype direct: ~azure.mgmt.peering.models.PeeringLocationPropertiesDirect + :ivar exchange: The properties that define an exchange peering location. + :vartype exchange: ~azure.mgmt.peering.models.PeeringLocationPropertiesExchange + :ivar peering_location: The name of the peering location. + :vartype peering_location: str + :ivar country: The country in which the peering location exists. + :vartype country: str + :ivar azure_region: The Azure region associated with the peering location. + :vartype azure_region: str """ _validation = { @@ -784,6 +1357,21 @@ def __init__( azure_region: Optional[str] = None, **kwargs ): + """ + :keyword kind: The kind of peering that the peering location supports. Possible values include: + "Direct", "Exchange". + :paramtype kind: str or ~azure.mgmt.peering.models.Kind + :keyword direct: The properties that define a direct peering location. + :paramtype direct: ~azure.mgmt.peering.models.PeeringLocationPropertiesDirect + :keyword exchange: The properties that define an exchange peering location. + :paramtype exchange: ~azure.mgmt.peering.models.PeeringLocationPropertiesExchange + :keyword peering_location: The name of the peering location. + :paramtype peering_location: str + :keyword country: The country in which the peering location exists. + :paramtype country: str + :keyword azure_region: The Azure region associated with the peering location. + :paramtype azure_region: str + """ super(PeeringLocation, self).__init__(**kwargs) self.kind = kind self.direct = direct @@ -796,10 +1384,10 @@ def __init__( class PeeringLocationListResult(msrest.serialization.Model): """The paginated list of peering locations. - :param value: The list of peering locations. - :type value: list[~azure.mgmt.peering.models.PeeringLocation] - :param next_link: The link to fetch the next page of peering locations. - :type next_link: str + :ivar value: The list of peering locations. + :vartype value: list[~azure.mgmt.peering.models.PeeringLocation] + :ivar next_link: The link to fetch the next page of peering locations. + :vartype next_link: str """ _attribute_map = { @@ -814,6 +1402,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peering locations. + :paramtype value: list[~azure.mgmt.peering.models.PeeringLocation] + :keyword next_link: The link to fetch the next page of peering locations. + :paramtype next_link: str + """ super(PeeringLocationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -822,10 +1416,10 @@ def __init__( class PeeringLocationPropertiesDirect(msrest.serialization.Model): """The properties that define a direct peering location. - :param peering_facilities: The list of direct peering facilities at the peering location. - :type peering_facilities: list[~azure.mgmt.peering.models.DirectPeeringFacility] - :param bandwidth_offers: The list of bandwidth offers available at the peering location. - :type bandwidth_offers: list[~azure.mgmt.peering.models.PeeringBandwidthOffer] + :ivar peering_facilities: The list of direct peering facilities at the peering location. + :vartype peering_facilities: list[~azure.mgmt.peering.models.DirectPeeringFacility] + :ivar bandwidth_offers: The list of bandwidth offers available at the peering location. + :vartype bandwidth_offers: list[~azure.mgmt.peering.models.PeeringBandwidthOffer] """ _attribute_map = { @@ -840,6 +1434,12 @@ def __init__( bandwidth_offers: Optional[List["PeeringBandwidthOffer"]] = None, **kwargs ): + """ + :keyword peering_facilities: The list of direct peering facilities at the peering location. + :paramtype peering_facilities: list[~azure.mgmt.peering.models.DirectPeeringFacility] + :keyword bandwidth_offers: The list of bandwidth offers available at the peering location. + :paramtype bandwidth_offers: list[~azure.mgmt.peering.models.PeeringBandwidthOffer] + """ super(PeeringLocationPropertiesDirect, self).__init__(**kwargs) self.peering_facilities = peering_facilities self.bandwidth_offers = bandwidth_offers @@ -848,8 +1448,8 @@ def __init__( class PeeringLocationPropertiesExchange(msrest.serialization.Model): """The properties that define an exchange peering location. - :param peering_facilities: The list of exchange peering facilities at the peering location. - :type peering_facilities: list[~azure.mgmt.peering.models.ExchangePeeringFacility] + :ivar peering_facilities: The list of exchange peering facilities at the peering location. + :vartype peering_facilities: list[~azure.mgmt.peering.models.ExchangePeeringFacility] """ _attribute_map = { @@ -862,6 +1462,10 @@ def __init__( peering_facilities: Optional[List["ExchangePeeringFacility"]] = None, **kwargs ): + """ + :keyword peering_facilities: The list of exchange peering facilities at the peering location. + :paramtype peering_facilities: list[~azure.mgmt.peering.models.ExchangePeeringFacility] + """ super(PeeringLocationPropertiesExchange, self).__init__(**kwargs) self.peering_facilities = peering_facilities @@ -869,18 +1473,24 @@ def __init__( class PeeringPropertiesDirect(msrest.serialization.Model): """The properties that define a direct peering. - :param connections: The set of connections that constitute a direct peering. - :type connections: list[~azure.mgmt.peering.models.DirectConnection] - :param use_for_peering_service: The flag that indicates whether or not the peering is used for + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar connections: The set of connections that constitute a direct peering. + :vartype connections: list[~azure.mgmt.peering.models.DirectConnection] + :ivar use_for_peering_service: The flag that indicates whether or not the peering is used for peering service. - :type use_for_peering_service: bool - :param peer_asn: The reference of the peer ASN. - :type peer_asn: ~azure.mgmt.peering.models.SubResource - :param direct_peering_type: The type of direct peering. Possible values include: "Edge", - "Transit", "Cdn", "Internal". - :type direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType + :vartype use_for_peering_service: bool + :ivar peer_asn: The reference of the peer ASN. + :vartype peer_asn: ~azure.mgmt.peering.models.SubResource + :ivar direct_peering_type: The type of direct peering. Possible values include: "Edge", + "Transit", "Cdn", "Internal", "Ix", "IxRs", "Voice", "EdgeZoneForOperators". + :vartype direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType """ + _validation = { + 'use_for_peering_service': {'readonly': True}, + } + _attribute_map = { 'connections': {'key': 'connections', 'type': '[DirectConnection]'}, 'use_for_peering_service': {'key': 'useForPeeringService', 'type': 'bool'}, @@ -892,14 +1502,22 @@ def __init__( self, *, connections: Optional[List["DirectConnection"]] = None, - use_for_peering_service: Optional[bool] = None, peer_asn: Optional["SubResource"] = None, direct_peering_type: Optional[Union[str, "DirectPeeringType"]] = None, **kwargs ): + """ + :keyword connections: The set of connections that constitute a direct peering. + :paramtype connections: list[~azure.mgmt.peering.models.DirectConnection] + :keyword peer_asn: The reference of the peer ASN. + :paramtype peer_asn: ~azure.mgmt.peering.models.SubResource + :keyword direct_peering_type: The type of direct peering. Possible values include: "Edge", + "Transit", "Cdn", "Internal", "Ix", "IxRs", "Voice", "EdgeZoneForOperators". + :paramtype direct_peering_type: str or ~azure.mgmt.peering.models.DirectPeeringType + """ super(PeeringPropertiesDirect, self).__init__(**kwargs) self.connections = connections - self.use_for_peering_service = use_for_peering_service + self.use_for_peering_service = None self.peer_asn = peer_asn self.direct_peering_type = direct_peering_type @@ -907,10 +1525,10 @@ def __init__( class PeeringPropertiesExchange(msrest.serialization.Model): """The properties that define an exchange peering. - :param connections: The set of connections that constitute an exchange peering. - :type connections: list[~azure.mgmt.peering.models.ExchangeConnection] - :param peer_asn: The reference of the peer ASN. - :type peer_asn: ~azure.mgmt.peering.models.SubResource + :ivar connections: The set of connections that constitute an exchange peering. + :vartype connections: list[~azure.mgmt.peering.models.ExchangeConnection] + :ivar peer_asn: The reference of the peer ASN. + :vartype peer_asn: ~azure.mgmt.peering.models.SubResource """ _attribute_map = { @@ -925,11 +1543,291 @@ def __init__( peer_asn: Optional["SubResource"] = None, **kwargs ): + """ + :keyword connections: The set of connections that constitute an exchange peering. + :paramtype connections: list[~azure.mgmt.peering.models.ExchangeConnection] + :keyword peer_asn: The reference of the peer ASN. + :paramtype peer_asn: ~azure.mgmt.peering.models.SubResource + """ super(PeeringPropertiesExchange, self).__init__(**kwargs) self.connections = connections self.peer_asn = peer_asn +class PeeringReceivedRoute(msrest.serialization.Model): + """The properties that define a received route. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar prefix: The prefix. + :vartype prefix: str + :ivar next_hop: The next hop for the prefix. + :vartype next_hop: str + :ivar as_path: The AS path for the prefix. + :vartype as_path: str + :ivar origin_as_validation_state: The origin AS change information for the prefix. + :vartype origin_as_validation_state: str + :ivar rpki_validation_state: The RPKI validation state for the prefix and origin AS that's + listed in the AS path. + :vartype rpki_validation_state: str + :ivar trust_anchor: The authority which holds the Route Origin Authorization record for the + prefix, if any. + :vartype trust_anchor: str + :ivar received_timestamp: The received timestamp associated with the prefix. + :vartype received_timestamp: str + """ + + _validation = { + 'prefix': {'readonly': True}, + 'next_hop': {'readonly': True}, + 'as_path': {'readonly': True}, + 'origin_as_validation_state': {'readonly': True}, + 'rpki_validation_state': {'readonly': True}, + 'trust_anchor': {'readonly': True}, + 'received_timestamp': {'readonly': True}, + } + + _attribute_map = { + 'prefix': {'key': 'prefix', 'type': 'str'}, + 'next_hop': {'key': 'nextHop', 'type': 'str'}, + 'as_path': {'key': 'asPath', 'type': 'str'}, + 'origin_as_validation_state': {'key': 'originAsValidationState', 'type': 'str'}, + 'rpki_validation_state': {'key': 'rpkiValidationState', 'type': 'str'}, + 'trust_anchor': {'key': 'trustAnchor', 'type': 'str'}, + 'received_timestamp': {'key': 'receivedTimestamp', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PeeringReceivedRoute, self).__init__(**kwargs) + self.prefix = None + self.next_hop = None + self.as_path = None + self.origin_as_validation_state = None + self.rpki_validation_state = None + self.trust_anchor = None + self.received_timestamp = None + + +class PeeringReceivedRouteListResult(msrest.serialization.Model): + """The paginated list of received routes for the peering. + + :ivar value: The list of received routes for the peering. + :vartype value: list[~azure.mgmt.peering.models.PeeringReceivedRoute] + :ivar next_link: The link to fetch the next page of received routes for the peering. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PeeringReceivedRoute]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PeeringReceivedRoute"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of received routes for the peering. + :paramtype value: list[~azure.mgmt.peering.models.PeeringReceivedRoute] + :keyword next_link: The link to fetch the next page of received routes for the peering. + :paramtype next_link: str + """ + super(PeeringReceivedRouteListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PeeringRegisteredAsn(Resource): + """The customer's ASN that is registered by the peering service provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the resource. + :vartype name: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str + :ivar asn: The customer's ASN from which traffic originates. + :vartype asn: int + :ivar peering_service_prefix_key: The peering service prefix key that is to be shared with the + customer. + :vartype peering_service_prefix_key: str + :ivar provisioning_state: The provisioning state of the resource. Possible values include: + "Succeeded", "Updating", "Deleting", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'peering_service_prefix_key': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'asn': {'key': 'properties.asn', 'type': 'int'}, + 'peering_service_prefix_key': {'key': 'properties.peeringServicePrefixKey', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + asn: Optional[int] = None, + **kwargs + ): + """ + :keyword asn: The customer's ASN from which traffic originates. + :paramtype asn: int + """ + super(PeeringRegisteredAsn, self).__init__(**kwargs) + self.asn = asn + self.peering_service_prefix_key = None + self.provisioning_state = None + + +class PeeringRegisteredAsnListResult(msrest.serialization.Model): + """The paginated list of peering registered ASNs. + + :ivar value: The list of peering registered ASNs. + :vartype value: list[~azure.mgmt.peering.models.PeeringRegisteredAsn] + :ivar next_link: The link to fetch the next page of peering registered ASNs. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PeeringRegisteredAsn]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PeeringRegisteredAsn"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of peering registered ASNs. + :paramtype value: list[~azure.mgmt.peering.models.PeeringRegisteredAsn] + :keyword next_link: The link to fetch the next page of peering registered ASNs. + :paramtype next_link: str + """ + super(PeeringRegisteredAsnListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PeeringRegisteredPrefix(Resource): + """The customer's prefix that is registered by the peering service provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the resource. + :vartype name: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str + :ivar prefix: The customer's prefix from which traffic originates. + :vartype prefix: str + :ivar prefix_validation_state: The prefix validation state. Possible values include: "None", + "Invalid", "Verified", "Failed", "Pending", "Warning", "Unknown". + :vartype prefix_validation_state: str or ~azure.mgmt.peering.models.PrefixValidationState + :ivar peering_service_prefix_key: The peering service prefix key that is to be shared with the + customer. + :vartype peering_service_prefix_key: str + :ivar error_message: The error message associated with the validation state, if any. + :vartype error_message: str + :ivar provisioning_state: The provisioning state of the resource. Possible values include: + "Succeeded", "Updating", "Deleting", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'prefix_validation_state': {'readonly': True}, + 'peering_service_prefix_key': {'readonly': True}, + 'error_message': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'prefix': {'key': 'properties.prefix', 'type': 'str'}, + 'prefix_validation_state': {'key': 'properties.prefixValidationState', 'type': 'str'}, + 'peering_service_prefix_key': {'key': 'properties.peeringServicePrefixKey', 'type': 'str'}, + 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + prefix: Optional[str] = None, + **kwargs + ): + """ + :keyword prefix: The customer's prefix from which traffic originates. + :paramtype prefix: str + """ + super(PeeringRegisteredPrefix, self).__init__(**kwargs) + self.prefix = prefix + self.prefix_validation_state = None + self.peering_service_prefix_key = None + self.error_message = None + self.provisioning_state = None + + +class PeeringRegisteredPrefixListResult(msrest.serialization.Model): + """The paginated list of peering registered prefixes. + + :ivar value: The list of peering registered prefixes. + :vartype value: list[~azure.mgmt.peering.models.PeeringRegisteredPrefix] + :ivar next_link: The link to fetch the next page of peering registered prefixes. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PeeringRegisteredPrefix]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PeeringRegisteredPrefix"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of peering registered prefixes. + :paramtype value: list[~azure.mgmt.peering.models.PeeringRegisteredPrefix] + :keyword next_link: The link to fetch the next page of peering registered prefixes. + :paramtype next_link: str + """ + super(PeeringRegisteredPrefixListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class PeeringService(Resource): """Peering Service. @@ -943,17 +1841,28 @@ class PeeringService(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param location: Required. The location of the resource. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param peering_service_location: The PeeringServiceLocation of the Customer. - :type peering_service_location: str - :param peering_service_provider: The MAPS Provider Name. - :type peering_service_provider: str + :ivar sku: The SKU that defines the type of the peering service. + :vartype sku: ~azure.mgmt.peering.models.PeeringServiceSku + :ivar location: Required. The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar peering_service_location: The location (state/province) of the customer. + :vartype peering_service_location: str + :ivar peering_service_provider: The name of the service provider. + :vartype peering_service_provider: str :ivar provisioning_state: The provisioning state of the resource. Possible values include: "Succeeded", "Updating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState + :ivar provider_primary_peering_location: The primary peering (Microsoft/service provider) + location to be used for customer traffic. + :vartype provider_primary_peering_location: str + :ivar provider_backup_peering_location: The backup peering (Microsoft/service provider) + location to be used for customer traffic. + :vartype provider_backup_peering_location: str + :ivar log_analytics_workspace_properties: The Log Analytics Workspace Properties. + :vartype log_analytics_workspace_properties: + ~azure.mgmt.peering.models.LogAnalyticsWorkspaceProperties """ _validation = { @@ -968,37 +1877,136 @@ class PeeringService(Resource): 'name': {'key': 'name', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PeeringServiceSku'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'peering_service_location': {'key': 'properties.peeringServiceLocation', 'type': 'str'}, 'peering_service_provider': {'key': 'properties.peeringServiceProvider', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'provider_primary_peering_location': {'key': 'properties.providerPrimaryPeeringLocation', 'type': 'str'}, + 'provider_backup_peering_location': {'key': 'properties.providerBackupPeeringLocation', 'type': 'str'}, + 'log_analytics_workspace_properties': {'key': 'properties.logAnalyticsWorkspaceProperties', 'type': 'LogAnalyticsWorkspaceProperties'}, } def __init__( self, *, location: str, + sku: Optional["PeeringServiceSku"] = None, tags: Optional[Dict[str, str]] = None, peering_service_location: Optional[str] = None, peering_service_provider: Optional[str] = None, + provider_primary_peering_location: Optional[str] = None, + provider_backup_peering_location: Optional[str] = None, + log_analytics_workspace_properties: Optional["LogAnalyticsWorkspaceProperties"] = None, **kwargs ): + """ + :keyword sku: The SKU that defines the type of the peering service. + :paramtype sku: ~azure.mgmt.peering.models.PeeringServiceSku + :keyword location: Required. The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword peering_service_location: The location (state/province) of the customer. + :paramtype peering_service_location: str + :keyword peering_service_provider: The name of the service provider. + :paramtype peering_service_provider: str + :keyword provider_primary_peering_location: The primary peering (Microsoft/service provider) + location to be used for customer traffic. + :paramtype provider_primary_peering_location: str + :keyword provider_backup_peering_location: The backup peering (Microsoft/service provider) + location to be used for customer traffic. + :paramtype provider_backup_peering_location: str + :keyword log_analytics_workspace_properties: The Log Analytics Workspace Properties. + :paramtype log_analytics_workspace_properties: + ~azure.mgmt.peering.models.LogAnalyticsWorkspaceProperties + """ super(PeeringService, self).__init__(**kwargs) + self.sku = sku self.location = location self.tags = tags self.peering_service_location = peering_service_location self.peering_service_provider = peering_service_provider self.provisioning_state = None + self.provider_primary_peering_location = provider_primary_peering_location + self.provider_backup_peering_location = provider_backup_peering_location + self.log_analytics_workspace_properties = log_analytics_workspace_properties + + +class PeeringServiceCountry(Resource): + """The peering service country. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the resource. + :vartype name: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PeeringServiceCountry, self).__init__(**kwargs) + + +class PeeringServiceCountryListResult(msrest.serialization.Model): + """The paginated list of peering service countries. + + :ivar value: The list of peering service countries. + :vartype value: list[~azure.mgmt.peering.models.PeeringServiceCountry] + :ivar next_link: The link to fetch the next page of peering service countries. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PeeringServiceCountry]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PeeringServiceCountry"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of peering service countries. + :paramtype value: list[~azure.mgmt.peering.models.PeeringServiceCountry] + :keyword next_link: The link to fetch the next page of peering service countries. + :paramtype next_link: str + """ + super(PeeringServiceCountryListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link class PeeringServiceListResult(msrest.serialization.Model): """The paginated list of peering services. - :param value: The list of peering services. - :type value: list[~azure.mgmt.peering.models.PeeringService] - :param next_link: The link to fetch the next page of peering services. - :type next_link: str + :ivar value: The list of peering services. + :vartype value: list[~azure.mgmt.peering.models.PeeringService] + :ivar next_link: The link to fetch the next page of peering services. + :vartype next_link: str """ _attribute_map = { @@ -1013,13 +2021,19 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peering services. + :paramtype value: list[~azure.mgmt.peering.models.PeeringService] + :keyword next_link: The link to fetch the next page of peering services. + :paramtype next_link: str + """ super(PeeringServiceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link class PeeringServiceLocation(Resource): - """PeeringService location. + """The peering service location. Variables are only populated by the server, and will be ignored when sending a request. @@ -1029,12 +2043,12 @@ class PeeringServiceLocation(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param country: Country of the customer. - :type country: str - :param state: State of the customer. - :type state: str - :param azure_region: Azure region for the location. - :type azure_region: str + :ivar country: Country of the customer. + :vartype country: str + :ivar state: State of the customer. + :vartype state: str + :ivar azure_region: Azure region for the location. + :vartype azure_region: str """ _validation = { @@ -1060,6 +2074,14 @@ def __init__( azure_region: Optional[str] = None, **kwargs ): + """ + :keyword country: Country of the customer. + :paramtype country: str + :keyword state: State of the customer. + :paramtype state: str + :keyword azure_region: Azure region for the location. + :paramtype azure_region: str + """ super(PeeringServiceLocation, self).__init__(**kwargs) self.country = country self.state = state @@ -1069,10 +2091,10 @@ def __init__( class PeeringServiceLocationListResult(msrest.serialization.Model): """The paginated list of peering service locations. - :param value: The list of peering service locations. - :type value: list[~azure.mgmt.peering.models.PeeringServiceLocation] - :param next_link: The link to fetch the next page of peering service locations. - :type next_link: str + :ivar value: The list of peering service locations. + :vartype value: list[~azure.mgmt.peering.models.PeeringServiceLocation] + :ivar next_link: The link to fetch the next page of peering service locations. + :vartype next_link: str """ _attribute_map = { @@ -1087,6 +2109,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peering service locations. + :paramtype value: list[~azure.mgmt.peering.models.PeeringServiceLocation] + :keyword next_link: The link to fetch the next page of peering service locations. + :paramtype next_link: str + """ super(PeeringServiceLocationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1103,14 +2131,20 @@ class PeeringServicePrefix(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param prefix: Valid route prefix. - :type prefix: str - :param prefix_validation_state: The prefix validation state. Possible values include: "None", - "Invalid", "Verified", "Failed", "Pending", "Unknown". - :type prefix_validation_state: str or ~azure.mgmt.peering.models.PrefixValidationState - :param learned_type: The prefix learned type. Possible values include: "None", "ViaPartner", - "ViaSession". - :type learned_type: str or ~azure.mgmt.peering.models.LearnedType + :ivar prefix: The prefix from which your traffic originates. + :vartype prefix: str + :ivar prefix_validation_state: The prefix validation state. Possible values include: "None", + "Invalid", "Verified", "Failed", "Pending", "Warning", "Unknown". + :vartype prefix_validation_state: str or ~azure.mgmt.peering.models.PrefixValidationState + :ivar learned_type: The prefix learned type. Possible values include: "None", + "ViaServiceProvider", "ViaSession". + :vartype learned_type: str or ~azure.mgmt.peering.models.LearnedType + :ivar error_message: The error message for validation state. + :vartype error_message: str + :ivar events: The list of events for peering service prefix. + :vartype events: list[~azure.mgmt.peering.models.PeeringServicePrefixEvent] + :ivar peering_service_prefix_key: The peering service prefix key. + :vartype peering_service_prefix_key: str :ivar provisioning_state: The provisioning state of the resource. Possible values include: "Succeeded", "Updating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.peering.models.ProvisioningState @@ -1120,6 +2154,10 @@ class PeeringServicePrefix(Resource): 'name': {'readonly': True}, 'id': {'readonly': True}, 'type': {'readonly': True}, + 'prefix_validation_state': {'readonly': True}, + 'learned_type': {'readonly': True}, + 'error_message': {'readonly': True}, + 'events': {'readonly': True}, 'provisioning_state': {'readonly': True}, } @@ -1130,6 +2168,9 @@ class PeeringServicePrefix(Resource): 'prefix': {'key': 'properties.prefix', 'type': 'str'}, 'prefix_validation_state': {'key': 'properties.prefixValidationState', 'type': 'str'}, 'learned_type': {'key': 'properties.learnedType', 'type': 'str'}, + 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + 'events': {'key': 'properties.events', 'type': '[PeeringServicePrefixEvent]'}, + 'peering_service_prefix_key': {'key': 'properties.peeringServicePrefixKey', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } @@ -1137,24 +2178,79 @@ def __init__( self, *, prefix: Optional[str] = None, - prefix_validation_state: Optional[Union[str, "PrefixValidationState"]] = None, - learned_type: Optional[Union[str, "LearnedType"]] = None, + peering_service_prefix_key: Optional[str] = None, **kwargs ): + """ + :keyword prefix: The prefix from which your traffic originates. + :paramtype prefix: str + :keyword peering_service_prefix_key: The peering service prefix key. + :paramtype peering_service_prefix_key: str + """ super(PeeringServicePrefix, self).__init__(**kwargs) self.prefix = prefix - self.prefix_validation_state = prefix_validation_state - self.learned_type = learned_type + self.prefix_validation_state = None + self.learned_type = None + self.error_message = None + self.events = None + self.peering_service_prefix_key = peering_service_prefix_key self.provisioning_state = None +class PeeringServicePrefixEvent(msrest.serialization.Model): + """The details of the event associated with a prefix. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar event_timestamp: The timestamp of the event associated with a prefix. + :vartype event_timestamp: ~datetime.datetime + :ivar event_type: The type of the event associated with a prefix. + :vartype event_type: str + :ivar event_summary: The summary of the event associated with a prefix. + :vartype event_summary: str + :ivar event_level: The level of the event associated with a prefix. + :vartype event_level: str + :ivar event_description: The description of the event associated with a prefix. + :vartype event_description: str + """ + + _validation = { + 'event_timestamp': {'readonly': True}, + 'event_type': {'readonly': True}, + 'event_summary': {'readonly': True}, + 'event_level': {'readonly': True}, + 'event_description': {'readonly': True}, + } + + _attribute_map = { + 'event_timestamp': {'key': 'eventTimestamp', 'type': 'iso-8601'}, + 'event_type': {'key': 'eventType', 'type': 'str'}, + 'event_summary': {'key': 'eventSummary', 'type': 'str'}, + 'event_level': {'key': 'eventLevel', 'type': 'str'}, + 'event_description': {'key': 'eventDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PeeringServicePrefixEvent, self).__init__(**kwargs) + self.event_timestamp = None + self.event_type = None + self.event_summary = None + self.event_level = None + self.event_description = None + + class PeeringServicePrefixListResult(msrest.serialization.Model): - """The paginated list of [T]. + """The paginated list of peering service prefixes. - :param value: The list of [T]. - :type value: list[~azure.mgmt.peering.models.PeeringServicePrefix] - :param next_link: The link to fetch the next page of [T]. - :type next_link: str + :ivar value: The list of peering service prefixes. + :vartype value: list[~azure.mgmt.peering.models.PeeringServicePrefix] + :ivar next_link: The link to fetch the next page of peering service prefixes. + :vartype next_link: str """ _attribute_map = { @@ -1169,6 +2265,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peering service prefixes. + :paramtype value: list[~azure.mgmt.peering.models.PeeringServicePrefix] + :keyword next_link: The link to fetch the next page of peering service prefixes. + :paramtype next_link: str + """ super(PeeringServicePrefixListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1185,8 +2287,11 @@ class PeeringServiceProvider(Resource): :vartype id: str :ivar type: The type of the resource. :vartype type: str - :param service_provider_name: The name of the service provider. - :type service_provider_name: str + :ivar service_provider_name: The name of the service provider. + :vartype service_provider_name: str + :ivar peering_locations: The list of locations at which the service provider peers with + Microsoft. + :vartype peering_locations: list[str] """ _validation = { @@ -1200,25 +2305,35 @@ class PeeringServiceProvider(Resource): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'service_provider_name': {'key': 'properties.serviceProviderName', 'type': 'str'}, + 'peering_locations': {'key': 'properties.peeringLocations', 'type': '[str]'}, } def __init__( self, *, service_provider_name: Optional[str] = None, + peering_locations: Optional[List[str]] = None, **kwargs ): + """ + :keyword service_provider_name: The name of the service provider. + :paramtype service_provider_name: str + :keyword peering_locations: The list of locations at which the service provider peers with + Microsoft. + :paramtype peering_locations: list[str] + """ super(PeeringServiceProvider, self).__init__(**kwargs) self.service_provider_name = service_provider_name + self.peering_locations = peering_locations class PeeringServiceProviderListResult(msrest.serialization.Model): """The paginated list of peering service providers. - :param value: The list of peering service providers. - :type value: list[~azure.mgmt.peering.models.PeeringServiceProvider] - :param next_link: The link to fetch the next page of peering service providers. - :type next_link: str + :ivar value: The list of peering service providers. + :vartype value: list[~azure.mgmt.peering.models.PeeringServiceProvider] + :ivar next_link: The link to fetch the next page of peering service providers. + :vartype next_link: str """ _attribute_map = { @@ -1233,27 +2348,64 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of peering service providers. + :paramtype value: list[~azure.mgmt.peering.models.PeeringServiceProvider] + :keyword next_link: The link to fetch the next page of peering service providers. + :paramtype next_link: str + """ super(PeeringServiceProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link +class PeeringServiceSku(msrest.serialization.Model): + """The SKU that defines the type of the peering service. + + :ivar name: The name of the peering service SKU. + :vartype name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the peering service SKU. + :paramtype name: str + """ + super(PeeringServiceSku, self).__init__(**kwargs) + self.name = name + + class PeeringSku(msrest.serialization.Model): """The SKU that defines the tier and kind of the peering. - :param name: The name of the peering SKU. Possible values include: "Basic_Exchange_Free", - "Basic_Direct_Free", "Premium_Direct_Free", "Premium_Exchange_Metered", - "Premium_Direct_Metered", "Premium_Direct_Unlimited". - :type name: str or ~azure.mgmt.peering.models.Name - :param tier: The tier of the peering SKU. Possible values include: "Basic", "Premium". - :type tier: str or ~azure.mgmt.peering.models.Tier - :param family: The family of the peering SKU. Possible values include: "Direct", "Exchange". - :type family: str or ~azure.mgmt.peering.models.Family - :param size: The size of the peering SKU. Possible values include: "Free", "Metered", + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the peering SKU. + :vartype name: str + :ivar tier: The tier of the peering SKU. Possible values include: "Basic", "Premium". + :vartype tier: str or ~azure.mgmt.peering.models.Tier + :ivar family: The family of the peering SKU. Possible values include: "Direct", "Exchange". + :vartype family: str or ~azure.mgmt.peering.models.Family + :ivar size: The size of the peering SKU. Possible values include: "Free", "Metered", "Unlimited". - :type size: str or ~azure.mgmt.peering.models.Size + :vartype size: str or ~azure.mgmt.peering.models.Size """ + _validation = { + 'tier': {'readonly': True}, + 'family': {'readonly': True}, + 'size': {'readonly': True}, + } + _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'tier': {'key': 'tier', 'type': 'str'}, @@ -1264,24 +2416,25 @@ class PeeringSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "Name"]] = None, - tier: Optional[Union[str, "Tier"]] = None, - family: Optional[Union[str, "Family"]] = None, - size: Optional[Union[str, "Size"]] = None, + name: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the peering SKU. + :paramtype name: str + """ super(PeeringSku, self).__init__(**kwargs) self.name = name - self.tier = tier - self.family = family - self.size = size + self.tier = None + self.family = None + self.size = None class ResourceTags(msrest.serialization.Model): """The resource tags. - :param tags: A set of tags. Gets or sets the tags, a dictionary of descriptors arm object. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the tags, a dictionary of descriptors arm object. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1294,15 +2447,46 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets the tags, a dictionary of descriptors arm object. + :paramtype tags: dict[str, str] + """ super(ResourceTags, self).__init__(**kwargs) self.tags = tags +class ServiceSpecification(msrest.serialization.Model): + """Service specification payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: list[~azure.mgmt.peering.models.MetricSpecification] + """ + + _validation = { + 'metric_specifications': {'readonly': True}, + } + + _attribute_map = { + 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ServiceSpecification, self).__init__(**kwargs) + self.metric_specifications = None + + class SubResource(msrest.serialization.Model): """The sub resource. - :param id: The identifier of the referenced resource. - :type id: str + :ivar id: The identifier of the referenced resource. + :vartype id: str """ _attribute_map = { @@ -1315,5 +2499,9 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The identifier of the referenced resource. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_peering_management_client_enums.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_peering_management_client_enums.py index b44f84211b20..1f97a1c4bd24 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_peering_management_client_enums.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/models/_peering_management_client_enums.py @@ -6,27 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) +class Command(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Invoked command + """ + TRACEROUTE = "Traceroute" + PING = "Ping" + BGP_ROUTE = "BgpRoute" -class ConnectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the connection. """ @@ -39,7 +32,7 @@ class ConnectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VALIDATING = "Validating" ACTIVE = "Active" -class DirectPeeringType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DirectPeeringType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of direct peering. """ @@ -47,64 +40,72 @@ class DirectPeeringType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): TRANSIT = "Transit" CDN = "Cdn" INTERNAL = "Internal" + IX = "Ix" + IX_RS = "IxRs" + VOICE = "Voice" + EDGE_ZONE_FOR_OPERATORS = "EdgeZoneForOperators" -class Enum0(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "Available" - UN_AVAILABLE = "UnAvailable" - -class Enum1(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - DIRECT = "Direct" - EXCHANGE = "Exchange" - -class Enum14(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - DIRECT = "Direct" - EXCHANGE = "Exchange" + UNAVAILABLE = "Unavailable" -class Enum15(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - EDGE = "Edge" - TRANSIT = "Transit" - CDN = "Cdn" - INTERNAL = "Internal" - -class Family(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Family(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The family of the peering SKU. """ DIRECT = "Direct" EXCHANGE = "Exchange" -class Kind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of the peering. """ DIRECT = "Direct" EXCHANGE = "Exchange" -class LearnedType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LearnedType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The prefix learned type """ NONE = "None" - VIA_PARTNER = "ViaPartner" + VIA_SERVICE_PROVIDER = "ViaServiceProvider" VIA_SESSION = "ViaSession" -class Name(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The name of the peering SKU. - """ +class LegacyPeeringsKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - BASIC_EXCHANGE_FREE = "Basic_Exchange_Free" - BASIC_DIRECT_FREE = "Basic_Direct_Free" - PREMIUM_DIRECT_FREE = "Premium_Direct_Free" - PREMIUM_EXCHANGE_METERED = "Premium_Exchange_Metered" - PREMIUM_DIRECT_METERED = "Premium_Direct_Metered" - PREMIUM_DIRECT_UNLIMITED = "Premium_Direct_Unlimited" + DIRECT = "Direct" + EXCHANGE = "Exchange" -class PrefixValidationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The prefix validation state +class LookingGlassCommand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + TRACEROUTE = "Traceroute" + PING = "Ping" + BGP_ROUTE = "BgpRoute" + +class LookingGlassSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + EDGE_SITE = "EdgeSite" + AZURE_REGION = "AzureRegion" + +class PeeringLocationsDirectPeeringType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + EDGE = "Edge" + TRANSIT = "Transit" + CDN = "Cdn" + INTERNAL = "Internal" + IX = "Ix" + IX_RS = "IxRs" + VOICE = "Voice" + EDGE_ZONE_FOR_OPERATORS = "EdgeZoneForOperators" + +class PeeringLocationsKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + DIRECT = "Direct" + EXCHANGE = "Exchange" + +class PrefixValidationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The prefix validation state. """ NONE = "None" @@ -112,9 +113,10 @@ class PrefixValidationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) VERIFIED = "Verified" FAILED = "Failed" PENDING = "Pending" + WARNING = "Warning" UNKNOWN = "Unknown" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the resource. """ @@ -123,14 +125,25 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETING = "Deleting" FAILED = "Failed" -class SessionAddressProvider(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Role(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The role of the contact. + """ + + NOC = "Noc" + POLICY = "Policy" + TECHNICAL = "Technical" + SERVICE = "Service" + ESCALATION = "Escalation" + OTHER = "Other" + +class SessionAddressProvider(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The field indicating if Microsoft provides session ip addresses. """ MICROSOFT = "Microsoft" PEER = "Peer" -class SessionStateV4(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SessionStateV4(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the IPv4 session. """ @@ -146,7 +159,7 @@ class SessionStateV4(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PENDING_UPDATE = "PendingUpdate" PENDING_REMOVE = "PendingRemove" -class SessionStateV6(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SessionStateV6(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the IPv6 session. """ @@ -162,7 +175,7 @@ class SessionStateV6(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PENDING_UPDATE = "PendingUpdate" PENDING_REMOVE = "PendingRemove" -class Size(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Size(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The size of the peering SKU. """ @@ -170,14 +183,14 @@ class Size(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): METERED = "Metered" UNLIMITED = "Unlimited" -class Tier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Tier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The tier of the peering SKU. """ BASIC = "Basic" PREMIUM = "Premium" -class ValidationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ValidationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The validation state of the ASN associated with the peer. """ diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/__init__.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/__init__.py index 2c62d44850a9..ceb6794fa18e 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/__init__.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/__init__.py @@ -6,27 +6,39 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._cdn_peering_prefixes_operations import CdnPeeringPrefixesOperations from ._peering_management_client_operations import PeeringManagementClientOperationsMixin from ._legacy_peerings_operations import LegacyPeeringsOperations +from ._looking_glass_operations import LookingGlassOperations from ._operations import Operations from ._peer_asns_operations import PeerAsnsOperations from ._peering_locations_operations import PeeringLocationsOperations +from ._registered_asns_operations import RegisteredAsnsOperations +from ._registered_prefixes_operations import RegisteredPrefixesOperations from ._peerings_operations import PeeringsOperations +from ._received_routes_operations import ReceivedRoutesOperations +from ._connection_monitor_tests_operations import ConnectionMonitorTestsOperations +from ._peering_service_countries_operations import PeeringServiceCountriesOperations from ._peering_service_locations_operations import PeeringServiceLocationsOperations -from ._peering_service_prefixes_operations import PeeringServicePrefixesOperations from ._prefixes_operations import PrefixesOperations from ._peering_service_providers_operations import PeeringServiceProvidersOperations from ._peering_services_operations import PeeringServicesOperations __all__ = [ + 'CdnPeeringPrefixesOperations', 'PeeringManagementClientOperationsMixin', 'LegacyPeeringsOperations', + 'LookingGlassOperations', 'Operations', 'PeerAsnsOperations', 'PeeringLocationsOperations', + 'RegisteredAsnsOperations', + 'RegisteredPrefixesOperations', 'PeeringsOperations', + 'ReceivedRoutesOperations', + 'ConnectionMonitorTestsOperations', + 'PeeringServiceCountriesOperations', 'PeeringServiceLocationsOperations', - 'PeeringServicePrefixesOperations', 'PrefixesOperations', 'PeeringServiceProvidersOperations', 'PeeringServicesOperations', diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_cdn_peering_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_cdn_peering_prefixes_operations.py new file mode 100644 index 000000000000..fb1e5f0612fe --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_cdn_peering_prefixes_operations.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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 msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + peering_location: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/cdnPeeringPrefixes') + 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['peeringLocation'] = _SERIALIZER.query("peering_location", peering_location, 'str') + 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 CdnPeeringPrefixesOperations(object): + """CdnPeeringPrefixesOperations 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.peering.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, + peering_location: str, + **kwargs: Any + ) -> Iterable["_models.CdnPeeringPrefixListResult"]: + """Lists all of the advertised prefixes for the specified peering location. + + :param peering_location: The peering location. + :type peering_location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CdnPeeringPrefixListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.CdnPeeringPrefixListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CdnPeeringPrefixListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + 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("CdnPeeringPrefixListResult", 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(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': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/cdnPeeringPrefixes'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_connection_monitor_tests_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_connection_monitor_tests_operations.py new file mode 100644 index 000000000000..782e7081a4f0 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_connection_monitor_tests_operations.py @@ -0,0 +1,460 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +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 msrest import Serializer + +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( + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "connectionMonitorTestName": _SERIALIZER.url("connection_monitor_test_name", connection_monitor_test_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "connectionMonitorTestName": _SERIALIZER.url("connection_monitor_test_name", connection_monitor_test_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "connectionMonitorTestName": _SERIALIZER.url("connection_monitor_test_name", connection_monitor_test_name, 'str'), + "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') + + # 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_peering_service_request( + resource_group_name: str, + peering_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "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') + + # 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 ConnectionMonitorTestsOperations(object): + """ConnectionMonitorTestsOperations 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.peering.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, + peering_service_name: str, + connection_monitor_test_name: str, + **kwargs: Any + ) -> "_models.ConnectionMonitorTest": + """Gets an existing connection monitor test with the specified name under the given subscription, + resource group and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param connection_monitor_test_name: The name of the connection monitor test. + :type connection_monitor_test_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectionMonitorTest, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.ConnectionMonitorTest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionMonitorTest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + connection_monitor_test_name=connection_monitor_test_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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('ConnectionMonitorTest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + connection_monitor_test: "_models.ConnectionMonitorTest", + **kwargs: Any + ) -> "_models.ConnectionMonitorTest": + """Creates or updates a connection monitor test with the specified name under the given + subscription, resource group and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param connection_monitor_test_name: The name of the connection monitor test. + :type connection_monitor_test_name: str + :param connection_monitor_test: The properties needed to create a connection monitor test. + :type connection_monitor_test: ~azure.mgmt.peering.models.ConnectionMonitorTest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectionMonitorTest, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.ConnectionMonitorTest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionMonitorTest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(connection_monitor_test, 'ConnectionMonitorTest') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + connection_monitor_test_name=connection_monitor_test_name, + subscription_id=self._config.subscription_id, + 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(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('ConnectionMonitorTest', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConnectionMonitorTest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + peering_service_name: str, + connection_monitor_test_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing connection monitor test with the specified name under the given + subscription, resource group and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param connection_monitor_test_name: The name of the connection monitor test. + :type connection_monitor_test_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + connection_monitor_test_name=connection_monitor_test_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}'} # type: ignore + + + @distributed_trace + def list_by_peering_service( + self, + resource_group_name: str, + peering_service_name: str, + **kwargs: Any + ) -> Iterable["_models.ConnectionMonitorTestListResult"]: + """Lists all connection monitor tests under the given subscription, resource group and peering + service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectionMonitorTestListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.ConnectionMonitorTestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionMonitorTestListResult"] + 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_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_peering_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectionMonitorTestListResult", 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(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_peering_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_legacy_peerings_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_legacy_peerings_operations.py index 2f30feb21622..ee3154e51ae2 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_legacy_peerings_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_legacy_peerings_operations.py @@ -5,23 +5,64 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + peering_location: str, + kind: Union[str, "_models.LegacyPeeringsKind"], + asn: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/legacyPeerings') + 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['peeringLocation'] = _SERIALIZER.query("peering_location", peering_location, 'str') + query_parameters['kind'] = _SERIALIZER.query("kind", kind, 'str') + if asn is not None: + query_parameters['asn'] = _SERIALIZER.query("asn", asn, 'int') + 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 LegacyPeeringsOperations(object): """LegacyPeeringsOperations operations. @@ -45,20 +86,23 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - peering_location, # type: str - kind, # type: Union[str, "_models.Enum1"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringListResult"] + peering_location: str, + kind: Union[str, "_models.LegacyPeeringsKind"], + asn: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.PeeringListResult"]: """Lists all of the legacy peerings under the given subscription matching the specified kind and location. :param peering_location: The location of the peering. :type peering_location: str :param kind: The kind of the peering. - :type kind: str or ~azure.mgmt.peering.models.Enum1 + :type kind: str or ~azure.mgmt.peering.models.LegacyPeeringsKind + :param asn: The ASN number associated with a legacy peering. + :type asn: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PeeringListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringListResult] @@ -69,36 +113,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['peeringLocation'] = self._serialize.query("peering_location", peering_location, 'str') - query_parameters['kind'] = self._serialize.query("kind", kind, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + kind=kind, + asn=asn, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + peering_location=peering_location, + kind=kind, + asn=asn, + 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('PeeringListResult', pipeline_response) + deserialized = self._deserialize("PeeringListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,12 +154,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_looking_glass_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_looking_glass_operations.py new file mode 100644 index 000000000000..2de577c677e0 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_looking_glass_operations.py @@ -0,0 +1,147 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_invoke_request( + subscription_id: str, + *, + command: Union[str, "_models.LookingGlassCommand"], + source_type: Union[str, "_models.LookingGlassSourceType"], + source_location: str, + destination_ip: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/lookingGlass') + 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['command'] = _SERIALIZER.query("command", command, 'str') + query_parameters['sourceType'] = _SERIALIZER.query("source_type", source_type, 'str') + query_parameters['sourceLocation'] = _SERIALIZER.query("source_location", source_location, 'str') + query_parameters['destinationIP'] = _SERIALIZER.query("destination_ip", destination_ip, 'str') + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class LookingGlassOperations(object): + """LookingGlassOperations 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.peering.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 invoke( + self, + command: Union[str, "_models.LookingGlassCommand"], + source_type: Union[str, "_models.LookingGlassSourceType"], + source_location: str, + destination_ip: str, + **kwargs: Any + ) -> "_models.LookingGlassOutput": + """Run looking glass functionality. + + :param command: The command to be executed: ping, traceroute, bgpRoute. + :type command: str or ~azure.mgmt.peering.models.LookingGlassCommand + :param source_type: The type of the source: Edge site or Azure Region. + :type source_type: str or ~azure.mgmt.peering.models.LookingGlassSourceType + :param source_location: The location of the source. + :type source_location: str + :param destination_ip: The IP address of the destination. + :type destination_ip: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LookingGlassOutput, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.LookingGlassOutput + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LookingGlassOutput"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_invoke_request( + subscription_id=self._config.subscription_id, + command=command, + source_type=source_type, + source_location=source_location, + destination_ip=destination_ip, + template_url=self.invoke.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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('LookingGlassOutput', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + invoke.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/lookingGlass'} # type: ignore + diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_operations.py index 8d739364523e..305130a824ac 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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 = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Peering/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. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available API operations for peering resources. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + 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) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peer_asns_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peer_asns_operations.py index 65ab692f263f..e161770dd9ff 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peer_asns_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peer_asns_operations.py @@ -5,23 +5,165 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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( + peer_asn_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}') + path_format_arguments = { + "peerAsnName": _SERIALIZER.url("peer_asn_name", peer_asn_name, 'str'), + "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') + + # 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( + peer_asn_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}') + path_format_arguments = { + "peerAsnName": _SERIALIZER.url("peer_asn_name", peer_asn_name, 'str'), + "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') + + # 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( + peer_asn_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}') + path_format_arguments = { + "peerAsnName": _SERIALIZER.url("peer_asn_name", peer_asn_name, 'str'), + "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') + + # 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_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns') + 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') + + # 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 PeerAsnsOperations(object): """PeerAsnsOperations operations. @@ -45,12 +187,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - peer_asn_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PeerAsn" + peer_asn_name: str, + **kwargs: Any + ) -> "_models.PeerAsn": """Gets the peer ASN with the specified name under the given subscription. :param peer_asn_name: The peer ASN name. @@ -65,32 +207,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'peerAsnName': self._serialize.url("peer_asn_name", peer_asn_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + peer_asn_name=peer_asn_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PeerAsn', pipeline_response) @@ -99,15 +231,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}'} # type: ignore + + @distributed_trace def create_or_update( self, - peer_asn_name, # type: str - peer_asn, # type: "_models.PeerAsn" - **kwargs # type: Any - ): - # type: (...) -> "_models.PeerAsn" + peer_asn_name: str, + peer_asn: "_models.PeerAsn", + **kwargs: Any + ) -> "_models.PeerAsn": """Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription. @@ -125,37 +259,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'peerAsnName': self._serialize.url("peer_asn_name", peer_asn_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(peer_asn, 'PeerAsn') + + request = build_create_or_update_request( + peer_asn_name=peer_asn_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peer_asn, 'PeerAsn') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -168,14 +292,16 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}'} # type: ignore + + @distributed_trace def delete( self, - peer_asn_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + peer_asn_name: str, + **kwargs: Any + ) -> None: """Deletes an existing peer ASN with the specified name under the given subscription. :param peer_asn_name: The peer ASN name. @@ -190,32 +316,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'peerAsnName': self._serialize.url("peer_asn_name", peer_asn_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + peer_asn_name=peer_asn_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -223,11 +339,12 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeerAsnListResult"] + **kwargs: Any + ) -> Iterable["_models.PeerAsnListResult"]: """Lists all of the peer ASNs under the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -240,34 +357,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PeerAsnListResult', pipeline_response) + deserialized = self._deserialize("PeerAsnListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,12 +392,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_locations_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_locations_operations.py index 695151180cf7..9030e50d80f1 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_locations_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_locations_operations.py @@ -5,23 +5,62 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + kind: Union[str, "_models.PeeringLocationsKind"], + direct_peering_type: Optional[Union[str, "_models.PeeringLocationsDirectPeeringType"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringLocations') + 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['kind'] = _SERIALIZER.query("kind", kind, 'str') + if direct_peering_type is not None: + query_parameters['directPeeringType'] = _SERIALIZER.query("direct_peering_type", direct_peering_type, 'str') + 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 PeeringLocationsOperations(object): """PeeringLocationsOperations operations. @@ -45,21 +84,22 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - kind, # type: Union[str, "_models.Enum14"] - direct_peering_type=None, # type: Optional[Union[str, "_models.Enum15"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringLocationListResult"] + kind: Union[str, "_models.PeeringLocationsKind"], + direct_peering_type: Optional[Union[str, "_models.PeeringLocationsDirectPeeringType"]] = None, + **kwargs: Any + ) -> Iterable["_models.PeeringLocationListResult"]: """Lists all of the available peering locations for the specified kind of peering. :param kind: The kind of the peering. - :type kind: str or ~azure.mgmt.peering.models.Enum14 + :type kind: str or ~azure.mgmt.peering.models.PeeringLocationsKind :param direct_peering_type: The type of direct peering. - :type direct_peering_type: str or ~azure.mgmt.peering.models.Enum15 + :type direct_peering_type: str or ~azure.mgmt.peering.models.PeeringLocationsDirectPeeringType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringLocationListResult or the result of cls(response) + :return: An iterator like instance of either PeeringLocationListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringLocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -68,37 +108,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['kind'] = self._serialize.query("kind", kind, 'str') - if direct_peering_type is not None: - query_parameters['directPeeringType'] = self._serialize.query("direct_peering_type", direct_peering_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + kind=kind, + direct_peering_type=direct_peering_type, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + kind=kind, + direct_peering_type=direct_peering_type, + 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('PeeringLocationListResult', pipeline_response) + deserialized = self._deserialize("PeeringLocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,12 +147,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_management_client_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_management_client_operations.py index 2aef6f9bc969..530000cc46e8 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_management_client_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_management_client_operations.py @@ -5,36 +5,80 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_check_service_provider_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/checkServiceProviderAvailability') + 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') + + # 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class PeeringManagementClientOperationsMixin(object): + @distributed_trace def check_service_provider_availability( self, - check_service_provider_availability_input, # type: "_models.CheckServiceProviderAvailabilityInput" - **kwargs # type: Any - ): - # type: (...) -> Union[str, "_models.Enum0"] + check_service_provider_availability_input: "_models.CheckServiceProviderAvailabilityInput", + **kwargs: Any + ) -> Union[str, "_models.Enum0"]: """Checks if the peering service provider is present within 1000 miles of customer's location. :param check_service_provider_availability_input: The CheckServiceProviderAvailabilityInput - indicating customer location and service provider. - :type check_service_provider_availability_input: ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput + indicating customer location and service provider. + :type check_service_provider_availability_input: + ~azure.mgmt.peering.models.CheckServiceProviderAvailabilityInput :keyword callable cls: A custom type or function that will be passed the direct response :return: Enum0, or the result of cls(response) :rtype: str or ~azure.mgmt.peering.models.Enum0 @@ -45,36 +89,26 @@ def check_service_provider_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_service_provider_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(check_service_provider_availability_input, 'CheckServiceProviderAvailabilityInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_service_provider_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_service_provider_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_service_provider_availability_input, 'CheckServiceProviderAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('str', pipeline_response) @@ -83,4 +117,6 @@ def check_service_provider_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_service_provider_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/CheckServiceProviderAvailability'} # type: ignore + + check_service_provider_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/checkServiceProviderAvailability'} # type: ignore + diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_countries_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_countries_operations.py new file mode 100644 index 000000000000..53e9ba8d2d71 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_countries_operations.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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 msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceCountries') + 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') + + # 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 PeeringServiceCountriesOperations(object): + """PeeringServiceCountriesOperations 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.peering.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.PeeringServiceCountryListResult"]: + """Lists all of the available countries for peering service. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringServiceCountryListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceCountryListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceCountryListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PeeringServiceCountryListResult", 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(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': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceCountries'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_locations_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_locations_operations.py index 0675861a8f49..67df5f8467e7 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_locations_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_locations_operations.py @@ -5,23 +5,60 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + country: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceLocations') + 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] + if country is not None: + query_parameters['country'] = _SERIALIZER.query("country", country, 'str') + 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 PeeringServiceLocationsOperations(object): """PeeringServiceLocationsOperations operations. @@ -45,16 +82,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringServiceLocationListResult"] - """Lists all of the available peering service locations for the specified kind of peering. + country: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PeeringServiceLocationListResult"]: + """Lists all of the available locations for peering service. + :param country: The country of interest, in which the locations are to be present. + :type country: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceLocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceLocationListResult] + :return: An iterator like instance of either PeeringServiceLocationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceLocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceLocationListResult"] @@ -62,34 +104,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + country=country, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + country=country, + 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('PeeringServiceLocationListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceLocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +141,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_prefixes_operations.py deleted file mode 100644 index 32253e9072c0..000000000000 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_prefixes_operations.py +++ /dev/null @@ -1,246 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class PeeringServicePrefixesOperations(object): - """PeeringServicePrefixesOperations 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.peering.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - resource_group_name, # type: str - peering_service_name, # type: str - prefix_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PeeringServicePrefix" - """Gets the peering service prefix. - - :param resource_group_name: The resource group name. - :type resource_group_name: str - :param peering_service_name: The peering service name. - :type peering_service_name: str - :param prefix_name: The prefix name. - :type prefix_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PeeringServicePrefix, or the result of cls(response) - :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'prefixName': self._serialize.url("prefix_name", prefix_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - peering_service_name, # type: str - prefix_name, # type: str - peering_service_prefix, # type: "_models.PeeringServicePrefix" - **kwargs # type: Any - ): - # type: (...) -> "_models.PeeringServicePrefix" - """Creates or updates the peering prefix. - - :param resource_group_name: The resource group name. - :type resource_group_name: str - :param peering_service_name: The peering service name. - :type peering_service_name: str - :param prefix_name: The prefix name. - :type prefix_name: str - :param peering_service_prefix: The IP prefix for an peering. - :type peering_service_prefix: ~azure.mgmt.peering.models.PeeringServicePrefix - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PeeringServicePrefix, or the result of cls(response) - :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'prefixName': self._serialize.url("prefix_name", prefix_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peering_service_prefix, 'PeeringServicePrefix') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - peering_service_name, # type: str - prefix_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """removes the peering prefix. - - :param resource_group_name: The resource group name. - :type resource_group_name: str - :param peering_service_name: The peering service name. - :type peering_service_name: str - :param prefix_name: The prefix name. - :type prefix_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 = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'prefixName': self._serialize.url("prefix_name", prefix_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_providers_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_providers_operations.py index b8a112a01d7c..7bc536040b9c 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_providers_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_service_providers_operations.py @@ -5,23 +5,56 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceProviders') + 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') + + # 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 PeeringServiceProvidersOperations(object): """PeeringServiceProvidersOperations operations. @@ -45,16 +78,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringServiceProviderListResult"] + **kwargs: Any + ) -> Iterable["_models.PeeringServiceProviderListResult"]: """Lists all of the available peering service locations for the specified kind of peering. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceProviderListResult] + :return: An iterator like instance of either PeeringServiceProviderListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServiceProviderListResult"] @@ -62,34 +97,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringServiceProviderListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +132,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_services_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_services_operations.py index e7b671195eec..11d1cc41414a 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_services_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peering_services_operations.py @@ -5,23 +5,279 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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( + resource_group_name: str, + peering_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_service_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_service_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "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') + + # 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( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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') + + # 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, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServices') + 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') + + # 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_initialize_connection_monitor_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/initializeConnectionMonitor') + 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') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PeeringServicesOperations(object): """PeeringServicesOperations operations. @@ -45,13 +301,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - peering_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PeeringService" + resource_group_name: str, + peering_service_name: str, + **kwargs: Any + ) -> "_models.PeeringService": """Gets an existing peering service with the specified name under the given subscription and resource group. @@ -69,33 +325,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PeeringService', pipeline_response) @@ -104,16 +350,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - peering_service_name, # type: str - peering_service, # type: "_models.PeeringService" - **kwargs # type: Any - ): - # type: (...) -> "_models.PeeringService" + resource_group_name: str, + peering_service_name: str, + peering_service: "_models.PeeringService", + **kwargs: Any + ) -> "_models.PeeringService": """Creates a new peering service or updates an existing peering with the specified name under the given subscription and resource group. @@ -133,38 +381,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(peering_service, 'PeeringService') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peering_service, 'PeeringService') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -177,15 +415,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - peering_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + peering_service_name: str, + **kwargs: Any + ) -> None: """Deletes an existing peering service with the specified name under the given subscription and resource group. @@ -203,33 +443,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -237,14 +467,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - peering_service_name, # type: str - tags, # type: "_models.ResourceTags" - **kwargs # type: Any - ): - # type: (...) -> "_models.PeeringService" + resource_group_name: str, + peering_service_name: str, + tags: "_models.ResourceTags", + **kwargs: Any + ) -> "_models.PeeringService": """Updates tags for a peering service with the specified name under the given subscription and resource group. @@ -264,38 +495,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(tags, 'ResourceTags') + + request = build_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(tags, 'ResourceTags') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PeeringService', pipeline_response) @@ -304,20 +525,23 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringServiceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PeeringServiceListResult"]: """Lists all of the peering services under the given subscription and resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceListResult or the result of cls(response) + :return: An iterator like instance of either PeeringServiceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -326,35 +550,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringServiceListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -367,26 +587,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Peering/peeringServices'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringServiceListResult"] + **kwargs: Any + ) -> Iterable["_models.PeeringServiceListResult"]: """Lists all of the peerings under the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServiceListResult or the result of cls(response) + :return: An iterator like instance of either PeeringServiceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -395,34 +617,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringServiceListResult', pipeline_response) + deserialized = self._deserialize("PeeringServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -435,13 +652,54 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Peering/peeringServices'} # type: ignore + + @distributed_trace + def initialize_connection_monitor( + self, + **kwargs: Any + ) -> None: + """Initialize Peering Service for Connection Monitor functionality. + + :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', {})) + + + request = build_initialize_connection_monitor_request( + subscription_id=self._config.subscription_id, + template_url=self.initialize_connection_monitor.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + if cls: + return cls(pipeline_response, None, {}) + + initialize_connection_monitor.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/initializeConnectionMonitor'} # type: ignore + diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peerings_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peerings_operations.py index 77ffd87bed49..8c4e51677efb 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peerings_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_peerings_operations.py @@ -5,23 +5,248 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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( + resource_group_name: str, + peering_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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') + + # 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( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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') + + # 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, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerings') + 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') + + # 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 PeeringsOperations(object): """PeeringsOperations operations. @@ -45,13 +270,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - peering_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Peering" + resource_group_name: str, + peering_name: str, + **kwargs: Any + ) -> "_models.Peering": """Gets an existing peering with the specified name under the given subscription and resource group. @@ -69,33 +294,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Peering', pipeline_response) @@ -104,16 +319,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - peering_name, # type: str - peering, # type: "_models.Peering" - **kwargs # type: Any - ): - # type: (...) -> "_models.Peering" + resource_group_name: str, + peering_name: str, + peering: "_models.Peering", + **kwargs: Any + ) -> "_models.Peering": """Creates a new peering or updates an existing peering with the specified name under the given subscription and resource group. @@ -133,38 +350,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(peering, 'Peering') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(peering, 'Peering') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -177,15 +384,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - peering_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + peering_name: str, + **kwargs: Any + ) -> None: """Deletes an existing peering with the specified name under the given subscription and resource group. @@ -203,33 +412,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -237,14 +436,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - peering_name, # type: str - tags, # type: "_models.ResourceTags" - **kwargs # type: Any - ): - # type: (...) -> "_models.Peering" + resource_group_name: str, + peering_name: str, + tags: "_models.ResourceTags", + **kwargs: Any + ) -> "_models.Peering": """Updates tags for a peering with the specified name under the given subscription and resource group. @@ -264,38 +464,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringName': self._serialize.url("peering_name", peering_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(tags, 'ResourceTags') + + request = build_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(tags, 'ResourceTags') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Peering', pipeline_response) @@ -304,14 +494,16 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PeeringListResult"]: """Lists all of the peerings under the given subscription and resource group. :param resource_group_name: The name of the resource group. @@ -326,35 +518,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringListResult', pipeline_response) + deserialized = self._deserialize("PeeringListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -367,22 +555,23 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Peering/peerings'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringListResult"] + **kwargs: Any + ) -> Iterable["_models.PeeringListResult"]: """Lists all of the peerings under the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -395,34 +584,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PeeringListResult', pipeline_response) + deserialized = self._deserialize("PeeringListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -435,12 +619,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_prefixes_operations.py index 7979359a3cae..2e3bae3f5a14 100644 --- a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_prefixes_operations.py +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_prefixes_operations.py @@ -5,23 +5,189 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 HttpRequest, HttpResponse +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 msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "prefixName": _SERIALIZER.url("prefix_name", prefix_name, 'str'), + "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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "prefixName": _SERIALIZER.url("prefix_name", prefix_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "prefixName": _SERIALIZER.url("prefix_name", prefix_name, 'str'), + "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') + + # 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_peering_service_request( + resource_group_name: str, + peering_service_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringServiceName": _SERIALIZER.url("peering_service_name", peering_service_name, 'str'), + "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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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 PrefixesOperations(object): """PrefixesOperations operations. @@ -45,21 +211,208 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace + def get( + self, + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.PeeringServicePrefix": + """Gets an existing prefix with the specified name under the given subscription, resource group + and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param prefix_name: The name of the prefix. + :type prefix_name: str + :param expand: The properties to be expanded. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringServicePrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + prefix_name=prefix_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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('PeeringServicePrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + peering_service_prefix: "_models.PeeringServicePrefix", + **kwargs: Any + ) -> "_models.PeeringServicePrefix": + """Creates a new prefix with the specified name under the given subscription, resource group and + peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param prefix_name: The name of the prefix. + :type prefix_name: str + :param peering_service_prefix: The properties needed to create a prefix. + :type peering_service_prefix: ~azure.mgmt.peering.models.PeeringServicePrefix + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringServicePrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringServicePrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringServicePrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(peering_service_prefix, 'PeeringServicePrefix') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + prefix_name=prefix_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringServicePrefix', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PeeringServicePrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + peering_service_name: str, + prefix_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing prefix with the specified name under the given subscription, resource group + and peering service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_service_name: The name of the peering service. + :type peering_service_name: str + :param prefix_name: The name of the prefix. + :type prefix_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + prefix_name=prefix_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}'} # type: ignore + + + @distributed_trace def list_by_peering_service( self, - resource_group_name, # type: str - peering_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PeeringServicePrefixListResult"] - """Lists the peerings prefix in the resource group. - - :param resource_group_name: The resource group name. + resource_group_name: str, + peering_service_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PeeringServicePrefixListResult"]: + """Lists all prefixes under the given subscription, resource group and peering service. + + :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param peering_service_name: The peering service name. + :param peering_service_name: The name of the peering service. :type peering_service_name: str + :param expand: The properties to be expanded. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PeeringServicePrefixListResult or the result of cls(response) + :return: An iterator like instance of either PeeringServicePrefixListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringServicePrefixListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -68,36 +421,35 @@ def list_by_peering_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_peering_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'peeringServiceName': self._serialize.url("peering_service_name", peering_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_peering_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_peering_service_request( + resource_group_name=resource_group_name, + peering_service_name=peering_service_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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('PeeringServicePrefixListResult', pipeline_response) + deserialized = self._deserialize("PeeringServicePrefixListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +462,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_received_routes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_received_routes_operations.py new file mode 100644 index 000000000000..427ffe33df8f --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_received_routes_operations.py @@ -0,0 +1,203 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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 msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_peering_request( + resource_group_name: str, + peering_name: str, + subscription_id: str, + *, + prefix: Optional[str] = None, + as_path: Optional[str] = None, + origin_as_validation_state: Optional[str] = None, + rpki_validation_state: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/receivedRoutes') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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] + if prefix is not None: + query_parameters['prefix'] = _SERIALIZER.query("prefix", prefix, 'str') + if as_path is not None: + query_parameters['asPath'] = _SERIALIZER.query("as_path", as_path, 'str') + if origin_as_validation_state is not None: + query_parameters['originAsValidationState'] = _SERIALIZER.query("origin_as_validation_state", origin_as_validation_state, 'str') + if rpki_validation_state is not None: + query_parameters['rpkiValidationState'] = _SERIALIZER.query("rpki_validation_state", rpki_validation_state, 'str') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + 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 ReceivedRoutesOperations(object): + """ReceivedRoutesOperations 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.peering.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_peering( + self, + resource_group_name: str, + peering_name: str, + prefix: Optional[str] = None, + as_path: Optional[str] = None, + origin_as_validation_state: Optional[str] = None, + rpki_validation_state: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PeeringReceivedRouteListResult"]: + """Lists the prefixes received over the specified peering under the given subscription and + resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param prefix: The optional prefix that can be used to filter the routes. + :type prefix: str + :param as_path: The optional AS path that can be used to filter the routes. + :type as_path: str + :param origin_as_validation_state: The optional origin AS validation state that can be used to + filter the routes. + :type origin_as_validation_state: str + :param rpki_validation_state: The optional RPKI validation state that can be used to filter the + routes. + :type rpki_validation_state: str + :param skip_token: The optional page continuation token that is used in the event of paginated + result. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringReceivedRouteListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringReceivedRouteListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringReceivedRouteListResult"] + 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_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + prefix=prefix, + as_path=as_path, + origin_as_validation_state=origin_as_validation_state, + rpki_validation_state=rpki_validation_state, + skip_token=skip_token, + template_url=self.list_by_peering.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + prefix=prefix, + as_path=as_path, + origin_as_validation_state=origin_as_validation_state, + rpki_validation_state=rpki_validation_state, + skip_token=skip_token, + 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("PeeringReceivedRouteListResult", 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(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_peering.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/receivedRoutes'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_asns_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_asns_operations.py new file mode 100644 index 000000000000..c91740618ddd --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_asns_operations.py @@ -0,0 +1,458 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +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 msrest import Serializer + +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( + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "registeredAsnName": _SERIALIZER.url("registered_asn_name", registered_asn_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "registeredAsnName": _SERIALIZER.url("registered_asn_name", registered_asn_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "registeredAsnName": _SERIALIZER.url("registered_asn_name", registered_asn_name, 'str'), + "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') + + # 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_peering_request( + resource_group_name: str, + peering_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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') + + # 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 RegisteredAsnsOperations(object): + """RegisteredAsnsOperations 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.peering.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, + peering_name: str, + registered_asn_name: str, + **kwargs: Any + ) -> "_models.PeeringRegisteredAsn": + """Gets an existing registered ASN with the specified name under the given subscription, resource + group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_asn_name: The name of the registered ASN. + :type registered_asn_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredAsn, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredAsn + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredAsn"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_asn_name=registered_asn_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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('PeeringRegisteredAsn', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + registered_asn: "_models.PeeringRegisteredAsn", + **kwargs: Any + ) -> "_models.PeeringRegisteredAsn": + """Creates a new registered ASN with the specified name under the given subscription, resource + group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_asn_name: The name of the ASN. + :type registered_asn_name: str + :param registered_asn: The properties needed to create a registered ASN. + :type registered_asn: ~azure.mgmt.peering.models.PeeringRegisteredAsn + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredAsn, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredAsn + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredAsn"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(registered_asn, 'PeeringRegisteredAsn') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_asn_name=registered_asn_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringRegisteredAsn', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PeeringRegisteredAsn', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + peering_name: str, + registered_asn_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing registered ASN with the specified name under the given subscription, + resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_asn_name: The name of the registered ASN. + :type registered_asn_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_asn_name=registered_asn_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}'} # type: ignore + + + @distributed_trace + def list_by_peering( + self, + resource_group_name: str, + peering_name: str, + **kwargs: Any + ) -> Iterable["_models.PeeringRegisteredAsnListResult"]: + """Lists all registered ASNs under the given subscription, resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringRegisteredAsnListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringRegisteredAsnListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredAsnListResult"] + 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_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_peering.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PeeringRegisteredAsnListResult", 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(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_peering.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns'} # type: ignore diff --git a/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_prefixes_operations.py b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_prefixes_operations.py new file mode 100644 index 000000000000..f8eb637ae504 --- /dev/null +++ b/sdk/peering/azure-mgmt-peering/azure/mgmt/peering/operations/_registered_prefixes_operations.py @@ -0,0 +1,459 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +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 msrest import Serializer + +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( + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "registeredPrefixName": _SERIALIZER.url("registered_prefix_name", registered_prefix_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "registeredPrefixName": _SERIALIZER.url("registered_prefix_name", registered_prefix_name, 'str'), + "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') + + # 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( + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "registeredPrefixName": _SERIALIZER.url("registered_prefix_name", registered_prefix_name, 'str'), + "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') + + # 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_peering_request( + resource_group_name: str, + peering_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "peeringName": _SERIALIZER.url("peering_name", peering_name, 'str'), + "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') + + # 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 RegisteredPrefixesOperations(object): + """RegisteredPrefixesOperations 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.peering.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, + peering_name: str, + registered_prefix_name: str, + **kwargs: Any + ) -> "_models.PeeringRegisteredPrefix": + """Gets an existing registered prefix with the specified name under the given subscription, + resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_prefix_name: The name of the registered prefix. + :type registered_prefix_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredPrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredPrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredPrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_prefix_name=registered_prefix_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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('PeeringRegisteredPrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + registered_prefix: "_models.PeeringRegisteredPrefix", + **kwargs: Any + ) -> "_models.PeeringRegisteredPrefix": + """Creates a new registered prefix with the specified name under the given subscription, resource + group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_prefix_name: The name of the registered prefix. + :type registered_prefix_name: str + :param registered_prefix: The properties needed to create a registered prefix. + :type registered_prefix: ~azure.mgmt.peering.models.PeeringRegisteredPrefix + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PeeringRegisteredPrefix, or the result of cls(response) + :rtype: ~azure.mgmt.peering.models.PeeringRegisteredPrefix + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredPrefix"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(registered_prefix, 'PeeringRegisteredPrefix') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_prefix_name=registered_prefix_name, + subscription_id=self._config.subscription_id, + 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(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('PeeringRegisteredPrefix', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PeeringRegisteredPrefix', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + peering_name: str, + registered_prefix_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing registered prefix with the specified name under the given subscription, + resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :param registered_prefix_name: The name of the registered prefix. + :type registered_prefix_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', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + registered_prefix_name=registered_prefix_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}'} # type: ignore + + + @distributed_trace + def list_by_peering( + self, + resource_group_name: str, + peering_name: str, + **kwargs: Any + ) -> Iterable["_models.PeeringRegisteredPrefixListResult"]: + """Lists all registered prefixes under the given subscription, resource group and peering. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param peering_name: The name of the peering. + :type peering_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PeeringRegisteredPrefixListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.peering.models.PeeringRegisteredPrefixListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PeeringRegisteredPrefixListResult"] + 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_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_peering.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_peering_request( + resource_group_name=resource_group_name, + peering_name=peering_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PeeringRegisteredPrefixListResult", 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(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_peering.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes'} # type: ignore