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