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