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