1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for license information. 5# Code generated by Microsoft (R) AutoRest Code Generator. 6# Changes may cause incorrect behavior and will be lost if the code is regenerated. 7# -------------------------------------------------------------------------- 8from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union 9import warnings 10 11from azure.core.async_paging import AsyncItemPaged, AsyncList 12from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 13from azure.core.pipeline import PipelineResponse 14from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest 15from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod 16from azure.mgmt.core.exceptions import ARMErrorFormat 17from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling 18 19from ... import models as _models 20 21T = TypeVar('T') 22ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] 23 24class VirtualMachineScaleSetVMsOperations: 25 """VirtualMachineScaleSetVMsOperations async operations. 26 27 You should not instantiate this class directly. Instead, you should create a Client instance that 28 instantiates it for you and attaches it as an attribute. 29 30 :ivar models: Alias to model classes used in this operation group. 31 :type models: ~azure.mgmt.compute.v2018_06_01.models 32 :param client: Client for service requests. 33 :param config: Configuration of service client. 34 :param serializer: An object model serializer. 35 :param deserializer: An object model deserializer. 36 """ 37 38 models = _models 39 40 def __init__(self, client, config, serializer, deserializer) -> None: 41 self._client = client 42 self._serialize = serializer 43 self._deserialize = deserializer 44 self._config = config 45 46 async def _reimage_initial( 47 self, 48 resource_group_name: str, 49 vm_scale_set_name: str, 50 instance_id: str, 51 vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, 52 **kwargs: Any 53 ) -> None: 54 cls = kwargs.pop('cls', None) # type: ClsType[None] 55 error_map = { 56 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 57 } 58 error_map.update(kwargs.pop('error_map', {})) 59 api_version = "2018-06-01" 60 content_type = kwargs.pop("content_type", "application/json") 61 62 # Construct URL 63 url = self._reimage_initial.metadata['url'] # type: ignore 64 path_format_arguments = { 65 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 66 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 67 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 68 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 69 } 70 url = self._client.format_url(url, **path_format_arguments) 71 72 # Construct parameters 73 query_parameters = {} # type: Dict[str, Any] 74 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 75 76 # Construct headers 77 header_parameters = {} # type: Dict[str, Any] 78 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 79 80 body_content_kwargs = {} # type: Dict[str, Any] 81 if vm_scale_set_vm_reimage_input is not None: 82 body_content = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') 83 else: 84 body_content = None 85 body_content_kwargs['content'] = body_content 86 request = self._client.post(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, 202]: 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 cls: 95 return cls(pipeline_response, None, {}) 96 97 _reimage_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage'} # type: ignore 98 99 async def begin_reimage( 100 self, 101 resource_group_name: str, 102 vm_scale_set_name: str, 103 instance_id: str, 104 vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, 105 **kwargs: Any 106 ) -> AsyncLROPoller[None]: 107 """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. 108 109 :param resource_group_name: The name of the resource group. 110 :type resource_group_name: str 111 :param vm_scale_set_name: The name of the VM scale set. 112 :type vm_scale_set_name: str 113 :param instance_id: The instance ID of the virtual machine. 114 :type instance_id: str 115 :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. 116 :type vm_scale_set_vm_reimage_input: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMReimageParameters 117 :keyword callable cls: A custom type or function that will be passed the direct response 118 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 119 :keyword polling: By default, your polling method will be AsyncARMPolling. 120 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 121 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 122 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 123 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 124 :rtype: ~azure.core.polling.AsyncLROPoller[None] 125 :raises ~azure.core.exceptions.HttpResponseError: 126 """ 127 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 128 cls = kwargs.pop('cls', None) # type: ClsType[None] 129 lro_delay = kwargs.pop( 130 'polling_interval', 131 self._config.polling_interval 132 ) 133 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 134 if cont_token is None: 135 raw_result = await self._reimage_initial( 136 resource_group_name=resource_group_name, 137 vm_scale_set_name=vm_scale_set_name, 138 instance_id=instance_id, 139 vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, 140 cls=lambda x,y,z: x, 141 **kwargs 142 ) 143 144 kwargs.pop('error_map', None) 145 kwargs.pop('content_type', None) 146 147 def get_long_running_output(pipeline_response): 148 if cls: 149 return cls(pipeline_response, None, {}) 150 151 path_format_arguments = { 152 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 153 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 154 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 155 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 156 } 157 158 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 159 elif polling is False: polling_method = AsyncNoPolling() 160 else: polling_method = polling 161 if cont_token: 162 return AsyncLROPoller.from_continuation_token( 163 polling_method=polling_method, 164 continuation_token=cont_token, 165 client=self._client, 166 deserialization_callback=get_long_running_output 167 ) 168 else: 169 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 170 begin_reimage.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage'} # type: ignore 171 172 async def _reimage_all_initial( 173 self, 174 resource_group_name: str, 175 vm_scale_set_name: str, 176 instance_id: str, 177 **kwargs: Any 178 ) -> None: 179 cls = kwargs.pop('cls', None) # type: ClsType[None] 180 error_map = { 181 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 182 } 183 error_map.update(kwargs.pop('error_map', {})) 184 api_version = "2018-06-01" 185 186 # Construct URL 187 url = self._reimage_all_initial.metadata['url'] # type: ignore 188 path_format_arguments = { 189 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 190 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 191 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 192 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 193 } 194 url = self._client.format_url(url, **path_format_arguments) 195 196 # Construct parameters 197 query_parameters = {} # type: Dict[str, Any] 198 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 199 200 # Construct headers 201 header_parameters = {} # type: Dict[str, Any] 202 203 request = self._client.post(url, query_parameters, header_parameters) 204 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 205 response = pipeline_response.http_response 206 207 if response.status_code not in [200, 202]: 208 map_error(status_code=response.status_code, response=response, error_map=error_map) 209 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 210 211 if cls: 212 return cls(pipeline_response, None, {}) 213 214 _reimage_all_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall'} # type: ignore 215 216 async def begin_reimage_all( 217 self, 218 resource_group_name: str, 219 vm_scale_set_name: str, 220 instance_id: str, 221 **kwargs: Any 222 ) -> AsyncLROPoller[None]: 223 """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. 224 This operation is only supported for managed disks. 225 226 :param resource_group_name: The name of the resource group. 227 :type resource_group_name: str 228 :param vm_scale_set_name: The name of the VM scale set. 229 :type vm_scale_set_name: str 230 :param instance_id: The instance ID of the virtual machine. 231 :type instance_id: str 232 :keyword callable cls: A custom type or function that will be passed the direct response 233 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 234 :keyword polling: By default, your polling method will be AsyncARMPolling. 235 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 236 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 237 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 238 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 239 :rtype: ~azure.core.polling.AsyncLROPoller[None] 240 :raises ~azure.core.exceptions.HttpResponseError: 241 """ 242 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 243 cls = kwargs.pop('cls', None) # type: ClsType[None] 244 lro_delay = kwargs.pop( 245 'polling_interval', 246 self._config.polling_interval 247 ) 248 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 249 if cont_token is None: 250 raw_result = await self._reimage_all_initial( 251 resource_group_name=resource_group_name, 252 vm_scale_set_name=vm_scale_set_name, 253 instance_id=instance_id, 254 cls=lambda x,y,z: x, 255 **kwargs 256 ) 257 258 kwargs.pop('error_map', None) 259 kwargs.pop('content_type', None) 260 261 def get_long_running_output(pipeline_response): 262 if cls: 263 return cls(pipeline_response, None, {}) 264 265 path_format_arguments = { 266 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 267 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 268 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 269 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 270 } 271 272 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 273 elif polling is False: polling_method = AsyncNoPolling() 274 else: polling_method = polling 275 if cont_token: 276 return AsyncLROPoller.from_continuation_token( 277 polling_method=polling_method, 278 continuation_token=cont_token, 279 client=self._client, 280 deserialization_callback=get_long_running_output 281 ) 282 else: 283 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 284 begin_reimage_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall'} # type: ignore 285 286 async def _deallocate_initial( 287 self, 288 resource_group_name: str, 289 vm_scale_set_name: str, 290 instance_id: str, 291 **kwargs: Any 292 ) -> None: 293 cls = kwargs.pop('cls', None) # type: ClsType[None] 294 error_map = { 295 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 296 } 297 error_map.update(kwargs.pop('error_map', {})) 298 api_version = "2018-06-01" 299 300 # Construct URL 301 url = self._deallocate_initial.metadata['url'] # type: ignore 302 path_format_arguments = { 303 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 304 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 305 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 306 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 307 } 308 url = self._client.format_url(url, **path_format_arguments) 309 310 # Construct parameters 311 query_parameters = {} # type: Dict[str, Any] 312 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 313 314 # Construct headers 315 header_parameters = {} # type: Dict[str, Any] 316 317 request = self._client.post(url, query_parameters, header_parameters) 318 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 319 response = pipeline_response.http_response 320 321 if response.status_code not in [200, 202]: 322 map_error(status_code=response.status_code, response=response, error_map=error_map) 323 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 324 325 if cls: 326 return cls(pipeline_response, None, {}) 327 328 _deallocate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate'} # type: ignore 329 330 async def begin_deallocate( 331 self, 332 resource_group_name: str, 333 vm_scale_set_name: str, 334 instance_id: str, 335 **kwargs: Any 336 ) -> AsyncLROPoller[None]: 337 """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and 338 releases the compute resources it uses. You are not billed for the compute resources of this 339 virtual machine once it is deallocated. 340 341 :param resource_group_name: The name of the resource group. 342 :type resource_group_name: str 343 :param vm_scale_set_name: The name of the VM scale set. 344 :type vm_scale_set_name: str 345 :param instance_id: The instance ID of the virtual machine. 346 :type instance_id: str 347 :keyword callable cls: A custom type or function that will be passed the direct response 348 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 349 :keyword polling: By default, your polling method will be AsyncARMPolling. 350 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 351 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 352 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 353 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 354 :rtype: ~azure.core.polling.AsyncLROPoller[None] 355 :raises ~azure.core.exceptions.HttpResponseError: 356 """ 357 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 358 cls = kwargs.pop('cls', None) # type: ClsType[None] 359 lro_delay = kwargs.pop( 360 'polling_interval', 361 self._config.polling_interval 362 ) 363 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 364 if cont_token is None: 365 raw_result = await self._deallocate_initial( 366 resource_group_name=resource_group_name, 367 vm_scale_set_name=vm_scale_set_name, 368 instance_id=instance_id, 369 cls=lambda x,y,z: x, 370 **kwargs 371 ) 372 373 kwargs.pop('error_map', None) 374 kwargs.pop('content_type', None) 375 376 def get_long_running_output(pipeline_response): 377 if cls: 378 return cls(pipeline_response, None, {}) 379 380 path_format_arguments = { 381 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 382 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 383 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 384 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 385 } 386 387 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 388 elif polling is False: polling_method = AsyncNoPolling() 389 else: polling_method = polling 390 if cont_token: 391 return AsyncLROPoller.from_continuation_token( 392 polling_method=polling_method, 393 continuation_token=cont_token, 394 client=self._client, 395 deserialization_callback=get_long_running_output 396 ) 397 else: 398 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 399 begin_deallocate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate'} # type: ignore 400 401 async def _update_initial( 402 self, 403 resource_group_name: str, 404 vm_scale_set_name: str, 405 instance_id: str, 406 parameters: "_models.VirtualMachineScaleSetVM", 407 **kwargs: Any 408 ) -> "_models.VirtualMachineScaleSetVM": 409 cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] 410 error_map = { 411 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 412 } 413 error_map.update(kwargs.pop('error_map', {})) 414 api_version = "2018-06-01" 415 content_type = kwargs.pop("content_type", "application/json") 416 accept = "application/json" 417 418 # Construct URL 419 url = self._update_initial.metadata['url'] # type: ignore 420 path_format_arguments = { 421 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 422 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 423 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 424 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 425 } 426 url = self._client.format_url(url, **path_format_arguments) 427 428 # Construct parameters 429 query_parameters = {} # type: Dict[str, Any] 430 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 431 432 # Construct headers 433 header_parameters = {} # type: Dict[str, Any] 434 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 435 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 436 437 body_content_kwargs = {} # type: Dict[str, Any] 438 body_content = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') 439 body_content_kwargs['content'] = body_content 440 request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) 441 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 442 response = pipeline_response.http_response 443 444 if response.status_code not in [200, 202]: 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 response.status_code == 200: 449 deserialized = self._deserialize('VirtualMachineScaleSetVM', pipeline_response) 450 451 if response.status_code == 202: 452 deserialized = self._deserialize('VirtualMachineScaleSetVM', pipeline_response) 453 454 if cls: 455 return cls(pipeline_response, deserialized, {}) 456 457 return deserialized 458 _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'} # type: ignore 459 460 async def begin_update( 461 self, 462 resource_group_name: str, 463 vm_scale_set_name: str, 464 instance_id: str, 465 parameters: "_models.VirtualMachineScaleSetVM", 466 **kwargs: Any 467 ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: 468 """Updates a virtual machine of a VM scale set. 469 470 :param resource_group_name: The name of the resource group. 471 :type resource_group_name: str 472 :param vm_scale_set_name: The name of the VM scale set where the extension should be create or 473 updated. 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 parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. 478 :type parameters: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM 479 :keyword callable cls: A custom type or function that will be passed the direct response 480 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 481 :keyword polling: By default, your polling method will be AsyncARMPolling. 482 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 483 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 484 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 485 :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the result of cls(response) 486 :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM] 487 :raises ~azure.core.exceptions.HttpResponseError: 488 """ 489 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 490 cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] 491 lro_delay = kwargs.pop( 492 'polling_interval', 493 self._config.polling_interval 494 ) 495 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 496 if cont_token is None: 497 raw_result = await self._update_initial( 498 resource_group_name=resource_group_name, 499 vm_scale_set_name=vm_scale_set_name, 500 instance_id=instance_id, 501 parameters=parameters, 502 cls=lambda x,y,z: x, 503 **kwargs 504 ) 505 506 kwargs.pop('error_map', None) 507 kwargs.pop('content_type', None) 508 509 def get_long_running_output(pipeline_response): 510 deserialized = self._deserialize('VirtualMachineScaleSetVM', pipeline_response) 511 512 if cls: 513 return cls(pipeline_response, deserialized, {}) 514 return deserialized 515 516 path_format_arguments = { 517 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 518 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 519 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 520 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 521 } 522 523 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 524 elif polling is False: polling_method = AsyncNoPolling() 525 else: polling_method = polling 526 if cont_token: 527 return AsyncLROPoller.from_continuation_token( 528 polling_method=polling_method, 529 continuation_token=cont_token, 530 client=self._client, 531 deserialization_callback=get_long_running_output 532 ) 533 else: 534 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 535 begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'} # type: ignore 536 537 async def _delete_initial( 538 self, 539 resource_group_name: str, 540 vm_scale_set_name: str, 541 instance_id: str, 542 **kwargs: Any 543 ) -> None: 544 cls = kwargs.pop('cls', None) # type: ClsType[None] 545 error_map = { 546 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 547 } 548 error_map.update(kwargs.pop('error_map', {})) 549 api_version = "2018-06-01" 550 551 # Construct URL 552 url = self._delete_initial.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 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 564 565 # Construct headers 566 header_parameters = {} # type: Dict[str, Any] 567 568 request = self._client.delete(url, query_parameters, header_parameters) 569 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 570 response = pipeline_response.http_response 571 572 if response.status_code not in [200, 202, 204]: 573 map_error(status_code=response.status_code, response=response, error_map=error_map) 574 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 575 576 if cls: 577 return cls(pipeline_response, None, {}) 578 579 _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'} # type: ignore 580 581 async def begin_delete( 582 self, 583 resource_group_name: str, 584 vm_scale_set_name: str, 585 instance_id: str, 586 **kwargs: Any 587 ) -> AsyncLROPoller[None]: 588 """Deletes a virtual machine from a VM scale set. 589 590 :param resource_group_name: The name of the resource group. 591 :type resource_group_name: str 592 :param vm_scale_set_name: The name of the VM scale set. 593 :type vm_scale_set_name: str 594 :param instance_id: The instance ID of the virtual machine. 595 :type instance_id: str 596 :keyword callable cls: A custom type or function that will be passed the direct response 597 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 598 :keyword polling: By default, your polling method will be AsyncARMPolling. 599 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 600 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 601 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 602 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 603 :rtype: ~azure.core.polling.AsyncLROPoller[None] 604 :raises ~azure.core.exceptions.HttpResponseError: 605 """ 606 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 607 cls = kwargs.pop('cls', None) # type: ClsType[None] 608 lro_delay = kwargs.pop( 609 'polling_interval', 610 self._config.polling_interval 611 ) 612 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 613 if cont_token is None: 614 raw_result = await self._delete_initial( 615 resource_group_name=resource_group_name, 616 vm_scale_set_name=vm_scale_set_name, 617 instance_id=instance_id, 618 cls=lambda x,y,z: x, 619 **kwargs 620 ) 621 622 kwargs.pop('error_map', None) 623 kwargs.pop('content_type', None) 624 625 def get_long_running_output(pipeline_response): 626 if cls: 627 return cls(pipeline_response, None, {}) 628 629 path_format_arguments = { 630 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 631 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 632 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 633 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 634 } 635 636 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 637 elif polling is False: polling_method = AsyncNoPolling() 638 else: polling_method = polling 639 if cont_token: 640 return AsyncLROPoller.from_continuation_token( 641 polling_method=polling_method, 642 continuation_token=cont_token, 643 client=self._client, 644 deserialization_callback=get_long_running_output 645 ) 646 else: 647 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 648 begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'} # type: ignore 649 650 async def get( 651 self, 652 resource_group_name: str, 653 vm_scale_set_name: str, 654 instance_id: str, 655 **kwargs: Any 656 ) -> "_models.VirtualMachineScaleSetVM": 657 """Gets a virtual machine from a VM scale set. 658 659 :param resource_group_name: The name of the resource group. 660 :type resource_group_name: str 661 :param vm_scale_set_name: The name of the VM scale set. 662 :type vm_scale_set_name: str 663 :param instance_id: The instance ID of the virtual machine. 664 :type instance_id: str 665 :keyword callable cls: A custom type or function that will be passed the direct response 666 :return: VirtualMachineScaleSetVM, or the result of cls(response) 667 :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM 668 :raises: ~azure.core.exceptions.HttpResponseError 669 """ 670 cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] 671 error_map = { 672 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 673 } 674 error_map.update(kwargs.pop('error_map', {})) 675 api_version = "2018-06-01" 676 accept = "application/json" 677 678 # Construct URL 679 url = self.get.metadata['url'] # type: ignore 680 path_format_arguments = { 681 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 682 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 683 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 684 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 685 } 686 url = self._client.format_url(url, **path_format_arguments) 687 688 # Construct parameters 689 query_parameters = {} # type: Dict[str, Any] 690 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 691 692 # Construct headers 693 header_parameters = {} # type: Dict[str, Any] 694 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 695 696 request = self._client.get(url, query_parameters, header_parameters) 697 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 698 response = pipeline_response.http_response 699 700 if response.status_code not in [200]: 701 map_error(status_code=response.status_code, response=response, error_map=error_map) 702 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 703 704 deserialized = self._deserialize('VirtualMachineScaleSetVM', pipeline_response) 705 706 if cls: 707 return cls(pipeline_response, deserialized, {}) 708 709 return deserialized 710 get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'} # type: ignore 711 712 async def get_instance_view( 713 self, 714 resource_group_name: str, 715 vm_scale_set_name: str, 716 instance_id: str, 717 **kwargs: Any 718 ) -> "_models.VirtualMachineScaleSetVMInstanceView": 719 """Gets the status of a virtual machine from a VM scale set. 720 721 :param resource_group_name: The name of the resource group. 722 :type resource_group_name: str 723 :param vm_scale_set_name: The name of the VM scale set. 724 :type vm_scale_set_name: str 725 :param instance_id: The instance ID of the virtual machine. 726 :type instance_id: str 727 :keyword callable cls: A custom type or function that will be passed the direct response 728 :return: VirtualMachineScaleSetVMInstanceView, or the result of cls(response) 729 :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMInstanceView 730 :raises: ~azure.core.exceptions.HttpResponseError 731 """ 732 cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] 733 error_map = { 734 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 735 } 736 error_map.update(kwargs.pop('error_map', {})) 737 api_version = "2018-06-01" 738 accept = "application/json" 739 740 # Construct URL 741 url = self.get_instance_view.metadata['url'] # type: ignore 742 path_format_arguments = { 743 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 744 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 745 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 746 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 747 } 748 url = self._client.format_url(url, **path_format_arguments) 749 750 # Construct parameters 751 query_parameters = {} # type: Dict[str, Any] 752 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 753 754 # Construct headers 755 header_parameters = {} # type: Dict[str, Any] 756 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 757 758 request = self._client.get(url, query_parameters, header_parameters) 759 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 760 response = pipeline_response.http_response 761 762 if response.status_code not in [200]: 763 map_error(status_code=response.status_code, response=response, error_map=error_map) 764 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 765 766 deserialized = self._deserialize('VirtualMachineScaleSetVMInstanceView', pipeline_response) 767 768 if cls: 769 return cls(pipeline_response, deserialized, {}) 770 771 return deserialized 772 get_instance_view.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView'} # type: ignore 773 774 def list( 775 self, 776 resource_group_name: str, 777 virtual_machine_scale_set_name: str, 778 filter: Optional[str] = None, 779 select: Optional[str] = None, 780 expand: Optional[str] = None, 781 **kwargs: Any 782 ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: 783 """Gets a list of all virtual machines in a VM scale sets. 784 785 :param resource_group_name: The name of the resource group. 786 :type resource_group_name: str 787 :param virtual_machine_scale_set_name: The name of the VM scale set. 788 :type virtual_machine_scale_set_name: str 789 :param filter: The filter to apply to the operation. Allowed values are 790 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied 791 eq true', 'properties/latestModelApplied eq false'. 792 :type filter: str 793 :param select: The list parameters. Allowed values are 'instanceView', 'instanceView/statuses'. 794 :type select: str 795 :param expand: The expand expression to apply to the operation. Allowed values are 796 'instanceView'. 797 :type expand: str 798 :keyword callable cls: A custom type or function that will be passed the direct response 799 :return: An iterator like instance of either VirtualMachineScaleSetVMListResult or the result of cls(response) 800 :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMListResult] 801 :raises: ~azure.core.exceptions.HttpResponseError 802 """ 803 cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] 804 error_map = { 805 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 806 } 807 error_map.update(kwargs.pop('error_map', {})) 808 api_version = "2018-06-01" 809 accept = "application/json" 810 811 def prepare_request(next_link=None): 812 # Construct headers 813 header_parameters = {} # type: Dict[str, Any] 814 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 815 816 if not next_link: 817 # Construct URL 818 url = self.list.metadata['url'] # type: ignore 819 path_format_arguments = { 820 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 821 'virtualMachineScaleSetName': self._serialize.url("virtual_machine_scale_set_name", virtual_machine_scale_set_name, 'str'), 822 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 823 } 824 url = self._client.format_url(url, **path_format_arguments) 825 # Construct parameters 826 query_parameters = {} # type: Dict[str, Any] 827 if filter is not None: 828 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 829 if select is not None: 830 query_parameters['$select'] = self._serialize.query("select", select, 'str') 831 if expand is not None: 832 query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') 833 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 834 835 request = self._client.get(url, query_parameters, header_parameters) 836 else: 837 url = next_link 838 query_parameters = {} # type: Dict[str, Any] 839 request = self._client.get(url, query_parameters, header_parameters) 840 return request 841 842 async def extract_data(pipeline_response): 843 deserialized = self._deserialize('VirtualMachineScaleSetVMListResult', pipeline_response) 844 list_of_elem = deserialized.value 845 if cls: 846 list_of_elem = cls(list_of_elem) 847 return deserialized.next_link or None, AsyncList(list_of_elem) 848 849 async def get_next(next_link=None): 850 request = prepare_request(next_link) 851 852 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 853 response = pipeline_response.http_response 854 855 if response.status_code not in [200]: 856 map_error(status_code=response.status_code, response=response, error_map=error_map) 857 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 858 859 return pipeline_response 860 861 return AsyncItemPaged( 862 get_next, extract_data 863 ) 864 list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines'} # type: ignore 865 866 async def _power_off_initial( 867 self, 868 resource_group_name: str, 869 vm_scale_set_name: str, 870 instance_id: str, 871 **kwargs: Any 872 ) -> None: 873 cls = kwargs.pop('cls', None) # type: ClsType[None] 874 error_map = { 875 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 876 } 877 error_map.update(kwargs.pop('error_map', {})) 878 api_version = "2018-06-01" 879 880 # Construct URL 881 url = self._power_off_initial.metadata['url'] # type: ignore 882 path_format_arguments = { 883 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 884 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 885 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 886 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 887 } 888 url = self._client.format_url(url, **path_format_arguments) 889 890 # Construct parameters 891 query_parameters = {} # type: Dict[str, Any] 892 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 893 894 # Construct headers 895 header_parameters = {} # type: Dict[str, Any] 896 897 request = self._client.post(url, query_parameters, header_parameters) 898 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 899 response = pipeline_response.http_response 900 901 if response.status_code not in [200, 202]: 902 map_error(status_code=response.status_code, response=response, error_map=error_map) 903 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 904 905 if cls: 906 return cls(pipeline_response, None, {}) 907 908 _power_off_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff'} # type: ignore 909 910 async def begin_power_off( 911 self, 912 resource_group_name: str, 913 vm_scale_set_name: str, 914 instance_id: str, 915 **kwargs: Any 916 ) -> AsyncLROPoller[None]: 917 """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached 918 and you are getting charged for the resources. Instead, use deallocate to release resources and 919 avoid charges. 920 921 :param resource_group_name: The name of the resource group. 922 :type resource_group_name: str 923 :param vm_scale_set_name: The name of the VM scale set. 924 :type vm_scale_set_name: str 925 :param instance_id: The instance ID of the virtual machine. 926 :type instance_id: str 927 :keyword callable cls: A custom type or function that will be passed the direct response 928 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 929 :keyword polling: By default, your polling method will be AsyncARMPolling. 930 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 931 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 932 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 933 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 934 :rtype: ~azure.core.polling.AsyncLROPoller[None] 935 :raises ~azure.core.exceptions.HttpResponseError: 936 """ 937 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 938 cls = kwargs.pop('cls', None) # type: ClsType[None] 939 lro_delay = kwargs.pop( 940 'polling_interval', 941 self._config.polling_interval 942 ) 943 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 944 if cont_token is None: 945 raw_result = await self._power_off_initial( 946 resource_group_name=resource_group_name, 947 vm_scale_set_name=vm_scale_set_name, 948 instance_id=instance_id, 949 cls=lambda x,y,z: x, 950 **kwargs 951 ) 952 953 kwargs.pop('error_map', None) 954 kwargs.pop('content_type', None) 955 956 def get_long_running_output(pipeline_response): 957 if cls: 958 return cls(pipeline_response, None, {}) 959 960 path_format_arguments = { 961 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 962 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 963 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 964 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 965 } 966 967 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 968 elif polling is False: polling_method = AsyncNoPolling() 969 else: polling_method = polling 970 if cont_token: 971 return AsyncLROPoller.from_continuation_token( 972 polling_method=polling_method, 973 continuation_token=cont_token, 974 client=self._client, 975 deserialization_callback=get_long_running_output 976 ) 977 else: 978 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 979 begin_power_off.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff'} # type: ignore 980 981 async def _restart_initial( 982 self, 983 resource_group_name: str, 984 vm_scale_set_name: str, 985 instance_id: str, 986 **kwargs: Any 987 ) -> None: 988 cls = kwargs.pop('cls', None) # type: ClsType[None] 989 error_map = { 990 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 991 } 992 error_map.update(kwargs.pop('error_map', {})) 993 api_version = "2018-06-01" 994 995 # Construct URL 996 url = self._restart_initial.metadata['url'] # type: ignore 997 path_format_arguments = { 998 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 999 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1000 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1001 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1002 } 1003 url = self._client.format_url(url, **path_format_arguments) 1004 1005 # Construct parameters 1006 query_parameters = {} # type: Dict[str, Any] 1007 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 1008 1009 # Construct headers 1010 header_parameters = {} # type: Dict[str, Any] 1011 1012 request = self._client.post(url, query_parameters, header_parameters) 1013 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 1014 response = pipeline_response.http_response 1015 1016 if response.status_code not in [200, 202]: 1017 map_error(status_code=response.status_code, response=response, error_map=error_map) 1018 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1019 1020 if cls: 1021 return cls(pipeline_response, None, {}) 1022 1023 _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart'} # type: ignore 1024 1025 async def begin_restart( 1026 self, 1027 resource_group_name: str, 1028 vm_scale_set_name: str, 1029 instance_id: str, 1030 **kwargs: Any 1031 ) -> AsyncLROPoller[None]: 1032 """Restarts a virtual machine in a VM scale set. 1033 1034 :param resource_group_name: The name of the resource group. 1035 :type resource_group_name: str 1036 :param vm_scale_set_name: The name of the VM scale set. 1037 :type vm_scale_set_name: str 1038 :param instance_id: The instance ID of the virtual machine. 1039 :type instance_id: str 1040 :keyword callable cls: A custom type or function that will be passed the direct response 1041 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 1042 :keyword polling: By default, your polling method will be AsyncARMPolling. 1043 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 1044 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 1045 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 1046 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 1047 :rtype: ~azure.core.polling.AsyncLROPoller[None] 1048 :raises ~azure.core.exceptions.HttpResponseError: 1049 """ 1050 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 1051 cls = kwargs.pop('cls', None) # type: ClsType[None] 1052 lro_delay = kwargs.pop( 1053 'polling_interval', 1054 self._config.polling_interval 1055 ) 1056 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 1057 if cont_token is None: 1058 raw_result = await self._restart_initial( 1059 resource_group_name=resource_group_name, 1060 vm_scale_set_name=vm_scale_set_name, 1061 instance_id=instance_id, 1062 cls=lambda x,y,z: x, 1063 **kwargs 1064 ) 1065 1066 kwargs.pop('error_map', None) 1067 kwargs.pop('content_type', None) 1068 1069 def get_long_running_output(pipeline_response): 1070 if cls: 1071 return cls(pipeline_response, None, {}) 1072 1073 path_format_arguments = { 1074 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1075 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1076 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1077 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1078 } 1079 1080 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 1081 elif polling is False: polling_method = AsyncNoPolling() 1082 else: polling_method = polling 1083 if cont_token: 1084 return AsyncLROPoller.from_continuation_token( 1085 polling_method=polling_method, 1086 continuation_token=cont_token, 1087 client=self._client, 1088 deserialization_callback=get_long_running_output 1089 ) 1090 else: 1091 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 1092 begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart'} # type: ignore 1093 1094 async def _start_initial( 1095 self, 1096 resource_group_name: str, 1097 vm_scale_set_name: str, 1098 instance_id: str, 1099 **kwargs: Any 1100 ) -> None: 1101 cls = kwargs.pop('cls', None) # type: ClsType[None] 1102 error_map = { 1103 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 1104 } 1105 error_map.update(kwargs.pop('error_map', {})) 1106 api_version = "2018-06-01" 1107 1108 # Construct URL 1109 url = self._start_initial.metadata['url'] # type: ignore 1110 path_format_arguments = { 1111 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1112 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1113 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1114 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1115 } 1116 url = self._client.format_url(url, **path_format_arguments) 1117 1118 # Construct parameters 1119 query_parameters = {} # type: Dict[str, Any] 1120 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 1121 1122 # Construct headers 1123 header_parameters = {} # type: Dict[str, Any] 1124 1125 request = self._client.post(url, query_parameters, header_parameters) 1126 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 1127 response = pipeline_response.http_response 1128 1129 if response.status_code not in [200, 202]: 1130 map_error(status_code=response.status_code, response=response, error_map=error_map) 1131 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1132 1133 if cls: 1134 return cls(pipeline_response, None, {}) 1135 1136 _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start'} # type: ignore 1137 1138 async def begin_start( 1139 self, 1140 resource_group_name: str, 1141 vm_scale_set_name: str, 1142 instance_id: str, 1143 **kwargs: Any 1144 ) -> AsyncLROPoller[None]: 1145 """Starts a virtual machine in a VM scale set. 1146 1147 :param resource_group_name: The name of the resource group. 1148 :type resource_group_name: str 1149 :param vm_scale_set_name: The name of the VM scale set. 1150 :type vm_scale_set_name: str 1151 :param instance_id: The instance ID of the virtual machine. 1152 :type instance_id: str 1153 :keyword callable cls: A custom type or function that will be passed the direct response 1154 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 1155 :keyword polling: By default, your polling method will be AsyncARMPolling. 1156 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 1157 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 1158 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 1159 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 1160 :rtype: ~azure.core.polling.AsyncLROPoller[None] 1161 :raises ~azure.core.exceptions.HttpResponseError: 1162 """ 1163 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 1164 cls = kwargs.pop('cls', None) # type: ClsType[None] 1165 lro_delay = kwargs.pop( 1166 'polling_interval', 1167 self._config.polling_interval 1168 ) 1169 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 1170 if cont_token is None: 1171 raw_result = await self._start_initial( 1172 resource_group_name=resource_group_name, 1173 vm_scale_set_name=vm_scale_set_name, 1174 instance_id=instance_id, 1175 cls=lambda x,y,z: x, 1176 **kwargs 1177 ) 1178 1179 kwargs.pop('error_map', None) 1180 kwargs.pop('content_type', None) 1181 1182 def get_long_running_output(pipeline_response): 1183 if cls: 1184 return cls(pipeline_response, None, {}) 1185 1186 path_format_arguments = { 1187 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1188 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1189 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1190 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1191 } 1192 1193 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 1194 elif polling is False: polling_method = AsyncNoPolling() 1195 else: polling_method = polling 1196 if cont_token: 1197 return AsyncLROPoller.from_continuation_token( 1198 polling_method=polling_method, 1199 continuation_token=cont_token, 1200 client=self._client, 1201 deserialization_callback=get_long_running_output 1202 ) 1203 else: 1204 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 1205 begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start'} # type: ignore 1206 1207 async def _redeploy_initial( 1208 self, 1209 resource_group_name: str, 1210 vm_scale_set_name: str, 1211 instance_id: str, 1212 **kwargs: Any 1213 ) -> None: 1214 cls = kwargs.pop('cls', None) # type: ClsType[None] 1215 error_map = { 1216 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 1217 } 1218 error_map.update(kwargs.pop('error_map', {})) 1219 api_version = "2018-06-01" 1220 1221 # Construct URL 1222 url = self._redeploy_initial.metadata['url'] # type: ignore 1223 path_format_arguments = { 1224 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1225 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1226 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1227 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1228 } 1229 url = self._client.format_url(url, **path_format_arguments) 1230 1231 # Construct parameters 1232 query_parameters = {} # type: Dict[str, Any] 1233 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 1234 1235 # Construct headers 1236 header_parameters = {} # type: Dict[str, Any] 1237 1238 request = self._client.post(url, query_parameters, header_parameters) 1239 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 1240 response = pipeline_response.http_response 1241 1242 if response.status_code not in [200, 202]: 1243 map_error(status_code=response.status_code, response=response, error_map=error_map) 1244 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1245 1246 if cls: 1247 return cls(pipeline_response, None, {}) 1248 1249 _redeploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy'} # type: ignore 1250 1251 async def begin_redeploy( 1252 self, 1253 resource_group_name: str, 1254 vm_scale_set_name: str, 1255 instance_id: str, 1256 **kwargs: Any 1257 ) -> AsyncLROPoller[None]: 1258 """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and 1259 powers it back on. 1260 1261 :param resource_group_name: The name of the resource group. 1262 :type resource_group_name: str 1263 :param vm_scale_set_name: The name of the VM scale set. 1264 :type vm_scale_set_name: str 1265 :param instance_id: The instance ID of the virtual machine. 1266 :type instance_id: str 1267 :keyword callable cls: A custom type or function that will be passed the direct response 1268 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 1269 :keyword polling: By default, your polling method will be AsyncARMPolling. 1270 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 1271 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 1272 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 1273 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 1274 :rtype: ~azure.core.polling.AsyncLROPoller[None] 1275 :raises ~azure.core.exceptions.HttpResponseError: 1276 """ 1277 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 1278 cls = kwargs.pop('cls', None) # type: ClsType[None] 1279 lro_delay = kwargs.pop( 1280 'polling_interval', 1281 self._config.polling_interval 1282 ) 1283 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 1284 if cont_token is None: 1285 raw_result = await self._redeploy_initial( 1286 resource_group_name=resource_group_name, 1287 vm_scale_set_name=vm_scale_set_name, 1288 instance_id=instance_id, 1289 cls=lambda x,y,z: x, 1290 **kwargs 1291 ) 1292 1293 kwargs.pop('error_map', None) 1294 kwargs.pop('content_type', None) 1295 1296 def get_long_running_output(pipeline_response): 1297 if cls: 1298 return cls(pipeline_response, None, {}) 1299 1300 path_format_arguments = { 1301 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1302 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1303 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1304 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1305 } 1306 1307 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 1308 elif polling is False: polling_method = AsyncNoPolling() 1309 else: polling_method = polling 1310 if cont_token: 1311 return AsyncLROPoller.from_continuation_token( 1312 polling_method=polling_method, 1313 continuation_token=cont_token, 1314 client=self._client, 1315 deserialization_callback=get_long_running_output 1316 ) 1317 else: 1318 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 1319 begin_redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy'} # type: ignore 1320 1321 async def _perform_maintenance_initial( 1322 self, 1323 resource_group_name: str, 1324 vm_scale_set_name: str, 1325 instance_id: str, 1326 **kwargs: Any 1327 ) -> None: 1328 cls = kwargs.pop('cls', None) # type: ClsType[None] 1329 error_map = { 1330 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 1331 } 1332 error_map.update(kwargs.pop('error_map', {})) 1333 api_version = "2018-06-01" 1334 1335 # Construct URL 1336 url = self._perform_maintenance_initial.metadata['url'] # type: ignore 1337 path_format_arguments = { 1338 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1339 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1340 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1341 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1342 } 1343 url = self._client.format_url(url, **path_format_arguments) 1344 1345 # Construct parameters 1346 query_parameters = {} # type: Dict[str, Any] 1347 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 1348 1349 # Construct headers 1350 header_parameters = {} # type: Dict[str, Any] 1351 1352 request = self._client.post(url, query_parameters, header_parameters) 1353 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 1354 response = pipeline_response.http_response 1355 1356 if response.status_code not in [200, 202]: 1357 map_error(status_code=response.status_code, response=response, error_map=error_map) 1358 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1359 1360 if cls: 1361 return cls(pipeline_response, None, {}) 1362 1363 _perform_maintenance_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance'} # type: ignore 1364 1365 async def begin_perform_maintenance( 1366 self, 1367 resource_group_name: str, 1368 vm_scale_set_name: str, 1369 instance_id: str, 1370 **kwargs: Any 1371 ) -> AsyncLROPoller[None]: 1372 """Performs maintenance on a virtual machine in a VM scale set. 1373 1374 :param resource_group_name: The name of the resource group. 1375 :type resource_group_name: str 1376 :param vm_scale_set_name: The name of the VM scale set. 1377 :type vm_scale_set_name: str 1378 :param instance_id: The instance ID of the virtual machine. 1379 :type instance_id: str 1380 :keyword callable cls: A custom type or function that will be passed the direct response 1381 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 1382 :keyword polling: By default, your polling method will be AsyncARMPolling. 1383 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 1384 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 1385 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 1386 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 1387 :rtype: ~azure.core.polling.AsyncLROPoller[None] 1388 :raises ~azure.core.exceptions.HttpResponseError: 1389 """ 1390 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 1391 cls = kwargs.pop('cls', None) # type: ClsType[None] 1392 lro_delay = kwargs.pop( 1393 'polling_interval', 1394 self._config.polling_interval 1395 ) 1396 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 1397 if cont_token is None: 1398 raw_result = await self._perform_maintenance_initial( 1399 resource_group_name=resource_group_name, 1400 vm_scale_set_name=vm_scale_set_name, 1401 instance_id=instance_id, 1402 cls=lambda x,y,z: x, 1403 **kwargs 1404 ) 1405 1406 kwargs.pop('error_map', None) 1407 kwargs.pop('content_type', None) 1408 1409 def get_long_running_output(pipeline_response): 1410 if cls: 1411 return cls(pipeline_response, None, {}) 1412 1413 path_format_arguments = { 1414 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1415 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1416 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1417 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1418 } 1419 1420 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 1421 elif polling is False: polling_method = AsyncNoPolling() 1422 else: polling_method = polling 1423 if cont_token: 1424 return AsyncLROPoller.from_continuation_token( 1425 polling_method=polling_method, 1426 continuation_token=cont_token, 1427 client=self._client, 1428 deserialization_callback=get_long_running_output 1429 ) 1430 else: 1431 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 1432 begin_perform_maintenance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance'} # type: ignore 1433 1434 async def _run_command_initial( 1435 self, 1436 resource_group_name: str, 1437 vm_scale_set_name: str, 1438 instance_id: str, 1439 parameters: "_models.RunCommandInput", 1440 **kwargs: Any 1441 ) -> Optional["_models.RunCommandResult"]: 1442 cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] 1443 error_map = { 1444 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 1445 } 1446 error_map.update(kwargs.pop('error_map', {})) 1447 api_version = "2018-06-01" 1448 content_type = kwargs.pop("content_type", "application/json") 1449 accept = "application/json, text/json" 1450 1451 # Construct URL 1452 url = self._run_command_initial.metadata['url'] # type: ignore 1453 path_format_arguments = { 1454 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1455 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1456 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1457 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1458 } 1459 url = self._client.format_url(url, **path_format_arguments) 1460 1461 # Construct parameters 1462 query_parameters = {} # type: Dict[str, Any] 1463 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 1464 1465 # Construct headers 1466 header_parameters = {} # type: Dict[str, Any] 1467 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 1468 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 1469 1470 body_content_kwargs = {} # type: Dict[str, Any] 1471 body_content = self._serialize.body(parameters, 'RunCommandInput') 1472 body_content_kwargs['content'] = body_content 1473 request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) 1474 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 1475 response = pipeline_response.http_response 1476 1477 if response.status_code not in [200, 202]: 1478 map_error(status_code=response.status_code, response=response, error_map=error_map) 1479 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1480 1481 deserialized = None 1482 if response.status_code == 200: 1483 deserialized = self._deserialize('RunCommandResult', pipeline_response) 1484 1485 if cls: 1486 return cls(pipeline_response, deserialized, {}) 1487 1488 return deserialized 1489 _run_command_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand'} # type: ignore 1490 1491 async def begin_run_command( 1492 self, 1493 resource_group_name: str, 1494 vm_scale_set_name: str, 1495 instance_id: str, 1496 parameters: "_models.RunCommandInput", 1497 **kwargs: Any 1498 ) -> AsyncLROPoller["_models.RunCommandResult"]: 1499 """Run command on a virtual machine in a VM scale set. 1500 1501 :param resource_group_name: The name of the resource group. 1502 :type resource_group_name: str 1503 :param vm_scale_set_name: The name of the VM scale set. 1504 :type vm_scale_set_name: str 1505 :param instance_id: The instance ID of the virtual machine. 1506 :type instance_id: str 1507 :param parameters: Parameters supplied to the Run command operation. 1508 :type parameters: ~azure.mgmt.compute.v2018_06_01.models.RunCommandInput 1509 :keyword callable cls: A custom type or function that will be passed the direct response 1510 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 1511 :keyword polling: By default, your polling method will be AsyncARMPolling. 1512 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 1513 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 1514 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 1515 :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of cls(response) 1516 :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.RunCommandResult] 1517 :raises ~azure.core.exceptions.HttpResponseError: 1518 """ 1519 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 1520 cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 1521 lro_delay = kwargs.pop( 1522 'polling_interval', 1523 self._config.polling_interval 1524 ) 1525 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 1526 if cont_token is None: 1527 raw_result = await self._run_command_initial( 1528 resource_group_name=resource_group_name, 1529 vm_scale_set_name=vm_scale_set_name, 1530 instance_id=instance_id, 1531 parameters=parameters, 1532 cls=lambda x,y,z: x, 1533 **kwargs 1534 ) 1535 1536 kwargs.pop('error_map', None) 1537 kwargs.pop('content_type', None) 1538 1539 def get_long_running_output(pipeline_response): 1540 deserialized = self._deserialize('RunCommandResult', pipeline_response) 1541 1542 if cls: 1543 return cls(pipeline_response, deserialized, {}) 1544 return deserialized 1545 1546 path_format_arguments = { 1547 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 1548 'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'), 1549 'instanceId': self._serialize.url("instance_id", instance_id, 'str'), 1550 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 1551 } 1552 1553 if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) 1554 elif polling is False: polling_method = AsyncNoPolling() 1555 else: polling_method = polling 1556 if cont_token: 1557 return AsyncLROPoller.from_continuation_token( 1558 polling_method=polling_method, 1559 continuation_token=cont_token, 1560 client=self._client, 1561 deserialization_callback=get_long_running_output 1562 ) 1563 else: 1564 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 1565 begin_run_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand'} # type: ignore 1566