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