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, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union
9import warnings
10
11from azure.core.async_paging import AsyncItemPaged, AsyncList
12from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
13from azure.core.pipeline import PipelineResponse
14from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
15from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
16from azure.mgmt.core.exceptions import ARMErrorFormat
17from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
18
19from ... import models as _models
20
21T = TypeVar('T')
22ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
23
24class AppServicePlansOperations:
25    """AppServicePlansOperations async operations.
26
27    You should not instantiate this class directly. Instead, you should create a Client instance that
28    instantiates it for you and attaches it as an attribute.
29
30    :ivar models: Alias to model classes used in this operation group.
31    :type models: ~azure.mgmt.web.v2020_06_01.models
32    :param client: Client for service requests.
33    :param config: Configuration of service client.
34    :param serializer: An object model serializer.
35    :param deserializer: An object model deserializer.
36    """
37
38    models = _models
39
40    def __init__(self, client, config, serializer, deserializer) -> None:
41        self._client = client
42        self._serialize = serializer
43        self._deserialize = deserializer
44        self._config = config
45
46    def list(
47        self,
48        detailed: Optional[bool] = None,
49        **kwargs: Any
50    ) -> AsyncIterable["_models.AppServicePlanCollection"]:
51        """Get all App Service plans for a subscription.
52
53        Description for Get all App Service plans for a subscription.
54
55        :param detailed: Specify :code:`<code>true</code>` to return all App Service plan properties.
56         The default is :code:`<code>false</code>`, which returns a subset of the properties.
57          Retrieval of all properties may increase the API latency.
58        :type detailed: bool
59        :keyword callable cls: A custom type or function that will be passed the direct response
60        :return: An iterator like instance of either AppServicePlanCollection or the result of cls(response)
61        :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.web.v2020_06_01.models.AppServicePlanCollection]
62        :raises: ~azure.core.exceptions.HttpResponseError
63        """
64        cls = kwargs.pop('cls', None)  # type: ClsType["_models.AppServicePlanCollection"]
65        error_map = {
66            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
67        }
68        error_map.update(kwargs.pop('error_map', {}))
69        api_version = "2020-06-01"
70        accept = "application/json"
71
72        def prepare_request(next_link=None):
73            # Construct headers
74            header_parameters = {}  # type: Dict[str, Any]
75            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
76
77            if not next_link:
78                # Construct URL
79                url = self.list.metadata['url']  # type: ignore
80                path_format_arguments = {
81                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
82                }
83                url = self._client.format_url(url, **path_format_arguments)
84                # Construct parameters
85                query_parameters = {}  # type: Dict[str, Any]
86                if detailed is not None:
87                    query_parameters['detailed'] = self._serialize.query("detailed", detailed, 'bool')
88                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
89
90                request = self._client.get(url, query_parameters, header_parameters)
91            else:
92                url = next_link
93                query_parameters = {}  # type: Dict[str, Any]
94                request = self._client.get(url, query_parameters, header_parameters)
95            return request
96
97        async def extract_data(pipeline_response):
98            deserialized = self._deserialize('AppServicePlanCollection', pipeline_response)
99            list_of_elem = deserialized.value
100            if cls:
101                list_of_elem = cls(list_of_elem)
102            return deserialized.next_link or None, AsyncList(list_of_elem)
103
104        async def get_next(next_link=None):
105            request = prepare_request(next_link)
106
107            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
108            response = pipeline_response.http_response
109
110            if response.status_code not in [200]:
111                error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
112                map_error(status_code=response.status_code, response=response, error_map=error_map)
113                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
114
115            return pipeline_response
116
117        return AsyncItemPaged(
118            get_next, extract_data
119        )
120    list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Web/serverfarms'}  # type: ignore
121
122    def list_by_resource_group(
123        self,
124        resource_group_name: str,
125        **kwargs: Any
126    ) -> AsyncIterable["_models.AppServicePlanCollection"]:
127        """Get all App Service plans in a resource group.
128
129        Description for Get all App Service plans in a resource group.
130
131        :param resource_group_name: Name of the resource group to which the resource belongs.
132        :type resource_group_name: str
133        :keyword callable cls: A custom type or function that will be passed the direct response
134        :return: An iterator like instance of either AppServicePlanCollection or the result of cls(response)
135        :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.web.v2020_06_01.models.AppServicePlanCollection]
136        :raises: ~azure.core.exceptions.HttpResponseError
137        """
138        cls = kwargs.pop('cls', None)  # type: ClsType["_models.AppServicePlanCollection"]
139        error_map = {
140            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
141        }
142        error_map.update(kwargs.pop('error_map', {}))
143        api_version = "2020-06-01"
144        accept = "application/json"
145
146        def prepare_request(next_link=None):
147            # Construct headers
148            header_parameters = {}  # type: Dict[str, Any]
149            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
150
151            if not next_link:
152                # Construct URL
153                url = self.list_by_resource_group.metadata['url']  # type: ignore
154                path_format_arguments = {
155                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
156                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
157                }
158                url = self._client.format_url(url, **path_format_arguments)
159                # Construct parameters
160                query_parameters = {}  # type: Dict[str, Any]
161                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
162
163                request = self._client.get(url, query_parameters, header_parameters)
164            else:
165                url = next_link
166                query_parameters = {}  # type: Dict[str, Any]
167                request = self._client.get(url, query_parameters, header_parameters)
168            return request
169
170        async def extract_data(pipeline_response):
171            deserialized = self._deserialize('AppServicePlanCollection', pipeline_response)
172            list_of_elem = deserialized.value
173            if cls:
174                list_of_elem = cls(list_of_elem)
175            return deserialized.next_link or None, AsyncList(list_of_elem)
176
177        async def get_next(next_link=None):
178            request = prepare_request(next_link)
179
180            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
181            response = pipeline_response.http_response
182
183            if response.status_code not in [200]:
184                error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
185                map_error(status_code=response.status_code, response=response, error_map=error_map)
186                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
187
188            return pipeline_response
189
190        return AsyncItemPaged(
191            get_next, extract_data
192        )
193    list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms'}  # type: ignore
194
195    async def get(
196        self,
197        resource_group_name: str,
198        name: str,
199        **kwargs: Any
200    ) -> Optional["_models.AppServicePlan"]:
201        """Get an App Service plan.
202
203        Description for Get an App Service plan.
204
205        :param resource_group_name: Name of the resource group to which the resource belongs.
206        :type resource_group_name: str
207        :param name: Name of the App Service plan.
208        :type name: str
209        :keyword callable cls: A custom type or function that will be passed the direct response
210        :return: AppServicePlan, or the result of cls(response)
211        :rtype: ~azure.mgmt.web.v2020_06_01.models.AppServicePlan or None
212        :raises: ~azure.core.exceptions.HttpResponseError
213        """
214        cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.AppServicePlan"]]
215        error_map = {
216            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
217        }
218        error_map.update(kwargs.pop('error_map', {}))
219        api_version = "2020-06-01"
220        accept = "application/json"
221
222        # Construct URL
223        url = self.get.metadata['url']  # type: ignore
224        path_format_arguments = {
225            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
226            'name': self._serialize.url("name", name, 'str'),
227            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
228        }
229        url = self._client.format_url(url, **path_format_arguments)
230
231        # Construct parameters
232        query_parameters = {}  # type: Dict[str, Any]
233        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
234
235        # Construct headers
236        header_parameters = {}  # type: Dict[str, Any]
237        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
238
239        request = self._client.get(url, query_parameters, header_parameters)
240        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
241        response = pipeline_response.http_response
242
243        if response.status_code not in [200, 404]:
244            map_error(status_code=response.status_code, response=response, error_map=error_map)
245            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
246            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
247
248        deserialized = None
249        if response.status_code == 200:
250            deserialized = self._deserialize('AppServicePlan', pipeline_response)
251
252        if cls:
253            return cls(pipeline_response, deserialized, {})
254
255        return deserialized
256    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}'}  # type: ignore
257
258    async def _create_or_update_initial(
259        self,
260        resource_group_name: str,
261        name: str,
262        app_service_plan: "_models.AppServicePlan",
263        **kwargs: Any
264    ) -> "_models.AppServicePlan":
265        cls = kwargs.pop('cls', None)  # type: ClsType["_models.AppServicePlan"]
266        error_map = {
267            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
268        }
269        error_map.update(kwargs.pop('error_map', {}))
270        api_version = "2020-06-01"
271        content_type = kwargs.pop("content_type", "application/json")
272        accept = "application/json"
273
274        # Construct URL
275        url = self._create_or_update_initial.metadata['url']  # type: ignore
276        path_format_arguments = {
277            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
278            'name': self._serialize.url("name", name, 'str'),
279            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
280        }
281        url = self._client.format_url(url, **path_format_arguments)
282
283        # Construct parameters
284        query_parameters = {}  # type: Dict[str, Any]
285        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
286
287        # Construct headers
288        header_parameters = {}  # type: Dict[str, Any]
289        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
290        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
291
292        body_content_kwargs = {}  # type: Dict[str, Any]
293        body_content = self._serialize.body(app_service_plan, 'AppServicePlan')
294        body_content_kwargs['content'] = body_content
295        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
296        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
297        response = pipeline_response.http_response
298
299        if response.status_code not in [200, 202]:
300            map_error(status_code=response.status_code, response=response, error_map=error_map)
301            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
302            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
303
304        if response.status_code == 200:
305            deserialized = self._deserialize('AppServicePlan', pipeline_response)
306
307        if response.status_code == 202:
308            deserialized = self._deserialize('AppServicePlan', pipeline_response)
309
310        if cls:
311            return cls(pipeline_response, deserialized, {})
312
313        return deserialized
314    _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}'}  # type: ignore
315
316    async def begin_create_or_update(
317        self,
318        resource_group_name: str,
319        name: str,
320        app_service_plan: "_models.AppServicePlan",
321        **kwargs: Any
322    ) -> AsyncLROPoller["_models.AppServicePlan"]:
323        """Creates or updates an App Service Plan.
324
325        Description for Creates or updates an App Service Plan.
326
327        :param resource_group_name: Name of the resource group to which the resource belongs.
328        :type resource_group_name: str
329        :param name: Name of the App Service plan.
330        :type name: str
331        :param app_service_plan: Details of the App Service plan.
332        :type app_service_plan: ~azure.mgmt.web.v2020_06_01.models.AppServicePlan
333        :keyword callable cls: A custom type or function that will be passed the direct response
334        :keyword str continuation_token: A continuation token to restart a poller from a saved state.
335        :keyword polling: By default, your polling method will be AsyncARMPolling.
336         Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
337        :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
338        :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
339        :return: An instance of AsyncLROPoller that returns either AppServicePlan or the result of cls(response)
340        :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.web.v2020_06_01.models.AppServicePlan]
341        :raises ~azure.core.exceptions.HttpResponseError:
342        """
343        polling = kwargs.pop('polling', True)  # type: Union[bool, AsyncPollingMethod]
344        cls = kwargs.pop('cls', None)  # type: ClsType["_models.AppServicePlan"]
345        lro_delay = kwargs.pop(
346            'polling_interval',
347            self._config.polling_interval
348        )
349        cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
350        if cont_token is None:
351            raw_result = await self._create_or_update_initial(
352                resource_group_name=resource_group_name,
353                name=name,
354                app_service_plan=app_service_plan,
355                cls=lambda x,y,z: x,
356                **kwargs
357            )
358
359        kwargs.pop('error_map', None)
360        kwargs.pop('content_type', None)
361
362        def get_long_running_output(pipeline_response):
363            deserialized = self._deserialize('AppServicePlan', pipeline_response)
364
365            if cls:
366                return cls(pipeline_response, deserialized, {})
367            return deserialized
368
369        path_format_arguments = {
370            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
371            'name': self._serialize.url("name", name, 'str'),
372            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
373        }
374
375        if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments,  **kwargs)
376        elif polling is False: polling_method = AsyncNoPolling()
377        else: polling_method = polling
378        if cont_token:
379            return AsyncLROPoller.from_continuation_token(
380                polling_method=polling_method,
381                continuation_token=cont_token,
382                client=self._client,
383                deserialization_callback=get_long_running_output
384            )
385        else:
386            return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
387    begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}'}  # type: ignore
388
389    async def delete(
390        self,
391        resource_group_name: str,
392        name: str,
393        **kwargs: Any
394    ) -> None:
395        """Delete an App Service plan.
396
397        Description for Delete an App Service plan.
398
399        :param resource_group_name: Name of the resource group to which the resource belongs.
400        :type resource_group_name: str
401        :param name: Name of the App Service plan.
402        :type name: str
403        :keyword callable cls: A custom type or function that will be passed the direct response
404        :return: None, or the result of cls(response)
405        :rtype: None
406        :raises: ~azure.core.exceptions.HttpResponseError
407        """
408        cls = kwargs.pop('cls', None)  # type: ClsType[None]
409        error_map = {
410            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
411        }
412        error_map.update(kwargs.pop('error_map', {}))
413        api_version = "2020-06-01"
414        accept = "application/json"
415
416        # Construct URL
417        url = self.delete.metadata['url']  # type: ignore
418        path_format_arguments = {
419            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
420            'name': self._serialize.url("name", name, 'str'),
421            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
422        }
423        url = self._client.format_url(url, **path_format_arguments)
424
425        # Construct parameters
426        query_parameters = {}  # type: Dict[str, Any]
427        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
428
429        # Construct headers
430        header_parameters = {}  # type: Dict[str, Any]
431        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
432
433        request = self._client.delete(url, query_parameters, header_parameters)
434        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
435        response = pipeline_response.http_response
436
437        if response.status_code not in [200, 204]:
438            map_error(status_code=response.status_code, response=response, error_map=error_map)
439            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
440            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
441
442        if cls:
443            return cls(pipeline_response, None, {})
444
445    delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}'}  # type: ignore
446
447    async def update(
448        self,
449        resource_group_name: str,
450        name: str,
451        app_service_plan: "_models.AppServicePlanPatchResource",
452        **kwargs: Any
453    ) -> "_models.AppServicePlan":
454        """Creates or updates an App Service Plan.
455
456        Description for Creates or updates an App Service Plan.
457
458        :param resource_group_name: Name of the resource group to which the resource belongs.
459        :type resource_group_name: str
460        :param name: Name of the App Service plan.
461        :type name: str
462        :param app_service_plan: Details of the App Service plan.
463        :type app_service_plan: ~azure.mgmt.web.v2020_06_01.models.AppServicePlanPatchResource
464        :keyword callable cls: A custom type or function that will be passed the direct response
465        :return: AppServicePlan, or the result of cls(response)
466        :rtype: ~azure.mgmt.web.v2020_06_01.models.AppServicePlan
467        :raises: ~azure.core.exceptions.HttpResponseError
468        """
469        cls = kwargs.pop('cls', None)  # type: ClsType["_models.AppServicePlan"]
470        error_map = {
471            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
472        }
473        error_map.update(kwargs.pop('error_map', {}))
474        api_version = "2020-06-01"
475        content_type = kwargs.pop("content_type", "application/json")
476        accept = "application/json"
477
478        # Construct URL
479        url = self.update.metadata['url']  # type: ignore
480        path_format_arguments = {
481            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
482            'name': self._serialize.url("name", name, 'str'),
483            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
484        }
485        url = self._client.format_url(url, **path_format_arguments)
486
487        # Construct parameters
488        query_parameters = {}  # type: Dict[str, Any]
489        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
490
491        # Construct headers
492        header_parameters = {}  # type: Dict[str, Any]
493        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
494        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
495
496        body_content_kwargs = {}  # type: Dict[str, Any]
497        body_content = self._serialize.body(app_service_plan, 'AppServicePlanPatchResource')
498        body_content_kwargs['content'] = body_content
499        request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
500        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
501        response = pipeline_response.http_response
502
503        if response.status_code not in [200, 202]:
504            map_error(status_code=response.status_code, response=response, error_map=error_map)
505            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
506            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
507
508        if response.status_code == 200:
509            deserialized = self._deserialize('AppServicePlan', pipeline_response)
510
511        if response.status_code == 202:
512            deserialized = self._deserialize('AppServicePlan', pipeline_response)
513
514        if cls:
515            return cls(pipeline_response, deserialized, {})
516
517        return deserialized
518    update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}'}  # type: ignore
519
520    async def list_capabilities(
521        self,
522        resource_group_name: str,
523        name: str,
524        **kwargs: Any
525    ) -> List["_models.Capability"]:
526        """List all capabilities of an App Service plan.
527
528        Description for List all capabilities of an App Service plan.
529
530        :param resource_group_name: Name of the resource group to which the resource belongs.
531        :type resource_group_name: str
532        :param name: Name of the App Service plan.
533        :type name: str
534        :keyword callable cls: A custom type or function that will be passed the direct response
535        :return: list of Capability, or the result of cls(response)
536        :rtype: list[~azure.mgmt.web.v2020_06_01.models.Capability]
537        :raises: ~azure.core.exceptions.HttpResponseError
538        """
539        cls = kwargs.pop('cls', None)  # type: ClsType[List["_models.Capability"]]
540        error_map = {
541            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
542        }
543        error_map.update(kwargs.pop('error_map', {}))
544        api_version = "2020-06-01"
545        accept = "application/json"
546
547        # Construct URL
548        url = self.list_capabilities.metadata['url']  # type: ignore
549        path_format_arguments = {
550            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
551            'name': self._serialize.url("name", name, 'str'),
552            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
553        }
554        url = self._client.format_url(url, **path_format_arguments)
555
556        # Construct parameters
557        query_parameters = {}  # type: Dict[str, Any]
558        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
559
560        # Construct headers
561        header_parameters = {}  # type: Dict[str, Any]
562        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
563
564        request = self._client.get(url, query_parameters, header_parameters)
565        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
566        response = pipeline_response.http_response
567
568        if response.status_code not in [200]:
569            map_error(status_code=response.status_code, response=response, error_map=error_map)
570            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
571            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
572
573        deserialized = self._deserialize('[Capability]', pipeline_response)
574
575        if cls:
576            return cls(pipeline_response, deserialized, {})
577
578        return deserialized
579    list_capabilities.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/capabilities'}  # type: ignore
580
581    async def get_hybrid_connection(
582        self,
583        resource_group_name: str,
584        name: str,
585        namespace_name: str,
586        relay_name: str,
587        **kwargs: Any
588    ) -> "_models.HybridConnection":
589        """Retrieve a Hybrid Connection in use in an App Service plan.
590
591        Description for Retrieve a Hybrid Connection in use in an App Service plan.
592
593        :param resource_group_name: Name of the resource group to which the resource belongs.
594        :type resource_group_name: str
595        :param name: Name of the App Service plan.
596        :type name: str
597        :param namespace_name: Name of the Service Bus namespace.
598        :type namespace_name: str
599        :param relay_name: Name of the Service Bus relay.
600        :type relay_name: str
601        :keyword callable cls: A custom type or function that will be passed the direct response
602        :return: HybridConnection, or the result of cls(response)
603        :rtype: ~azure.mgmt.web.v2020_06_01.models.HybridConnection
604        :raises: ~azure.core.exceptions.HttpResponseError
605        """
606        cls = kwargs.pop('cls', None)  # type: ClsType["_models.HybridConnection"]
607        error_map = {
608            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
609        }
610        error_map.update(kwargs.pop('error_map', {}))
611        api_version = "2020-06-01"
612        accept = "application/json"
613
614        # Construct URL
615        url = self.get_hybrid_connection.metadata['url']  # type: ignore
616        path_format_arguments = {
617            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
618            'name': self._serialize.url("name", name, 'str'),
619            'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'),
620            'relayName': self._serialize.url("relay_name", relay_name, 'str'),
621            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
622        }
623        url = self._client.format_url(url, **path_format_arguments)
624
625        # Construct parameters
626        query_parameters = {}  # type: Dict[str, Any]
627        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
628
629        # Construct headers
630        header_parameters = {}  # type: Dict[str, Any]
631        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
632
633        request = self._client.get(url, query_parameters, header_parameters)
634        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
635        response = pipeline_response.http_response
636
637        if response.status_code not in [200]:
638            map_error(status_code=response.status_code, response=response, error_map=error_map)
639            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
640            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
641
642        deserialized = self._deserialize('HybridConnection', pipeline_response)
643
644        if cls:
645            return cls(pipeline_response, deserialized, {})
646
647        return deserialized
648    get_hybrid_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}'}  # type: ignore
649
650    async def delete_hybrid_connection(
651        self,
652        resource_group_name: str,
653        name: str,
654        namespace_name: str,
655        relay_name: str,
656        **kwargs: Any
657    ) -> None:
658        """Delete a Hybrid Connection in use in an App Service plan.
659
660        Description for Delete a Hybrid Connection in use in an App Service plan.
661
662        :param resource_group_name: Name of the resource group to which the resource belongs.
663        :type resource_group_name: str
664        :param name: Name of the App Service plan.
665        :type name: str
666        :param namespace_name: Name of the Service Bus namespace.
667        :type namespace_name: str
668        :param relay_name: Name of the Service Bus relay.
669        :type relay_name: str
670        :keyword callable cls: A custom type or function that will be passed the direct response
671        :return: None, or the result of cls(response)
672        :rtype: None
673        :raises: ~azure.core.exceptions.HttpResponseError
674        """
675        cls = kwargs.pop('cls', None)  # type: ClsType[None]
676        error_map = {
677            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
678        }
679        error_map.update(kwargs.pop('error_map', {}))
680        api_version = "2020-06-01"
681        accept = "application/json"
682
683        # Construct URL
684        url = self.delete_hybrid_connection.metadata['url']  # type: ignore
685        path_format_arguments = {
686            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
687            'name': self._serialize.url("name", name, 'str'),
688            'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'),
689            'relayName': self._serialize.url("relay_name", relay_name, 'str'),
690            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
691        }
692        url = self._client.format_url(url, **path_format_arguments)
693
694        # Construct parameters
695        query_parameters = {}  # type: Dict[str, Any]
696        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
697
698        # Construct headers
699        header_parameters = {}  # type: Dict[str, Any]
700        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
701
702        request = self._client.delete(url, query_parameters, header_parameters)
703        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
704        response = pipeline_response.http_response
705
706        if response.status_code not in [200, 204]:
707            map_error(status_code=response.status_code, response=response, error_map=error_map)
708            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
709            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
710
711        if cls:
712            return cls(pipeline_response, None, {})
713
714    delete_hybrid_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}'}  # type: ignore
715
716    async def list_hybrid_connection_keys(
717        self,
718        resource_group_name: str,
719        name: str,
720        namespace_name: str,
721        relay_name: str,
722        **kwargs: Any
723    ) -> "_models.HybridConnectionKey":
724        """Get the send key name and value of a Hybrid Connection.
725
726        Description for Get the send key name and value of a Hybrid Connection.
727
728        :param resource_group_name: Name of the resource group to which the resource belongs.
729        :type resource_group_name: str
730        :param name: Name of the App Service plan.
731        :type name: str
732        :param namespace_name: The name of the Service Bus namespace.
733        :type namespace_name: str
734        :param relay_name: The name of the Service Bus relay.
735        :type relay_name: str
736        :keyword callable cls: A custom type or function that will be passed the direct response
737        :return: HybridConnectionKey, or the result of cls(response)
738        :rtype: ~azure.mgmt.web.v2020_06_01.models.HybridConnectionKey
739        :raises: ~azure.core.exceptions.HttpResponseError
740        """
741        cls = kwargs.pop('cls', None)  # type: ClsType["_models.HybridConnectionKey"]
742        error_map = {
743            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
744        }
745        error_map.update(kwargs.pop('error_map', {}))
746        api_version = "2020-06-01"
747        accept = "application/json"
748
749        # Construct URL
750        url = self.list_hybrid_connection_keys.metadata['url']  # type: ignore
751        path_format_arguments = {
752            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
753            'name': self._serialize.url("name", name, 'str'),
754            'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'),
755            'relayName': self._serialize.url("relay_name", relay_name, 'str'),
756            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
757        }
758        url = self._client.format_url(url, **path_format_arguments)
759
760        # Construct parameters
761        query_parameters = {}  # type: Dict[str, Any]
762        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
763
764        # Construct headers
765        header_parameters = {}  # type: Dict[str, Any]
766        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
767
768        request = self._client.post(url, query_parameters, header_parameters)
769        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
770        response = pipeline_response.http_response
771
772        if response.status_code not in [200]:
773            map_error(status_code=response.status_code, response=response, error_map=error_map)
774            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
775            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
776
777        deserialized = self._deserialize('HybridConnectionKey', pipeline_response)
778
779        if cls:
780            return cls(pipeline_response, deserialized, {})
781
782        return deserialized
783    list_hybrid_connection_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}/listKeys'}  # type: ignore
784
785    def list_web_apps_by_hybrid_connection(
786        self,
787        resource_group_name: str,
788        name: str,
789        namespace_name: str,
790        relay_name: str,
791        **kwargs: Any
792    ) -> AsyncIterable["_models.ResourceCollection"]:
793        """Get all apps that use a Hybrid Connection in an App Service Plan.
794
795        Description for Get all apps that use a Hybrid Connection in an App Service Plan.
796
797        :param resource_group_name: Name of the resource group to which the resource belongs.
798        :type resource_group_name: str
799        :param name: Name of the App Service plan.
800        :type name: str
801        :param namespace_name: Name of the Hybrid Connection namespace.
802        :type namespace_name: str
803        :param relay_name: Name of the Hybrid Connection relay.
804        :type relay_name: str
805        :keyword callable cls: A custom type or function that will be passed the direct response
806        :return: An iterator like instance of either ResourceCollection or the result of cls(response)
807        :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.web.v2020_06_01.models.ResourceCollection]
808        :raises: ~azure.core.exceptions.HttpResponseError
809        """
810        cls = kwargs.pop('cls', None)  # type: ClsType["_models.ResourceCollection"]
811        error_map = {
812            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
813        }
814        error_map.update(kwargs.pop('error_map', {}))
815        api_version = "2020-06-01"
816        accept = "application/json"
817
818        def prepare_request(next_link=None):
819            # Construct headers
820            header_parameters = {}  # type: Dict[str, Any]
821            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
822
823            if not next_link:
824                # Construct URL
825                url = self.list_web_apps_by_hybrid_connection.metadata['url']  # type: ignore
826                path_format_arguments = {
827                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
828                    'name': self._serialize.url("name", name, 'str'),
829                    'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'),
830                    'relayName': self._serialize.url("relay_name", relay_name, 'str'),
831                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
832                }
833                url = self._client.format_url(url, **path_format_arguments)
834                # Construct parameters
835                query_parameters = {}  # type: Dict[str, Any]
836                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
837
838                request = self._client.get(url, query_parameters, header_parameters)
839            else:
840                url = next_link
841                query_parameters = {}  # type: Dict[str, Any]
842                request = self._client.get(url, query_parameters, header_parameters)
843            return request
844
845        async def extract_data(pipeline_response):
846            deserialized = self._deserialize('ResourceCollection', pipeline_response)
847            list_of_elem = deserialized.value
848            if cls:
849                list_of_elem = cls(list_of_elem)
850            return deserialized.next_link or None, AsyncList(list_of_elem)
851
852        async def get_next(next_link=None):
853            request = prepare_request(next_link)
854
855            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
856            response = pipeline_response.http_response
857
858            if response.status_code not in [200]:
859                error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
860                map_error(status_code=response.status_code, response=response, error_map=error_map)
861                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
862
863            return pipeline_response
864
865        return AsyncItemPaged(
866            get_next, extract_data
867        )
868    list_web_apps_by_hybrid_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}/sites'}  # type: ignore
869
870    async def get_hybrid_connection_plan_limit(
871        self,
872        resource_group_name: str,
873        name: str,
874        **kwargs: Any
875    ) -> "_models.HybridConnectionLimits":
876        """Get the maximum number of Hybrid Connections allowed in an App Service plan.
877
878        Description for Get the maximum number of Hybrid Connections allowed in an App Service plan.
879
880        :param resource_group_name: Name of the resource group to which the resource belongs.
881        :type resource_group_name: str
882        :param name: Name of the App Service plan.
883        :type name: str
884        :keyword callable cls: A custom type or function that will be passed the direct response
885        :return: HybridConnectionLimits, or the result of cls(response)
886        :rtype: ~azure.mgmt.web.v2020_06_01.models.HybridConnectionLimits
887        :raises: ~azure.core.exceptions.HttpResponseError
888        """
889        cls = kwargs.pop('cls', None)  # type: ClsType["_models.HybridConnectionLimits"]
890        error_map = {
891            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
892        }
893        error_map.update(kwargs.pop('error_map', {}))
894        api_version = "2020-06-01"
895        accept = "application/json"
896
897        # Construct URL
898        url = self.get_hybrid_connection_plan_limit.metadata['url']  # type: ignore
899        path_format_arguments = {
900            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
901            'name': self._serialize.url("name", name, 'str'),
902            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
903        }
904        url = self._client.format_url(url, **path_format_arguments)
905
906        # Construct parameters
907        query_parameters = {}  # type: Dict[str, Any]
908        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
909
910        # Construct headers
911        header_parameters = {}  # type: Dict[str, Any]
912        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
913
914        request = self._client.get(url, query_parameters, header_parameters)
915        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
916        response = pipeline_response.http_response
917
918        if response.status_code not in [200]:
919            map_error(status_code=response.status_code, response=response, error_map=error_map)
920            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
921            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
922
923        deserialized = self._deserialize('HybridConnectionLimits', pipeline_response)
924
925        if cls:
926            return cls(pipeline_response, deserialized, {})
927
928        return deserialized
929    get_hybrid_connection_plan_limit.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionPlanLimits/limit'}  # type: ignore
930
931    def list_hybrid_connections(
932        self,
933        resource_group_name: str,
934        name: str,
935        **kwargs: Any
936    ) -> AsyncIterable["_models.HybridConnectionCollection"]:
937        """Retrieve all Hybrid Connections in use in an App Service plan.
938
939        Description for Retrieve all Hybrid Connections in use in an App Service plan.
940
941        :param resource_group_name: Name of the resource group to which the resource belongs.
942        :type resource_group_name: str
943        :param name: Name of the App Service plan.
944        :type name: str
945        :keyword callable cls: A custom type or function that will be passed the direct response
946        :return: An iterator like instance of either HybridConnectionCollection or the result of cls(response)
947        :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.web.v2020_06_01.models.HybridConnectionCollection]
948        :raises: ~azure.core.exceptions.HttpResponseError
949        """
950        cls = kwargs.pop('cls', None)  # type: ClsType["_models.HybridConnectionCollection"]
951        error_map = {
952            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
953        }
954        error_map.update(kwargs.pop('error_map', {}))
955        api_version = "2020-06-01"
956        accept = "application/json"
957
958        def prepare_request(next_link=None):
959            # Construct headers
960            header_parameters = {}  # type: Dict[str, Any]
961            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
962
963            if not next_link:
964                # Construct URL
965                url = self.list_hybrid_connections.metadata['url']  # type: ignore
966                path_format_arguments = {
967                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
968                    'name': self._serialize.url("name", name, 'str'),
969                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
970                }
971                url = self._client.format_url(url, **path_format_arguments)
972                # Construct parameters
973                query_parameters = {}  # type: Dict[str, Any]
974                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
975
976                request = self._client.get(url, query_parameters, header_parameters)
977            else:
978                url = next_link
979                query_parameters = {}  # type: Dict[str, Any]
980                request = self._client.get(url, query_parameters, header_parameters)
981            return request
982
983        async def extract_data(pipeline_response):
984            deserialized = self._deserialize('HybridConnectionCollection', pipeline_response)
985            list_of_elem = deserialized.value
986            if cls:
987                list_of_elem = cls(list_of_elem)
988            return deserialized.next_link or None, AsyncList(list_of_elem)
989
990        async def get_next(next_link=None):
991            request = prepare_request(next_link)
992
993            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
994            response = pipeline_response.http_response
995
996            if response.status_code not in [200]:
997                error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
998                map_error(status_code=response.status_code, response=response, error_map=error_map)
999                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1000
1001            return pipeline_response
1002
1003        return AsyncItemPaged(
1004            get_next, extract_data
1005        )
1006    list_hybrid_connections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionRelays'}  # type: ignore
1007
1008    async def restart_web_apps(
1009        self,
1010        resource_group_name: str,
1011        name: str,
1012        soft_restart: Optional[bool] = None,
1013        **kwargs: Any
1014    ) -> None:
1015        """Restart all apps in an App Service plan.
1016
1017        Description for Restart all apps in an App Service plan.
1018
1019        :param resource_group_name: Name of the resource group to which the resource belongs.
1020        :type resource_group_name: str
1021        :param name: Name of the App Service plan.
1022        :type name: str
1023        :param soft_restart: Specify :code:`<code>true</code>` to perform a soft restart, applies the
1024         configuration settings and restarts the apps if necessary. The default is
1025         :code:`<code>false</code>`, which always restarts and reprovisions the apps.
1026        :type soft_restart: bool
1027        :keyword callable cls: A custom type or function that will be passed the direct response
1028        :return: None, or the result of cls(response)
1029        :rtype: None
1030        :raises: ~azure.core.exceptions.HttpResponseError
1031        """
1032        cls = kwargs.pop('cls', None)  # type: ClsType[None]
1033        error_map = {
1034            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1035        }
1036        error_map.update(kwargs.pop('error_map', {}))
1037        api_version = "2020-06-01"
1038        accept = "application/json"
1039
1040        # Construct URL
1041        url = self.restart_web_apps.metadata['url']  # type: ignore
1042        path_format_arguments = {
1043            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1044            'name': self._serialize.url("name", name, 'str'),
1045            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1046        }
1047        url = self._client.format_url(url, **path_format_arguments)
1048
1049        # Construct parameters
1050        query_parameters = {}  # type: Dict[str, Any]
1051        if soft_restart is not None:
1052            query_parameters['softRestart'] = self._serialize.query("soft_restart", soft_restart, 'bool')
1053        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1054
1055        # Construct headers
1056        header_parameters = {}  # type: Dict[str, Any]
1057        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1058
1059        request = self._client.post(url, query_parameters, header_parameters)
1060        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1061        response = pipeline_response.http_response
1062
1063        if response.status_code not in [204]:
1064            map_error(status_code=response.status_code, response=response, error_map=error_map)
1065            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1066            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1067
1068        if cls:
1069            return cls(pipeline_response, None, {})
1070
1071    restart_web_apps.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/restartSites'}  # type: ignore
1072
1073    def list_web_apps(
1074        self,
1075        resource_group_name: str,
1076        name: str,
1077        skip_token: Optional[str] = None,
1078        filter: Optional[str] = None,
1079        top: Optional[str] = None,
1080        **kwargs: Any
1081    ) -> AsyncIterable["_models.WebAppCollection"]:
1082        """Get all apps associated with an App Service plan.
1083
1084        Description for Get all apps associated with an App Service plan.
1085
1086        :param resource_group_name: Name of the resource group to which the resource belongs.
1087        :type resource_group_name: str
1088        :param name: Name of the App Service plan.
1089        :type name: str
1090        :param skip_token: Skip to a web app in the list of webapps associated with app service plan.
1091         If specified, the resulting list will contain web apps starting from (including) the skipToken.
1092         Otherwise, the resulting list contains web apps from the start of the list.
1093        :type skip_token: str
1094        :param filter: Supported filter: $filter=state eq running. Returns only web apps that are
1095         currently running.
1096        :type filter: str
1097        :param top: List page size. If specified, results are paged.
1098        :type top: str
1099        :keyword callable cls: A custom type or function that will be passed the direct response
1100        :return: An iterator like instance of either WebAppCollection or the result of cls(response)
1101        :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.web.v2020_06_01.models.WebAppCollection]
1102        :raises: ~azure.core.exceptions.HttpResponseError
1103        """
1104        cls = kwargs.pop('cls', None)  # type: ClsType["_models.WebAppCollection"]
1105        error_map = {
1106            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1107        }
1108        error_map.update(kwargs.pop('error_map', {}))
1109        api_version = "2020-06-01"
1110        accept = "application/json"
1111
1112        def prepare_request(next_link=None):
1113            # Construct headers
1114            header_parameters = {}  # type: Dict[str, Any]
1115            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1116
1117            if not next_link:
1118                # Construct URL
1119                url = self.list_web_apps.metadata['url']  # type: ignore
1120                path_format_arguments = {
1121                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1122                    'name': self._serialize.url("name", name, 'str'),
1123                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1124                }
1125                url = self._client.format_url(url, **path_format_arguments)
1126                # Construct parameters
1127                query_parameters = {}  # type: Dict[str, Any]
1128                if skip_token is not None:
1129                    query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str')
1130                if filter is not None:
1131                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True)
1132                if top is not None:
1133                    query_parameters['$top'] = self._serialize.query("top", top, 'str')
1134                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1135
1136                request = self._client.get(url, query_parameters, header_parameters)
1137            else:
1138                url = next_link
1139                query_parameters = {}  # type: Dict[str, Any]
1140                request = self._client.get(url, query_parameters, header_parameters)
1141            return request
1142
1143        async def extract_data(pipeline_response):
1144            deserialized = self._deserialize('WebAppCollection', pipeline_response)
1145            list_of_elem = deserialized.value
1146            if cls:
1147                list_of_elem = cls(list_of_elem)
1148            return deserialized.next_link or None, AsyncList(list_of_elem)
1149
1150        async def get_next(next_link=None):
1151            request = prepare_request(next_link)
1152
1153            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1154            response = pipeline_response.http_response
1155
1156            if response.status_code not in [200]:
1157                error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1158                map_error(status_code=response.status_code, response=response, error_map=error_map)
1159                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1160
1161            return pipeline_response
1162
1163        return AsyncItemPaged(
1164            get_next, extract_data
1165        )
1166    list_web_apps.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/sites'}  # type: ignore
1167
1168    async def get_server_farm_skus(
1169        self,
1170        resource_group_name: str,
1171        name: str,
1172        **kwargs: Any
1173    ) -> Any:
1174        """Gets all selectable SKUs for a given App Service Plan.
1175
1176        Description for Gets all selectable SKUs for a given App Service Plan.
1177
1178        :param resource_group_name: Name of the resource group to which the resource belongs.
1179        :type resource_group_name: str
1180        :param name: Name of App Service Plan.
1181        :type name: str
1182        :keyword callable cls: A custom type or function that will be passed the direct response
1183        :return: any, or the result of cls(response)
1184        :rtype: any
1185        :raises: ~azure.core.exceptions.HttpResponseError
1186        """
1187        cls = kwargs.pop('cls', None)  # type: ClsType[Any]
1188        error_map = {
1189            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1190        }
1191        error_map.update(kwargs.pop('error_map', {}))
1192        api_version = "2020-06-01"
1193        accept = "application/json"
1194
1195        # Construct URL
1196        url = self.get_server_farm_skus.metadata['url']  # type: ignore
1197        path_format_arguments = {
1198            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1199            'name': self._serialize.url("name", name, 'str'),
1200            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1201        }
1202        url = self._client.format_url(url, **path_format_arguments)
1203
1204        # Construct parameters
1205        query_parameters = {}  # type: Dict[str, Any]
1206        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1207
1208        # Construct headers
1209        header_parameters = {}  # type: Dict[str, Any]
1210        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1211
1212        request = self._client.get(url, query_parameters, header_parameters)
1213        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1214        response = pipeline_response.http_response
1215
1216        if response.status_code not in [200]:
1217            map_error(status_code=response.status_code, response=response, error_map=error_map)
1218            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1219            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1220
1221        deserialized = self._deserialize('object', pipeline_response)
1222
1223        if cls:
1224            return cls(pipeline_response, deserialized, {})
1225
1226        return deserialized
1227    get_server_farm_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/skus'}  # type: ignore
1228
1229    def list_usages(
1230        self,
1231        resource_group_name: str,
1232        name: str,
1233        filter: Optional[str] = None,
1234        **kwargs: Any
1235    ) -> AsyncIterable["_models.CsmUsageQuotaCollection"]:
1236        """Gets server farm usage information.
1237
1238        Description for Gets server farm usage information.
1239
1240        :param resource_group_name: Name of the resource group to which the resource belongs.
1241        :type resource_group_name: str
1242        :param name: Name of App Service Plan.
1243        :type name: str
1244        :param filter: Return only usages/metrics specified in the filter. Filter conforms to odata
1245         syntax. Example: $filter=(name.value eq 'Metric1' or name.value eq 'Metric2').
1246        :type filter: str
1247        :keyword callable cls: A custom type or function that will be passed the direct response
1248        :return: An iterator like instance of either CsmUsageQuotaCollection or the result of cls(response)
1249        :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.web.v2020_06_01.models.CsmUsageQuotaCollection]
1250        :raises: ~azure.core.exceptions.HttpResponseError
1251        """
1252        cls = kwargs.pop('cls', None)  # type: ClsType["_models.CsmUsageQuotaCollection"]
1253        error_map = {
1254            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1255        }
1256        error_map.update(kwargs.pop('error_map', {}))
1257        api_version = "2020-06-01"
1258        accept = "application/json"
1259
1260        def prepare_request(next_link=None):
1261            # Construct headers
1262            header_parameters = {}  # type: Dict[str, Any]
1263            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1264
1265            if not next_link:
1266                # Construct URL
1267                url = self.list_usages.metadata['url']  # type: ignore
1268                path_format_arguments = {
1269                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1270                    'name': self._serialize.url("name", name, 'str'),
1271                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1272                }
1273                url = self._client.format_url(url, **path_format_arguments)
1274                # Construct parameters
1275                query_parameters = {}  # type: Dict[str, Any]
1276                if filter is not None:
1277                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True)
1278                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1279
1280                request = self._client.get(url, query_parameters, header_parameters)
1281            else:
1282                url = next_link
1283                query_parameters = {}  # type: Dict[str, Any]
1284                request = self._client.get(url, query_parameters, header_parameters)
1285            return request
1286
1287        async def extract_data(pipeline_response):
1288            deserialized = self._deserialize('CsmUsageQuotaCollection', pipeline_response)
1289            list_of_elem = deserialized.value
1290            if cls:
1291                list_of_elem = cls(list_of_elem)
1292            return deserialized.next_link or None, AsyncList(list_of_elem)
1293
1294        async def get_next(next_link=None):
1295            request = prepare_request(next_link)
1296
1297            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1298            response = pipeline_response.http_response
1299
1300            if response.status_code not in [200]:
1301                error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1302                map_error(status_code=response.status_code, response=response, error_map=error_map)
1303                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1304
1305            return pipeline_response
1306
1307        return AsyncItemPaged(
1308            get_next, extract_data
1309        )
1310    list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/usages'}  # type: ignore
1311
1312    async def list_vnets(
1313        self,
1314        resource_group_name: str,
1315        name: str,
1316        **kwargs: Any
1317    ) -> List["_models.VnetInfo"]:
1318        """Get all Virtual Networks associated with an App Service plan.
1319
1320        Description for Get all Virtual Networks associated with an App Service plan.
1321
1322        :param resource_group_name: Name of the resource group to which the resource belongs.
1323        :type resource_group_name: str
1324        :param name: Name of the App Service plan.
1325        :type name: str
1326        :keyword callable cls: A custom type or function that will be passed the direct response
1327        :return: list of VnetInfo, or the result of cls(response)
1328        :rtype: list[~azure.mgmt.web.v2020_06_01.models.VnetInfo]
1329        :raises: ~azure.core.exceptions.HttpResponseError
1330        """
1331        cls = kwargs.pop('cls', None)  # type: ClsType[List["_models.VnetInfo"]]
1332        error_map = {
1333            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1334        }
1335        error_map.update(kwargs.pop('error_map', {}))
1336        api_version = "2020-06-01"
1337        accept = "application/json"
1338
1339        # Construct URL
1340        url = self.list_vnets.metadata['url']  # type: ignore
1341        path_format_arguments = {
1342            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1343            'name': self._serialize.url("name", name, 'str'),
1344            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1345        }
1346        url = self._client.format_url(url, **path_format_arguments)
1347
1348        # Construct parameters
1349        query_parameters = {}  # type: Dict[str, Any]
1350        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1351
1352        # Construct headers
1353        header_parameters = {}  # type: Dict[str, Any]
1354        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1355
1356        request = self._client.get(url, query_parameters, header_parameters)
1357        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1358        response = pipeline_response.http_response
1359
1360        if response.status_code not in [200]:
1361            map_error(status_code=response.status_code, response=response, error_map=error_map)
1362            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1363            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1364
1365        deserialized = self._deserialize('[VnetInfo]', pipeline_response)
1366
1367        if cls:
1368            return cls(pipeline_response, deserialized, {})
1369
1370        return deserialized
1371    list_vnets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections'}  # type: ignore
1372
1373    async def get_vnet_from_server_farm(
1374        self,
1375        resource_group_name: str,
1376        name: str,
1377        vnet_name: str,
1378        **kwargs: Any
1379    ) -> Optional["_models.VnetInfo"]:
1380        """Get a Virtual Network associated with an App Service plan.
1381
1382        Description for Get a Virtual Network associated with an App Service plan.
1383
1384        :param resource_group_name: Name of the resource group to which the resource belongs.
1385        :type resource_group_name: str
1386        :param name: Name of the App Service plan.
1387        :type name: str
1388        :param vnet_name: Name of the Virtual Network.
1389        :type vnet_name: str
1390        :keyword callable cls: A custom type or function that will be passed the direct response
1391        :return: VnetInfo, or the result of cls(response)
1392        :rtype: ~azure.mgmt.web.v2020_06_01.models.VnetInfo or None
1393        :raises: ~azure.core.exceptions.HttpResponseError
1394        """
1395        cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.VnetInfo"]]
1396        error_map = {
1397            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1398        }
1399        error_map.update(kwargs.pop('error_map', {}))
1400        api_version = "2020-06-01"
1401        accept = "application/json"
1402
1403        # Construct URL
1404        url = self.get_vnet_from_server_farm.metadata['url']  # type: ignore
1405        path_format_arguments = {
1406            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1407            'name': self._serialize.url("name", name, 'str'),
1408            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1409            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1410        }
1411        url = self._client.format_url(url, **path_format_arguments)
1412
1413        # Construct parameters
1414        query_parameters = {}  # type: Dict[str, Any]
1415        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1416
1417        # Construct headers
1418        header_parameters = {}  # type: Dict[str, Any]
1419        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1420
1421        request = self._client.get(url, query_parameters, header_parameters)
1422        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1423        response = pipeline_response.http_response
1424
1425        if response.status_code not in [200, 404]:
1426            map_error(status_code=response.status_code, response=response, error_map=error_map)
1427            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1428            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1429
1430        deserialized = None
1431        if response.status_code == 200:
1432            deserialized = self._deserialize('VnetInfo', pipeline_response)
1433
1434        if cls:
1435            return cls(pipeline_response, deserialized, {})
1436
1437        return deserialized
1438    get_vnet_from_server_farm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}'}  # type: ignore
1439
1440    async def get_vnet_gateway(
1441        self,
1442        resource_group_name: str,
1443        name: str,
1444        vnet_name: str,
1445        gateway_name: str,
1446        **kwargs: Any
1447    ) -> "_models.VnetGateway":
1448        """Get a Virtual Network gateway.
1449
1450        Description for Get a Virtual Network gateway.
1451
1452        :param resource_group_name: Name of the resource group to which the resource belongs.
1453        :type resource_group_name: str
1454        :param name: Name of the App Service plan.
1455        :type name: str
1456        :param vnet_name: Name of the Virtual Network.
1457        :type vnet_name: str
1458        :param gateway_name: Name of the gateway. Only the 'primary' gateway is supported.
1459        :type gateway_name: str
1460        :keyword callable cls: A custom type or function that will be passed the direct response
1461        :return: VnetGateway, or the result of cls(response)
1462        :rtype: ~azure.mgmt.web.v2020_06_01.models.VnetGateway
1463        :raises: ~azure.core.exceptions.HttpResponseError
1464        """
1465        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VnetGateway"]
1466        error_map = {
1467            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1468        }
1469        error_map.update(kwargs.pop('error_map', {}))
1470        api_version = "2020-06-01"
1471        accept = "application/json"
1472
1473        # Construct URL
1474        url = self.get_vnet_gateway.metadata['url']  # type: ignore
1475        path_format_arguments = {
1476            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1477            'name': self._serialize.url("name", name, 'str'),
1478            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1479            'gatewayName': self._serialize.url("gateway_name", gateway_name, 'str'),
1480            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1481        }
1482        url = self._client.format_url(url, **path_format_arguments)
1483
1484        # Construct parameters
1485        query_parameters = {}  # type: Dict[str, Any]
1486        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1487
1488        # Construct headers
1489        header_parameters = {}  # type: Dict[str, Any]
1490        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1491
1492        request = self._client.get(url, query_parameters, header_parameters)
1493        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1494        response = pipeline_response.http_response
1495
1496        if response.status_code not in [200]:
1497            map_error(status_code=response.status_code, response=response, error_map=error_map)
1498            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1499            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1500
1501        deserialized = self._deserialize('VnetGateway', pipeline_response)
1502
1503        if cls:
1504            return cls(pipeline_response, deserialized, {})
1505
1506        return deserialized
1507    get_vnet_gateway.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}'}  # type: ignore
1508
1509    async def update_vnet_gateway(
1510        self,
1511        resource_group_name: str,
1512        name: str,
1513        vnet_name: str,
1514        gateway_name: str,
1515        connection_envelope: "_models.VnetGateway",
1516        **kwargs: Any
1517    ) -> "_models.VnetGateway":
1518        """Update a Virtual Network gateway.
1519
1520        Description for Update a Virtual Network gateway.
1521
1522        :param resource_group_name: Name of the resource group to which the resource belongs.
1523        :type resource_group_name: str
1524        :param name: Name of the App Service plan.
1525        :type name: str
1526        :param vnet_name: Name of the Virtual Network.
1527        :type vnet_name: str
1528        :param gateway_name: Name of the gateway. Only the 'primary' gateway is supported.
1529        :type gateway_name: str
1530        :param connection_envelope: Definition of the gateway.
1531        :type connection_envelope: ~azure.mgmt.web.v2020_06_01.models.VnetGateway
1532        :keyword callable cls: A custom type or function that will be passed the direct response
1533        :return: VnetGateway, or the result of cls(response)
1534        :rtype: ~azure.mgmt.web.v2020_06_01.models.VnetGateway
1535        :raises: ~azure.core.exceptions.HttpResponseError
1536        """
1537        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VnetGateway"]
1538        error_map = {
1539            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1540        }
1541        error_map.update(kwargs.pop('error_map', {}))
1542        api_version = "2020-06-01"
1543        content_type = kwargs.pop("content_type", "application/json")
1544        accept = "application/json"
1545
1546        # Construct URL
1547        url = self.update_vnet_gateway.metadata['url']  # type: ignore
1548        path_format_arguments = {
1549            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1550            'name': self._serialize.url("name", name, 'str'),
1551            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1552            'gatewayName': self._serialize.url("gateway_name", gateway_name, 'str'),
1553            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1554        }
1555        url = self._client.format_url(url, **path_format_arguments)
1556
1557        # Construct parameters
1558        query_parameters = {}  # type: Dict[str, Any]
1559        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1560
1561        # Construct headers
1562        header_parameters = {}  # type: Dict[str, Any]
1563        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
1564        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1565
1566        body_content_kwargs = {}  # type: Dict[str, Any]
1567        body_content = self._serialize.body(connection_envelope, 'VnetGateway')
1568        body_content_kwargs['content'] = body_content
1569        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
1570        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1571        response = pipeline_response.http_response
1572
1573        if response.status_code not in [200]:
1574            map_error(status_code=response.status_code, response=response, error_map=error_map)
1575            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1576            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1577
1578        deserialized = self._deserialize('VnetGateway', pipeline_response)
1579
1580        if cls:
1581            return cls(pipeline_response, deserialized, {})
1582
1583        return deserialized
1584    update_vnet_gateway.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}'}  # type: ignore
1585
1586    async def list_routes_for_vnet(
1587        self,
1588        resource_group_name: str,
1589        name: str,
1590        vnet_name: str,
1591        **kwargs: Any
1592    ) -> List["_models.VnetRoute"]:
1593        """Get all routes that are associated with a Virtual Network in an App Service plan.
1594
1595        Description for Get all routes that are associated with a Virtual Network in an App Service
1596        plan.
1597
1598        :param resource_group_name: Name of the resource group to which the resource belongs.
1599        :type resource_group_name: str
1600        :param name: Name of the App Service plan.
1601        :type name: str
1602        :param vnet_name: Name of the Virtual Network.
1603        :type vnet_name: str
1604        :keyword callable cls: A custom type or function that will be passed the direct response
1605        :return: list of VnetRoute, or the result of cls(response)
1606        :rtype: list[~azure.mgmt.web.v2020_06_01.models.VnetRoute]
1607        :raises: ~azure.core.exceptions.HttpResponseError
1608        """
1609        cls = kwargs.pop('cls', None)  # type: ClsType[List["_models.VnetRoute"]]
1610        error_map = {
1611            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1612        }
1613        error_map.update(kwargs.pop('error_map', {}))
1614        api_version = "2020-06-01"
1615        accept = "application/json"
1616
1617        # Construct URL
1618        url = self.list_routes_for_vnet.metadata['url']  # type: ignore
1619        path_format_arguments = {
1620            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1621            'name': self._serialize.url("name", name, 'str'),
1622            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1623            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1624        }
1625        url = self._client.format_url(url, **path_format_arguments)
1626
1627        # Construct parameters
1628        query_parameters = {}  # type: Dict[str, Any]
1629        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1630
1631        # Construct headers
1632        header_parameters = {}  # type: Dict[str, Any]
1633        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1634
1635        request = self._client.get(url, query_parameters, header_parameters)
1636        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1637        response = pipeline_response.http_response
1638
1639        if response.status_code not in [200]:
1640            map_error(status_code=response.status_code, response=response, error_map=error_map)
1641            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1642            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1643
1644        deserialized = self._deserialize('[VnetRoute]', pipeline_response)
1645
1646        if cls:
1647            return cls(pipeline_response, deserialized, {})
1648
1649        return deserialized
1650    list_routes_for_vnet.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes'}  # type: ignore
1651
1652    async def get_route_for_vnet(
1653        self,
1654        resource_group_name: str,
1655        name: str,
1656        vnet_name: str,
1657        route_name: str,
1658        **kwargs: Any
1659    ) -> Optional[List["_models.VnetRoute"]]:
1660        """Get a Virtual Network route in an App Service plan.
1661
1662        Description for Get a Virtual Network route in an App Service plan.
1663
1664        :param resource_group_name: Name of the resource group to which the resource belongs.
1665        :type resource_group_name: str
1666        :param name: Name of the App Service plan.
1667        :type name: str
1668        :param vnet_name: Name of the Virtual Network.
1669        :type vnet_name: str
1670        :param route_name: Name of the Virtual Network route.
1671        :type route_name: str
1672        :keyword callable cls: A custom type or function that will be passed the direct response
1673        :return: list of VnetRoute, or the result of cls(response)
1674        :rtype: list[~azure.mgmt.web.v2020_06_01.models.VnetRoute] or None
1675        :raises: ~azure.core.exceptions.HttpResponseError
1676        """
1677        cls = kwargs.pop('cls', None)  # type: ClsType[Optional[List["_models.VnetRoute"]]]
1678        error_map = {
1679            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1680        }
1681        error_map.update(kwargs.pop('error_map', {}))
1682        api_version = "2020-06-01"
1683        accept = "application/json"
1684
1685        # Construct URL
1686        url = self.get_route_for_vnet.metadata['url']  # type: ignore
1687        path_format_arguments = {
1688            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1689            'name': self._serialize.url("name", name, 'str'),
1690            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1691            'routeName': self._serialize.url("route_name", route_name, 'str'),
1692            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1693        }
1694        url = self._client.format_url(url, **path_format_arguments)
1695
1696        # Construct parameters
1697        query_parameters = {}  # type: Dict[str, Any]
1698        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1699
1700        # Construct headers
1701        header_parameters = {}  # type: Dict[str, Any]
1702        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1703
1704        request = self._client.get(url, query_parameters, header_parameters)
1705        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1706        response = pipeline_response.http_response
1707
1708        if response.status_code not in [200, 404]:
1709            map_error(status_code=response.status_code, response=response, error_map=error_map)
1710            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1711            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1712
1713        deserialized = None
1714        if response.status_code == 200:
1715            deserialized = self._deserialize('[VnetRoute]', pipeline_response)
1716
1717        if cls:
1718            return cls(pipeline_response, deserialized, {})
1719
1720        return deserialized
1721    get_route_for_vnet.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}'}  # type: ignore
1722
1723    async def create_or_update_vnet_route(
1724        self,
1725        resource_group_name: str,
1726        name: str,
1727        vnet_name: str,
1728        route_name: str,
1729        route: "_models.VnetRoute",
1730        **kwargs: Any
1731    ) -> Optional["_models.VnetRoute"]:
1732        """Create or update a Virtual Network route in an App Service plan.
1733
1734        Description for Create or update a Virtual Network route in an App Service plan.
1735
1736        :param resource_group_name: Name of the resource group to which the resource belongs.
1737        :type resource_group_name: str
1738        :param name: Name of the App Service plan.
1739        :type name: str
1740        :param vnet_name: Name of the Virtual Network.
1741        :type vnet_name: str
1742        :param route_name: Name of the Virtual Network route.
1743        :type route_name: str
1744        :param route: Definition of the Virtual Network route.
1745        :type route: ~azure.mgmt.web.v2020_06_01.models.VnetRoute
1746        :keyword callable cls: A custom type or function that will be passed the direct response
1747        :return: VnetRoute, or the result of cls(response)
1748        :rtype: ~azure.mgmt.web.v2020_06_01.models.VnetRoute or None
1749        :raises: ~azure.core.exceptions.HttpResponseError
1750        """
1751        cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.VnetRoute"]]
1752        error_map = {
1753            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1754        }
1755        error_map.update(kwargs.pop('error_map', {}))
1756        api_version = "2020-06-01"
1757        content_type = kwargs.pop("content_type", "application/json")
1758        accept = "application/json"
1759
1760        # Construct URL
1761        url = self.create_or_update_vnet_route.metadata['url']  # type: ignore
1762        path_format_arguments = {
1763            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1764            'name': self._serialize.url("name", name, 'str'),
1765            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1766            'routeName': self._serialize.url("route_name", route_name, 'str'),
1767            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1768        }
1769        url = self._client.format_url(url, **path_format_arguments)
1770
1771        # Construct parameters
1772        query_parameters = {}  # type: Dict[str, Any]
1773        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1774
1775        # Construct headers
1776        header_parameters = {}  # type: Dict[str, Any]
1777        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
1778        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1779
1780        body_content_kwargs = {}  # type: Dict[str, Any]
1781        body_content = self._serialize.body(route, 'VnetRoute')
1782        body_content_kwargs['content'] = body_content
1783        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
1784        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1785        response = pipeline_response.http_response
1786
1787        if response.status_code not in [200, 400, 404]:
1788            map_error(status_code=response.status_code, response=response, error_map=error_map)
1789            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1790            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1791
1792        deserialized = None
1793        if response.status_code == 200:
1794            deserialized = self._deserialize('VnetRoute', pipeline_response)
1795
1796        if cls:
1797            return cls(pipeline_response, deserialized, {})
1798
1799        return deserialized
1800    create_or_update_vnet_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}'}  # type: ignore
1801
1802    async def delete_vnet_route(
1803        self,
1804        resource_group_name: str,
1805        name: str,
1806        vnet_name: str,
1807        route_name: str,
1808        **kwargs: Any
1809    ) -> None:
1810        """Delete a Virtual Network route in an App Service plan.
1811
1812        Description for Delete a Virtual Network route in an App Service plan.
1813
1814        :param resource_group_name: Name of the resource group to which the resource belongs.
1815        :type resource_group_name: str
1816        :param name: Name of the App Service plan.
1817        :type name: str
1818        :param vnet_name: Name of the Virtual Network.
1819        :type vnet_name: str
1820        :param route_name: Name of the Virtual Network route.
1821        :type route_name: str
1822        :keyword callable cls: A custom type or function that will be passed the direct response
1823        :return: None, or the result of cls(response)
1824        :rtype: None
1825        :raises: ~azure.core.exceptions.HttpResponseError
1826        """
1827        cls = kwargs.pop('cls', None)  # type: ClsType[None]
1828        error_map = {
1829            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1830        }
1831        error_map.update(kwargs.pop('error_map', {}))
1832        api_version = "2020-06-01"
1833        accept = "application/json"
1834
1835        # Construct URL
1836        url = self.delete_vnet_route.metadata['url']  # type: ignore
1837        path_format_arguments = {
1838            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1839            'name': self._serialize.url("name", name, 'str'),
1840            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1841            'routeName': self._serialize.url("route_name", route_name, 'str'),
1842            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1843        }
1844        url = self._client.format_url(url, **path_format_arguments)
1845
1846        # Construct parameters
1847        query_parameters = {}  # type: Dict[str, Any]
1848        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1849
1850        # Construct headers
1851        header_parameters = {}  # type: Dict[str, Any]
1852        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1853
1854        request = self._client.delete(url, query_parameters, header_parameters)
1855        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1856        response = pipeline_response.http_response
1857
1858        if response.status_code not in [200, 404]:
1859            map_error(status_code=response.status_code, response=response, error_map=error_map)
1860            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1861            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1862
1863        if cls:
1864            return cls(pipeline_response, None, {})
1865
1866    delete_vnet_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}'}  # type: ignore
1867
1868    async def update_vnet_route(
1869        self,
1870        resource_group_name: str,
1871        name: str,
1872        vnet_name: str,
1873        route_name: str,
1874        route: "_models.VnetRoute",
1875        **kwargs: Any
1876    ) -> Optional["_models.VnetRoute"]:
1877        """Create or update a Virtual Network route in an App Service plan.
1878
1879        Description for Create or update a Virtual Network route in an App Service plan.
1880
1881        :param resource_group_name: Name of the resource group to which the resource belongs.
1882        :type resource_group_name: str
1883        :param name: Name of the App Service plan.
1884        :type name: str
1885        :param vnet_name: Name of the Virtual Network.
1886        :type vnet_name: str
1887        :param route_name: Name of the Virtual Network route.
1888        :type route_name: str
1889        :param route: Definition of the Virtual Network route.
1890        :type route: ~azure.mgmt.web.v2020_06_01.models.VnetRoute
1891        :keyword callable cls: A custom type or function that will be passed the direct response
1892        :return: VnetRoute, or the result of cls(response)
1893        :rtype: ~azure.mgmt.web.v2020_06_01.models.VnetRoute or None
1894        :raises: ~azure.core.exceptions.HttpResponseError
1895        """
1896        cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.VnetRoute"]]
1897        error_map = {
1898            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1899        }
1900        error_map.update(kwargs.pop('error_map', {}))
1901        api_version = "2020-06-01"
1902        content_type = kwargs.pop("content_type", "application/json")
1903        accept = "application/json"
1904
1905        # Construct URL
1906        url = self.update_vnet_route.metadata['url']  # type: ignore
1907        path_format_arguments = {
1908            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1909            'name': self._serialize.url("name", name, 'str'),
1910            'vnetName': self._serialize.url("vnet_name", vnet_name, 'str'),
1911            'routeName': self._serialize.url("route_name", route_name, 'str'),
1912            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1913        }
1914        url = self._client.format_url(url, **path_format_arguments)
1915
1916        # Construct parameters
1917        query_parameters = {}  # type: Dict[str, Any]
1918        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1919
1920        # Construct headers
1921        header_parameters = {}  # type: Dict[str, Any]
1922        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
1923        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1924
1925        body_content_kwargs = {}  # type: Dict[str, Any]
1926        body_content = self._serialize.body(route, 'VnetRoute')
1927        body_content_kwargs['content'] = body_content
1928        request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
1929        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1930        response = pipeline_response.http_response
1931
1932        if response.status_code not in [200, 400, 404]:
1933            map_error(status_code=response.status_code, response=response, error_map=error_map)
1934            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
1935            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1936
1937        deserialized = None
1938        if response.status_code == 200:
1939            deserialized = self._deserialize('VnetRoute', pipeline_response)
1940
1941        if cls:
1942            return cls(pipeline_response, deserialized, {})
1943
1944        return deserialized
1945    update_vnet_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}'}  # type: ignore
1946
1947    async def reboot_worker(
1948        self,
1949        resource_group_name: str,
1950        name: str,
1951        worker_name: str,
1952        **kwargs: Any
1953    ) -> None:
1954        """Reboot a worker machine in an App Service plan.
1955
1956        Description for Reboot a worker machine in an App Service plan.
1957
1958        :param resource_group_name: Name of the resource group to which the resource belongs.
1959        :type resource_group_name: str
1960        :param name: Name of the App Service plan.
1961        :type name: str
1962        :param worker_name: Name of worker machine, which typically starts with RD.
1963        :type worker_name: str
1964        :keyword callable cls: A custom type or function that will be passed the direct response
1965        :return: None, or the result of cls(response)
1966        :rtype: None
1967        :raises: ~azure.core.exceptions.HttpResponseError
1968        """
1969        cls = kwargs.pop('cls', None)  # type: ClsType[None]
1970        error_map = {
1971            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1972        }
1973        error_map.update(kwargs.pop('error_map', {}))
1974        api_version = "2020-06-01"
1975        accept = "application/json"
1976
1977        # Construct URL
1978        url = self.reboot_worker.metadata['url']  # type: ignore
1979        path_format_arguments = {
1980            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
1981            'name': self._serialize.url("name", name, 'str'),
1982            'workerName': self._serialize.url("worker_name", worker_name, 'str'),
1983            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
1984        }
1985        url = self._client.format_url(url, **path_format_arguments)
1986
1987        # Construct parameters
1988        query_parameters = {}  # type: Dict[str, Any]
1989        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
1990
1991        # Construct headers
1992        header_parameters = {}  # type: Dict[str, Any]
1993        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
1994
1995        request = self._client.post(url, query_parameters, header_parameters)
1996        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
1997        response = pipeline_response.http_response
1998
1999        if response.status_code not in [204]:
2000            map_error(status_code=response.status_code, response=response, error_map=error_map)
2001            error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, response)
2002            raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
2003
2004        if cls:
2005            return cls(pipeline_response, None, {})
2006
2007    reboot_worker.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/workers/{workerName}/reboot'}  # type: ignore
2008