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 ImagesOperations: 25 """ImagesOperations 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 _create_or_update_initial( 47 self, 48 resource_group_name: str, 49 image_name: str, 50 parameters: "_models.Image", 51 **kwargs: Any 52 ) -> "_models.Image": 53 cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] 54 error_map = { 55 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 56 } 57 error_map.update(kwargs.pop('error_map', {})) 58 api_version = "2018-06-01" 59 content_type = kwargs.pop("content_type", "application/json") 60 accept = "application/json" 61 62 # Construct URL 63 url = self._create_or_update_initial.metadata['url'] # type: ignore 64 path_format_arguments = { 65 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 66 'imageName': self._serialize.url("image_name", image_name, 'str'), 67 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 68 } 69 url = self._client.format_url(url, **path_format_arguments) 70 71 # Construct parameters 72 query_parameters = {} # type: Dict[str, Any] 73 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 74 75 # Construct headers 76 header_parameters = {} # type: Dict[str, Any] 77 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 78 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 79 80 body_content_kwargs = {} # type: Dict[str, Any] 81 body_content = self._serialize.body(parameters, 'Image') 82 body_content_kwargs['content'] = body_content 83 request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) 84 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 85 response = pipeline_response.http_response 86 87 if response.status_code not in [200, 201]: 88 map_error(status_code=response.status_code, response=response, error_map=error_map) 89 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 90 91 if response.status_code == 200: 92 deserialized = self._deserialize('Image', pipeline_response) 93 94 if response.status_code == 201: 95 deserialized = self._deserialize('Image', pipeline_response) 96 97 if cls: 98 return cls(pipeline_response, deserialized, {}) 99 100 return deserialized 101 _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 102 103 async def begin_create_or_update( 104 self, 105 resource_group_name: str, 106 image_name: str, 107 parameters: "_models.Image", 108 **kwargs: Any 109 ) -> AsyncLROPoller["_models.Image"]: 110 """Create or update an image. 111 112 :param resource_group_name: The name of the resource group. 113 :type resource_group_name: str 114 :param image_name: The name of the image. 115 :type image_name: str 116 :param parameters: Parameters supplied to the Create Image operation. 117 :type parameters: ~azure.mgmt.compute.v2018_06_01.models.Image 118 :keyword callable cls: A custom type or function that will be passed the direct response 119 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 120 :keyword polling: By default, your polling method will be AsyncARMPolling. 121 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 122 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 123 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 124 :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) 125 :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Image] 126 :raises ~azure.core.exceptions.HttpResponseError: 127 """ 128 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 129 cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] 130 lro_delay = kwargs.pop( 131 'polling_interval', 132 self._config.polling_interval 133 ) 134 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 135 if cont_token is None: 136 raw_result = await self._create_or_update_initial( 137 resource_group_name=resource_group_name, 138 image_name=image_name, 139 parameters=parameters, 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 deserialized = self._deserialize('Image', pipeline_response) 149 150 if cls: 151 return cls(pipeline_response, deserialized, {}) 152 return deserialized 153 154 path_format_arguments = { 155 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 156 'imageName': self._serialize.url("image_name", image_name, 'str'), 157 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 158 } 159 160 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 161 elif polling is False: polling_method = AsyncNoPolling() 162 else: polling_method = polling 163 if cont_token: 164 return AsyncLROPoller.from_continuation_token( 165 polling_method=polling_method, 166 continuation_token=cont_token, 167 client=self._client, 168 deserialization_callback=get_long_running_output 169 ) 170 else: 171 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 172 begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 173 174 async def _update_initial( 175 self, 176 resource_group_name: str, 177 image_name: str, 178 parameters: "_models.ImageUpdate", 179 **kwargs: Any 180 ) -> "_models.Image": 181 cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] 182 error_map = { 183 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 184 } 185 error_map.update(kwargs.pop('error_map', {})) 186 api_version = "2018-06-01" 187 content_type = kwargs.pop("content_type", "application/json") 188 accept = "application/json" 189 190 # Construct URL 191 url = self._update_initial.metadata['url'] # type: ignore 192 path_format_arguments = { 193 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 194 'imageName': self._serialize.url("image_name", image_name, 'str'), 195 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 196 } 197 url = self._client.format_url(url, **path_format_arguments) 198 199 # Construct parameters 200 query_parameters = {} # type: Dict[str, Any] 201 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 202 203 # Construct headers 204 header_parameters = {} # type: Dict[str, Any] 205 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 206 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 207 208 body_content_kwargs = {} # type: Dict[str, Any] 209 body_content = self._serialize.body(parameters, 'ImageUpdate') 210 body_content_kwargs['content'] = body_content 211 request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) 212 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 213 response = pipeline_response.http_response 214 215 if response.status_code not in [200, 201]: 216 map_error(status_code=response.status_code, response=response, error_map=error_map) 217 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 218 219 if response.status_code == 200: 220 deserialized = self._deserialize('Image', pipeline_response) 221 222 if response.status_code == 201: 223 deserialized = self._deserialize('Image', pipeline_response) 224 225 if cls: 226 return cls(pipeline_response, deserialized, {}) 227 228 return deserialized 229 _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 230 231 async def begin_update( 232 self, 233 resource_group_name: str, 234 image_name: str, 235 parameters: "_models.ImageUpdate", 236 **kwargs: Any 237 ) -> AsyncLROPoller["_models.Image"]: 238 """Update an image. 239 240 :param resource_group_name: The name of the resource group. 241 :type resource_group_name: str 242 :param image_name: The name of the image. 243 :type image_name: str 244 :param parameters: Parameters supplied to the Update Image operation. 245 :type parameters: ~azure.mgmt.compute.v2018_06_01.models.ImageUpdate 246 :keyword callable cls: A custom type or function that will be passed the direct response 247 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 248 :keyword polling: By default, your polling method will be AsyncARMPolling. 249 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 250 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 251 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 252 :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) 253 :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Image] 254 :raises ~azure.core.exceptions.HttpResponseError: 255 """ 256 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 257 cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] 258 lro_delay = kwargs.pop( 259 'polling_interval', 260 self._config.polling_interval 261 ) 262 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 263 if cont_token is None: 264 raw_result = await self._update_initial( 265 resource_group_name=resource_group_name, 266 image_name=image_name, 267 parameters=parameters, 268 cls=lambda x,y,z: x, 269 **kwargs 270 ) 271 272 kwargs.pop('error_map', None) 273 kwargs.pop('content_type', None) 274 275 def get_long_running_output(pipeline_response): 276 deserialized = self._deserialize('Image', pipeline_response) 277 278 if cls: 279 return cls(pipeline_response, deserialized, {}) 280 return deserialized 281 282 path_format_arguments = { 283 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 284 'imageName': self._serialize.url("image_name", image_name, 'str'), 285 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 286 } 287 288 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 289 elif polling is False: polling_method = AsyncNoPolling() 290 else: polling_method = polling 291 if cont_token: 292 return AsyncLROPoller.from_continuation_token( 293 polling_method=polling_method, 294 continuation_token=cont_token, 295 client=self._client, 296 deserialization_callback=get_long_running_output 297 ) 298 else: 299 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 300 begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 301 302 async def _delete_initial( 303 self, 304 resource_group_name: str, 305 image_name: str, 306 **kwargs: Any 307 ) -> None: 308 cls = kwargs.pop('cls', None) # type: ClsType[None] 309 error_map = { 310 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 311 } 312 error_map.update(kwargs.pop('error_map', {})) 313 api_version = "2018-06-01" 314 315 # Construct URL 316 url = self._delete_initial.metadata['url'] # type: ignore 317 path_format_arguments = { 318 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 319 'imageName': self._serialize.url("image_name", image_name, 'str'), 320 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 321 } 322 url = self._client.format_url(url, **path_format_arguments) 323 324 # Construct parameters 325 query_parameters = {} # type: Dict[str, Any] 326 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 327 328 # Construct headers 329 header_parameters = {} # type: Dict[str, Any] 330 331 request = self._client.delete(url, query_parameters, header_parameters) 332 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 333 response = pipeline_response.http_response 334 335 if response.status_code not in [200, 202, 204]: 336 map_error(status_code=response.status_code, response=response, error_map=error_map) 337 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 338 339 if cls: 340 return cls(pipeline_response, None, {}) 341 342 _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 343 344 async def begin_delete( 345 self, 346 resource_group_name: str, 347 image_name: str, 348 **kwargs: Any 349 ) -> AsyncLROPoller[None]: 350 """Deletes an Image. 351 352 :param resource_group_name: The name of the resource group. 353 :type resource_group_name: str 354 :param image_name: The name of the image. 355 :type image_name: str 356 :keyword callable cls: A custom type or function that will be passed the direct response 357 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 358 :keyword polling: By default, your polling method will be AsyncARMPolling. 359 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 360 :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod 361 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 362 :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) 363 :rtype: ~azure.core.polling.AsyncLROPoller[None] 364 :raises ~azure.core.exceptions.HttpResponseError: 365 """ 366 polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 367 cls = kwargs.pop('cls', None) # type: ClsType[None] 368 lro_delay = kwargs.pop( 369 'polling_interval', 370 self._config.polling_interval 371 ) 372 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 373 if cont_token is None: 374 raw_result = await self._delete_initial( 375 resource_group_name=resource_group_name, 376 image_name=image_name, 377 cls=lambda x,y,z: x, 378 **kwargs 379 ) 380 381 kwargs.pop('error_map', None) 382 kwargs.pop('content_type', None) 383 384 def get_long_running_output(pipeline_response): 385 if cls: 386 return cls(pipeline_response, None, {}) 387 388 path_format_arguments = { 389 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 390 'imageName': self._serialize.url("image_name", image_name, 'str'), 391 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 392 } 393 394 if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 395 elif polling is False: polling_method = AsyncNoPolling() 396 else: polling_method = polling 397 if cont_token: 398 return AsyncLROPoller.from_continuation_token( 399 polling_method=polling_method, 400 continuation_token=cont_token, 401 client=self._client, 402 deserialization_callback=get_long_running_output 403 ) 404 else: 405 return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) 406 begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 407 408 async def get( 409 self, 410 resource_group_name: str, 411 image_name: str, 412 expand: Optional[str] = None, 413 **kwargs: Any 414 ) -> "_models.Image": 415 """Gets an image. 416 417 :param resource_group_name: The name of the resource group. 418 :type resource_group_name: str 419 :param image_name: The name of the image. 420 :type image_name: str 421 :param expand: The expand expression to apply on the operation. 422 :type expand: str 423 :keyword callable cls: A custom type or function that will be passed the direct response 424 :return: Image, or the result of cls(response) 425 :rtype: ~azure.mgmt.compute.v2018_06_01.models.Image 426 :raises: ~azure.core.exceptions.HttpResponseError 427 """ 428 cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] 429 error_map = { 430 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 431 } 432 error_map.update(kwargs.pop('error_map', {})) 433 api_version = "2018-06-01" 434 accept = "application/json" 435 436 # Construct URL 437 url = self.get.metadata['url'] # type: ignore 438 path_format_arguments = { 439 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 440 'imageName': self._serialize.url("image_name", image_name, 'str'), 441 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 442 } 443 url = self._client.format_url(url, **path_format_arguments) 444 445 # Construct parameters 446 query_parameters = {} # type: Dict[str, Any] 447 if expand is not None: 448 query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') 449 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 450 451 # Construct headers 452 header_parameters = {} # type: Dict[str, Any] 453 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 454 455 request = self._client.get(url, query_parameters, header_parameters) 456 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 457 response = pipeline_response.http_response 458 459 if response.status_code not in [200]: 460 map_error(status_code=response.status_code, response=response, error_map=error_map) 461 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 462 463 deserialized = self._deserialize('Image', pipeline_response) 464 465 if cls: 466 return cls(pipeline_response, deserialized, {}) 467 468 return deserialized 469 get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}'} # type: ignore 470 471 def list_by_resource_group( 472 self, 473 resource_group_name: str, 474 **kwargs: Any 475 ) -> AsyncIterable["_models.ImageListResult"]: 476 """Gets the list of images under a resource group. 477 478 :param resource_group_name: The name of the resource group. 479 :type resource_group_name: str 480 :keyword callable cls: A custom type or function that will be passed the direct response 481 :return: An iterator like instance of either ImageListResult or the result of cls(response) 482 :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ImageListResult] 483 :raises: ~azure.core.exceptions.HttpResponseError 484 """ 485 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] 486 error_map = { 487 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 488 } 489 error_map.update(kwargs.pop('error_map', {})) 490 api_version = "2018-06-01" 491 accept = "application/json" 492 493 def prepare_request(next_link=None): 494 # Construct headers 495 header_parameters = {} # type: Dict[str, Any] 496 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 497 498 if not next_link: 499 # Construct URL 500 url = self.list_by_resource_group.metadata['url'] # type: ignore 501 path_format_arguments = { 502 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 503 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 504 } 505 url = self._client.format_url(url, **path_format_arguments) 506 # Construct parameters 507 query_parameters = {} # type: Dict[str, Any] 508 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 509 510 request = self._client.get(url, query_parameters, header_parameters) 511 else: 512 url = next_link 513 query_parameters = {} # type: Dict[str, Any] 514 request = self._client.get(url, query_parameters, header_parameters) 515 return request 516 517 async def extract_data(pipeline_response): 518 deserialized = self._deserialize('ImageListResult', pipeline_response) 519 list_of_elem = deserialized.value 520 if cls: 521 list_of_elem = cls(list_of_elem) 522 return deserialized.next_link or None, AsyncList(list_of_elem) 523 524 async def get_next(next_link=None): 525 request = prepare_request(next_link) 526 527 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 528 response = pipeline_response.http_response 529 530 if response.status_code not in [200]: 531 map_error(status_code=response.status_code, response=response, error_map=error_map) 532 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 533 534 return pipeline_response 535 536 return AsyncItemPaged( 537 get_next, extract_data 538 ) 539 list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images'} # type: ignore 540 541 def list( 542 self, 543 **kwargs: Any 544 ) -> AsyncIterable["_models.ImageListResult"]: 545 """Gets the list of Images in the subscription. Use nextLink property in the response to get the 546 next page of Images. Do this till nextLink is null to fetch all the Images. 547 548 :keyword callable cls: A custom type or function that will be passed the direct response 549 :return: An iterator like instance of either ImageListResult or the result of cls(response) 550 :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ImageListResult] 551 :raises: ~azure.core.exceptions.HttpResponseError 552 """ 553 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] 554 error_map = { 555 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 556 } 557 error_map.update(kwargs.pop('error_map', {})) 558 api_version = "2018-06-01" 559 accept = "application/json" 560 561 def prepare_request(next_link=None): 562 # Construct headers 563 header_parameters = {} # type: Dict[str, Any] 564 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 565 566 if not next_link: 567 # Construct URL 568 url = self.list.metadata['url'] # type: ignore 569 path_format_arguments = { 570 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 571 } 572 url = self._client.format_url(url, **path_format_arguments) 573 # Construct parameters 574 query_parameters = {} # type: Dict[str, Any] 575 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 576 577 request = self._client.get(url, query_parameters, header_parameters) 578 else: 579 url = next_link 580 query_parameters = {} # type: Dict[str, Any] 581 request = self._client.get(url, query_parameters, header_parameters) 582 return request 583 584 async def extract_data(pipeline_response): 585 deserialized = self._deserialize('ImageListResult', pipeline_response) 586 list_of_elem = deserialized.value 587 if cls: 588 list_of_elem = cls(list_of_elem) 589 return deserialized.next_link or None, AsyncList(list_of_elem) 590 591 async def get_next(next_link=None): 592 request = prepare_request(next_link) 593 594 pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) 595 response = pipeline_response.http_response 596 597 if response.status_code not in [200]: 598 map_error(status_code=response.status_code, response=response, error_map=error_map) 599 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 600 601 return pipeline_response 602 603 return AsyncItemPaged( 604 get_next, extract_data 605 ) 606 list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images'} # type: ignore 607