1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for license information. 5# Code generated by Microsoft (R) AutoRest Code Generator. 6# Changes may cause incorrect behavior and will be lost if the code is regenerated. 7# -------------------------------------------------------------------------- 8from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union 9import warnings 10 11from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 12from azure.core.pipeline import PipelineResponse 13from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest 14from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod 15from azure.mgmt.core.exceptions import ARMErrorFormat 16from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling 17 18from ... import models as _models 19 20T = TypeVar('T') 21ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] 22 23class VpnServerConfigurationsAssociatedWithVirtualWanOperations: 24 """VpnServerConfigurationsAssociatedWithVirtualWanOperations async operations. 25 26 You should not instantiate this class directly. Instead, you should create a Client instance that 27 instantiates it for you and attaches it as an attribute. 28 29 :ivar models: Alias to model classes used in this operation group. 30 :type models: ~azure.mgmt.network.v2020_03_01.models 31 :param client: Client for service requests. 32 :param config: Configuration of service client. 33 :param serializer: An object model serializer. 34 :param deserializer: An object model deserializer. 35 """ 36 37 models = _models 38 39 def __init__(self, client, config, serializer, deserializer) -> None: 40 self._client = client 41 self._serialize = serializer 42 self._deserialize = deserializer 43 self._config = config 44 45 async def _list_initial( 46 self, 47 resource_group_name: str, 48 virtual_wan_name: str, 49 **kwargs 50 ) -> Optional["_models.VpnServerConfigurationsResponse"]: 51 cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VpnServerConfigurationsResponse"]] 52 error_map = { 53 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 54 } 55 error_map.update(kwargs.pop('error_map', {})) 56 api_version = "2020-03-01" 57 accept = "application/json" 58 59 # Construct URL 60 url = self._list_initial.metadata['url'] # type: ignore 61 path_format_arguments = { 62 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 63 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 64 'virtualWANName': self._serialize.url("virtual_wan_name", virtual_wan_name, 'str'), 65 } 66 url = self._client.format_url(url, **path_format_arguments) 67 68 # Construct parameters 69 query_parameters = {} # type: Dict[str, Any] 70 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 71 72 # Construct headers 73 header_parameters = {} # type: Dict[str, Any] 74 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 75 76 request = self._client.post(url, query_parameters, header_parameters) 77 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 78 response = pipeline_response.http_response 79 80 if response.status_code not in [200, 202]: 81 map_error(status_code=response.status_code, response=response, error_map=error_map) 82 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 83 84 deserialized = None 85 if response.status_code == 200: 86 deserialized = self._deserialize('VpnServerConfigurationsResponse', pipeline_response) 87 88 if cls: 89 return cls(pipeline_response, deserialized, {}) 90 91 return deserialized 92 _list_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/vpnServerConfigurations'} # type: ignore 93 94 async def begin_list( 95 self, 96 resource_group_name: str, 97 virtual_wan_name: str, 98 **kwargs 99 ) -> AsyncLROPoller["_models.VpnServerConfigurationsResponse"]: 100 """Gives the list of VpnServerConfigurations associated with Virtual Wan in a resource group. 101 102 :param resource_group_name: The resource group name. 103 :type resource_group_name: str 104 :param virtual_wan_name: The name of the VirtualWAN whose associated VpnServerConfigurations is 105 needed. 106 :type virtual_wan_name: str 107 :keyword callable cls: A custom type or function that will be passed the direct response 108 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 109 :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, 110 False for no polling, or your own initialized polling object for a personal polling strategy. 111 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 112 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 113 :return: An instance of AsyncLROPoller that returns either VpnServerConfigurationsResponse or the result of cls(response) 114 :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.network.v2020_03_01.models.VpnServerConfigurationsResponse] 115 :raises ~azure.core.exceptions.HttpResponseError: 116 """ 117 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 118 cls = kwargs.pop('cls', None) # type: ClsType["_models.VpnServerConfigurationsResponse"] 119 lro_delay = kwargs.pop( 120 'polling_interval', 121 self._config.polling_interval 122 ) 123 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 124 if cont_token is None: 125 raw_result = await self._list_initial( 126 resource_group_name=resource_group_name, 127 virtual_wan_name=virtual_wan_name, 128 cls=lambda x,y,z: x, 129 **kwargs 130 ) 131 132 kwargs.pop('error_map', None) 133 kwargs.pop('content_type', None) 134 135 def get_long_running_output(pipeline_response): 136 deserialized = self._deserialize('VpnServerConfigurationsResponse', pipeline_response) 137 138 if cls: 139 return cls(pipeline_response, deserialized, {}) 140 return deserialized 141 142 path_format_arguments = { 143 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 144 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 145 'virtualWANName': self._serialize.url("virtual_wan_name", virtual_wan_name, 'str'), 146 } 147 148 if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) 149 elif polling is False: polling_method = AsyncNoPolling() 150 else: polling_method = polling 151 if cont_token: 152 return AsyncLROPoller.from_continuation_token( 153 polling_method=polling_method, 154 continuation_token=cont_token, 155 client=self._client, 156 deserialization_callback=get_long_running_output 157 ) 158 else: 159 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 160 begin_list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/vpnServerConfigurations'} # type: ignore 161