1# coding=utf-8
2# --------------------------------------------------------------------------
3# Copyright (c) Microsoft Corporation. All rights reserved.
4# Licensed under the MIT License. See License.txt in the project root for license information.
5# Code generated by Microsoft (R) AutoRest Code Generator.
6# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7# --------------------------------------------------------------------------
8from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union
9import warnings
10
11from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
12from azure.core.pipeline import PipelineResponse
13from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
14from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
15from azure.mgmt.core.exceptions import ARMErrorFormat
16from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
17
18from ... import models as _models
19
20T = TypeVar('T')
21ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
22
23class VirtualMachineScaleSetVMExtensionsOperations:
24    """VirtualMachineScaleSetVMExtensionsOperations async operations.
25
26    You should not instantiate this class directly. Instead, you should create a Client instance that
27    instantiates it for you and attaches it as an attribute.
28
29    :ivar models: Alias to model classes used in this operation group.
30    :type models: ~azure.mgmt.compute.v2019_12_01.models
31    :param client: Client for service requests.
32    :param config: Configuration of service client.
33    :param serializer: An object model serializer.
34    :param deserializer: An object model deserializer.
35    """
36
37    models = _models
38
39    def __init__(self, client, config, serializer, deserializer) -> None:
40        self._client = client
41        self._serialize = serializer
42        self._deserialize = deserializer
43        self._config = config
44
45    async def _create_or_update_initial(
46        self,
47        resource_group_name: str,
48        vm_scale_set_name: str,
49        instance_id: str,
50        vm_extension_name: str,
51        extension_parameters: "_models.VirtualMachineExtension",
52        **kwargs: Any
53    ) -> "_models.VirtualMachineExtension":
54        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VirtualMachineExtension"]
55        error_map = {
56            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
57        }
58        error_map.update(kwargs.pop('error_map', {}))
59        api_version = "2019-12-01"
60        content_type = kwargs.pop("content_type", "application/json")
61        accept = "application/json"
62
63        # Construct URL
64        url = self._create_or_update_initial.metadata['url']  # type: ignore
65        path_format_arguments = {
66            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
67            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
68            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
69            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_name, 'str'),
70            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
71        }
72        url = self._client.format_url(url, **path_format_arguments)
73
74        # Construct parameters
75        query_parameters = {}  # type: Dict[str, Any]
76        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
77
78        # Construct headers
79        header_parameters = {}  # type: Dict[str, Any]
80        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
81        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
82
83        body_content_kwargs = {}  # type: Dict[str, Any]
84        body_content = self._serialize.body(extension_parameters, 'VirtualMachineExtension')
85        body_content_kwargs['content'] = body_content
86        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
87        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
88        response = pipeline_response.http_response
89
90        if response.status_code not in [200, 201]:
91            map_error(status_code=response.status_code, response=response, error_map=error_map)
92            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
93
94        if response.status_code == 200:
95            deserialized = self._deserialize('VirtualMachineExtension', pipeline_response)
96
97        if response.status_code == 201:
98            deserialized = self._deserialize('VirtualMachineExtension', pipeline_response)
99
100        if cls:
101            return cls(pipeline_response, deserialized, {})
102
103        return deserialized
104    _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
105
106    async def begin_create_or_update(
107        self,
108        resource_group_name: str,
109        vm_scale_set_name: str,
110        instance_id: str,
111        vm_extension_name: str,
112        extension_parameters: "_models.VirtualMachineExtension",
113        **kwargs: Any
114    ) -> AsyncLROPoller["_models.VirtualMachineExtension"]:
115        """The operation to create or update the VMSS VM extension.
116
117        :param resource_group_name: The name of the resource group.
118        :type resource_group_name: str
119        :param vm_scale_set_name: The name of the VM scale set.
120        :type vm_scale_set_name: str
121        :param instance_id: The instance ID of the virtual machine.
122        :type instance_id: str
123        :param vm_extension_name: The name of the virtual machine extension.
124        :type vm_extension_name: str
125        :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension
126         operation.
127        :type extension_parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension
128        :keyword callable cls: A custom type or function that will be passed the direct response
129        :keyword str continuation_token: A continuation token to restart a poller from a saved state.
130        :keyword polling: By default, your polling method will be AsyncARMPolling.
131         Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
132        :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
133        :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
134        :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response)
135        :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension]
136        :raises ~azure.core.exceptions.HttpResponseError:
137        """
138        polling = kwargs.pop('polling', True)  # type: Union[bool, AsyncPollingMethod]
139        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VirtualMachineExtension"]
140        lro_delay = kwargs.pop(
141            'polling_interval',
142            self._config.polling_interval
143        )
144        cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
145        if cont_token is None:
146            raw_result = await self._create_or_update_initial(
147                resource_group_name=resource_group_name,
148                vm_scale_set_name=vm_scale_set_name,
149                instance_id=instance_id,
150                vm_extension_name=vm_extension_name,
151                extension_parameters=extension_parameters,
152                cls=lambda x,y,z: x,
153                **kwargs
154            )
155
156        kwargs.pop('error_map', None)
157        kwargs.pop('content_type', None)
158
159        def get_long_running_output(pipeline_response):
160            deserialized = self._deserialize('VirtualMachineExtension', pipeline_response)
161
162            if cls:
163                return cls(pipeline_response, deserialized, {})
164            return deserialized
165
166        path_format_arguments = {
167            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
168            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
169            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
170            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_name, 'str'),
171            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
172        }
173
174        if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments,  **kwargs)
175        elif polling is False: polling_method = AsyncNoPolling()
176        else: polling_method = polling
177        if cont_token:
178            return AsyncLROPoller.from_continuation_token(
179                polling_method=polling_method,
180                continuation_token=cont_token,
181                client=self._client,
182                deserialization_callback=get_long_running_output
183            )
184        else:
185            return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
186    begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
187
188    async def _update_initial(
189        self,
190        resource_group_name: str,
191        vm_scale_set_name: str,
192        instance_id: str,
193        vm_extension_name: str,
194        extension_parameters: "_models.VirtualMachineExtensionUpdate",
195        **kwargs: Any
196    ) -> "_models.VirtualMachineExtension":
197        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VirtualMachineExtension"]
198        error_map = {
199            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
200        }
201        error_map.update(kwargs.pop('error_map', {}))
202        api_version = "2019-12-01"
203        content_type = kwargs.pop("content_type", "application/json")
204        accept = "application/json"
205
206        # Construct URL
207        url = self._update_initial.metadata['url']  # type: ignore
208        path_format_arguments = {
209            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
210            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
211            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
212            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_name, 'str'),
213            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
214        }
215        url = self._client.format_url(url, **path_format_arguments)
216
217        # Construct parameters
218        query_parameters = {}  # type: Dict[str, Any]
219        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
220
221        # Construct headers
222        header_parameters = {}  # type: Dict[str, Any]
223        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
224        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
225
226        body_content_kwargs = {}  # type: Dict[str, Any]
227        body_content = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate')
228        body_content_kwargs['content'] = body_content
229        request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
230        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
231        response = pipeline_response.http_response
232
233        if response.status_code not in [200]:
234            map_error(status_code=response.status_code, response=response, error_map=error_map)
235            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
236
237        deserialized = self._deserialize('VirtualMachineExtension', pipeline_response)
238
239        if cls:
240            return cls(pipeline_response, deserialized, {})
241
242        return deserialized
243    _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
244
245    async def begin_update(
246        self,
247        resource_group_name: str,
248        vm_scale_set_name: str,
249        instance_id: str,
250        vm_extension_name: str,
251        extension_parameters: "_models.VirtualMachineExtensionUpdate",
252        **kwargs: Any
253    ) -> AsyncLROPoller["_models.VirtualMachineExtension"]:
254        """The operation to update the VMSS VM extension.
255
256        :param resource_group_name: The name of the resource group.
257        :type resource_group_name: str
258        :param vm_scale_set_name: The name of the VM scale set.
259        :type vm_scale_set_name: str
260        :param instance_id: The instance ID of the virtual machine.
261        :type instance_id: str
262        :param vm_extension_name: The name of the virtual machine extension.
263        :type vm_extension_name: str
264        :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension
265         operation.
266        :type extension_parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionUpdate
267        :keyword callable cls: A custom type or function that will be passed the direct response
268        :keyword str continuation_token: A continuation token to restart a poller from a saved state.
269        :keyword polling: By default, your polling method will be AsyncARMPolling.
270         Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
271        :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
272        :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
273        :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response)
274        :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension]
275        :raises ~azure.core.exceptions.HttpResponseError:
276        """
277        polling = kwargs.pop('polling', True)  # type: Union[bool, AsyncPollingMethod]
278        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VirtualMachineExtension"]
279        lro_delay = kwargs.pop(
280            'polling_interval',
281            self._config.polling_interval
282        )
283        cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
284        if cont_token is None:
285            raw_result = await self._update_initial(
286                resource_group_name=resource_group_name,
287                vm_scale_set_name=vm_scale_set_name,
288                instance_id=instance_id,
289                vm_extension_name=vm_extension_name,
290                extension_parameters=extension_parameters,
291                cls=lambda x,y,z: x,
292                **kwargs
293            )
294
295        kwargs.pop('error_map', None)
296        kwargs.pop('content_type', None)
297
298        def get_long_running_output(pipeline_response):
299            deserialized = self._deserialize('VirtualMachineExtension', pipeline_response)
300
301            if cls:
302                return cls(pipeline_response, deserialized, {})
303            return deserialized
304
305        path_format_arguments = {
306            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
307            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
308            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
309            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_name, 'str'),
310            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
311        }
312
313        if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments,  **kwargs)
314        elif polling is False: polling_method = AsyncNoPolling()
315        else: polling_method = polling
316        if cont_token:
317            return AsyncLROPoller.from_continuation_token(
318                polling_method=polling_method,
319                continuation_token=cont_token,
320                client=self._client,
321                deserialization_callback=get_long_running_output
322            )
323        else:
324            return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
325    begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
326
327    async def _delete_initial(
328        self,
329        resource_group_name: str,
330        vm_scale_set_name: str,
331        instance_id: str,
332        vm_extension_name: str,
333        **kwargs: Any
334    ) -> None:
335        cls = kwargs.pop('cls', None)  # type: ClsType[None]
336        error_map = {
337            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
338        }
339        error_map.update(kwargs.pop('error_map', {}))
340        api_version = "2019-12-01"
341        accept = "application/json"
342
343        # Construct URL
344        url = self._delete_initial.metadata['url']  # type: ignore
345        path_format_arguments = {
346            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
347            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
348            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
349            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_name, 'str'),
350            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
351        }
352        url = self._client.format_url(url, **path_format_arguments)
353
354        # Construct parameters
355        query_parameters = {}  # type: Dict[str, Any]
356        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
357
358        # Construct headers
359        header_parameters = {}  # type: Dict[str, Any]
360        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
361
362        request = self._client.delete(url, query_parameters, header_parameters)
363        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
364        response = pipeline_response.http_response
365
366        if response.status_code not in [200, 202, 204]:
367            map_error(status_code=response.status_code, response=response, error_map=error_map)
368            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
369
370        if cls:
371            return cls(pipeline_response, None, {})
372
373    _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
374
375    async def begin_delete(
376        self,
377        resource_group_name: str,
378        vm_scale_set_name: str,
379        instance_id: str,
380        vm_extension_name: str,
381        **kwargs: Any
382    ) -> AsyncLROPoller[None]:
383        """The operation to delete the VMSS VM extension.
384
385        :param resource_group_name: The name of the resource group.
386        :type resource_group_name: str
387        :param vm_scale_set_name: The name of the VM scale set.
388        :type vm_scale_set_name: str
389        :param instance_id: The instance ID of the virtual machine.
390        :type instance_id: str
391        :param vm_extension_name: The name of the virtual machine extension.
392        :type vm_extension_name: str
393        :keyword callable cls: A custom type or function that will be passed the direct response
394        :keyword str continuation_token: A continuation token to restart a poller from a saved state.
395        :keyword polling: By default, your polling method will be AsyncARMPolling.
396         Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
397        :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
398        :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
399        :return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
400        :rtype: ~azure.core.polling.AsyncLROPoller[None]
401        :raises ~azure.core.exceptions.HttpResponseError:
402        """
403        polling = kwargs.pop('polling', True)  # type: Union[bool, AsyncPollingMethod]
404        cls = kwargs.pop('cls', None)  # type: ClsType[None]
405        lro_delay = kwargs.pop(
406            'polling_interval',
407            self._config.polling_interval
408        )
409        cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
410        if cont_token is None:
411            raw_result = await self._delete_initial(
412                resource_group_name=resource_group_name,
413                vm_scale_set_name=vm_scale_set_name,
414                instance_id=instance_id,
415                vm_extension_name=vm_extension_name,
416                cls=lambda x,y,z: x,
417                **kwargs
418            )
419
420        kwargs.pop('error_map', None)
421        kwargs.pop('content_type', None)
422
423        def get_long_running_output(pipeline_response):
424            if cls:
425                return cls(pipeline_response, None, {})
426
427        path_format_arguments = {
428            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
429            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
430            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
431            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_name, 'str'),
432            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
433        }
434
435        if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments,  **kwargs)
436        elif polling is False: polling_method = AsyncNoPolling()
437        else: polling_method = polling
438        if cont_token:
439            return AsyncLROPoller.from_continuation_token(
440                polling_method=polling_method,
441                continuation_token=cont_token,
442                client=self._client,
443                deserialization_callback=get_long_running_output
444            )
445        else:
446            return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
447    begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
448
449    async def get(
450        self,
451        resource_group_name: str,
452        vm_scale_set_name: str,
453        instance_id: str,
454        vm_extension_name: str,
455        expand: Optional[str] = None,
456        **kwargs: Any
457    ) -> "_models.VirtualMachineExtension":
458        """The operation to get the VMSS VM extension.
459
460        :param resource_group_name: The name of the resource group.
461        :type resource_group_name: str
462        :param vm_scale_set_name: The name of the VM scale set.
463        :type vm_scale_set_name: str
464        :param instance_id: The instance ID of the virtual machine.
465        :type instance_id: str
466        :param vm_extension_name: The name of the virtual machine extension.
467        :type vm_extension_name: str
468        :param expand: The expand expression to apply on the operation.
469        :type expand: str
470        :keyword callable cls: A custom type or function that will be passed the direct response
471        :return: VirtualMachineExtension, or the result of cls(response)
472        :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension
473        :raises: ~azure.core.exceptions.HttpResponseError
474        """
475        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VirtualMachineExtension"]
476        error_map = {
477            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
478        }
479        error_map.update(kwargs.pop('error_map', {}))
480        api_version = "2019-12-01"
481        accept = "application/json"
482
483        # Construct URL
484        url = self.get.metadata['url']  # type: ignore
485        path_format_arguments = {
486            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
487            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
488            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
489            'vmExtensionName': self._serialize.url("vm_extension_name", vm_extension_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        if expand is not None:
497            query_parameters['$expand'] = self._serialize.query("expand", expand, 'str')
498        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
499
500        # Construct headers
501        header_parameters = {}  # type: Dict[str, Any]
502        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
503
504        request = self._client.get(url, query_parameters, header_parameters)
505        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
506        response = pipeline_response.http_response
507
508        if response.status_code not in [200]:
509            map_error(status_code=response.status_code, response=response, error_map=error_map)
510            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
511
512        deserialized = self._deserialize('VirtualMachineExtension', pipeline_response)
513
514        if cls:
515            return cls(pipeline_response, deserialized, {})
516
517        return deserialized
518    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}'}  # type: ignore
519
520    async def list(
521        self,
522        resource_group_name: str,
523        vm_scale_set_name: str,
524        instance_id: str,
525        expand: Optional[str] = None,
526        **kwargs: Any
527    ) -> "_models.VirtualMachineExtensionsListResult":
528        """The operation to get all extensions of an instance in Virtual Machine Scaleset.
529
530        :param resource_group_name: The name of the resource group.
531        :type resource_group_name: str
532        :param vm_scale_set_name: The name of the VM scale set.
533        :type vm_scale_set_name: str
534        :param instance_id: The instance ID of the virtual machine.
535        :type instance_id: str
536        :param expand: The expand expression to apply on the operation.
537        :type expand: str
538        :keyword callable cls: A custom type or function that will be passed the direct response
539        :return: VirtualMachineExtensionsListResult, or the result of cls(response)
540        :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult
541        :raises: ~azure.core.exceptions.HttpResponseError
542        """
543        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VirtualMachineExtensionsListResult"]
544        error_map = {
545            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
546        }
547        error_map.update(kwargs.pop('error_map', {}))
548        api_version = "2019-12-01"
549        accept = "application/json"
550
551        # Construct URL
552        url = self.list.metadata['url']  # type: ignore
553        path_format_arguments = {
554            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
555            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
556            'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
557            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
558        }
559        url = self._client.format_url(url, **path_format_arguments)
560
561        # Construct parameters
562        query_parameters = {}  # type: Dict[str, Any]
563        if expand is not None:
564            query_parameters['$expand'] = self._serialize.query("expand", expand, 'str')
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 = await 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('VirtualMachineExtensionsListResult', pipeline_response)
580
581        if cls:
582            return cls(pipeline_response, deserialized, {})
583
584        return deserialized
585    list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions'}  # type: ignore
586