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