@@ -7387,53 +7387,53 @@ async def get_next(next_link=None):
7387
7387
7388
7388
return AsyncItemPaged (get_next , extract_data )
7389
7389
7390
- @distributed_trace_async
7391
- async def list_virtual_machine_scale_sets (
7390
+ @distributed_trace
7391
+ def list_virtual_machine_scale_sets (
7392
7392
self , resource_group_name : str , name : str , ** kwargs : Any
7393
- ) -> _models .VirtualMachineScaleSetListResult :
7393
+ ) -> AsyncIterable [ " _models.VirtualMachineScaleSet" ] :
7394
7394
"""List VirtualMachineScaleSet resources by Fleet.
7395
7395
7396
7396
:param resource_group_name: The name of the resource group. The name is case insensitive.
7397
7397
Required.
7398
7398
:type resource_group_name: str
7399
7399
:param name: The name of the Fleet. Required.
7400
7400
:type name: str
7401
- :return: VirtualMachineScaleSetListResult. The VirtualMachineScaleSetListResult is compatible
7402
- with MutableMapping
7403
- :rtype: ~azure.mgmt.computefleet.models.VirtualMachineScaleSetListResult
7401
+ :return: An iterator like instance of VirtualMachineScaleSet
7402
+ :rtype:
7403
+ ~azure.core.async_paging.AsyncItemPaged[~azure. mgmt.computefleet.models.VirtualMachineScaleSet]
7404
7404
:raises ~azure.core.exceptions.HttpResponseError:
7405
7405
7406
7406
Example:
7407
7407
.. code-block:: python
7408
7408
7409
7409
# response body for status code(s): 200
7410
7410
response == {
7411
- "value": [
7412
- {
7413
- "id": "str",
7414
- "operationStatus": "str",
7415
- "error": {
7411
+ "id": "str",
7412
+ "operationStatus": "str",
7413
+ "error": {
7414
+ "code": "str",
7415
+ "details": [
7416
+ {
7416
7417
"code": "str",
7417
- "details": [
7418
- {
7419
- "code": "str",
7420
- "message": "str",
7421
- "target": "str"
7422
- }
7423
- ],
7424
- "innererror": {
7425
- "errorDetail": "str",
7426
- "exceptionType": "str"
7427
- },
7428
7418
"message": "str",
7429
7419
"target": "str"
7430
- },
7431
- "type": "str"
7432
- }
7433
- ],
7434
- "nextLink": "str"
7420
+ }
7421
+ ],
7422
+ "innererror": {
7423
+ "errorDetail": "str",
7424
+ "exceptionType": "str"
7425
+ },
7426
+ "message": "str",
7427
+ "target": "str"
7428
+ },
7429
+ "type": "str"
7435
7430
}
7436
7431
"""
7432
+ _headers = kwargs .pop ("headers" , {}) or {}
7433
+ _params = kwargs .pop ("params" , {}) or {}
7434
+
7435
+ cls : ClsType [List [_models .VirtualMachineScaleSet ]] = kwargs .pop ("cls" , None )
7436
+
7437
7437
error_map : MutableMapping [int , Type [HttpResponseError ]] = {
7438
7438
401 : ClientAuthenticationError ,
7439
7439
404 : ResourceNotFoundError ,
@@ -7442,44 +7442,57 @@ async def list_virtual_machine_scale_sets(
7442
7442
}
7443
7443
error_map .update (kwargs .pop ("error_map" , {}) or {})
7444
7444
7445
- _headers = kwargs . pop ( "headers" , {}) or {}
7446
- _params = kwargs . pop ( "params" , {}) or {}
7445
+ def prepare_request ( next_link = None ):
7446
+ if not next_link :
7447
7447
7448
- cls : ClsType [_models .VirtualMachineScaleSetListResult ] = kwargs .pop ("cls" , None )
7448
+ _request = build_fleets_list_virtual_machine_scale_sets_request (
7449
+ resource_group_name = resource_group_name ,
7450
+ name = name ,
7451
+ subscription_id = self ._config .subscription_id ,
7452
+ api_version = self ._config .api_version ,
7453
+ headers = _headers ,
7454
+ params = _params ,
7455
+ )
7456
+ _request .url = self ._client .format_url (_request .url )
7449
7457
7450
- _request = build_fleets_list_virtual_machine_scale_sets_request (
7451
- resource_group_name = resource_group_name ,
7452
- name = name ,
7453
- subscription_id = self ._config .subscription_id ,
7454
- api_version = self ._config .api_version ,
7455
- headers = _headers ,
7456
- params = _params ,
7457
- )
7458
- _request .url = self ._client .format_url (_request .url )
7458
+ else :
7459
+ # make call to next link with the client's api-version
7460
+ _parsed_next_link = urllib .parse .urlparse (next_link )
7461
+ _next_request_params = case_insensitive_dict (
7462
+ {
7463
+ key : [urllib .parse .quote (v ) for v in value ]
7464
+ for key , value in urllib .parse .parse_qs (_parsed_next_link .query ).items ()
7465
+ }
7466
+ )
7467
+ _next_request_params ["api-version" ] = self ._config .api_version
7468
+ _request = HttpRequest (
7469
+ "GET" , urllib .parse .urljoin (next_link , _parsed_next_link .path ), params = _next_request_params
7470
+ )
7471
+ _request .url = self ._client .format_url (_request .url )
7459
7472
7460
- _stream = kwargs .pop ("stream" , False )
7461
- pipeline_response : PipelineResponse = await self ._client ._pipeline .run ( # pylint: disable=protected-access
7462
- _request , stream = _stream , ** kwargs
7463
- )
7473
+ return _request
7464
7474
7465
- response = pipeline_response .http_response
7475
+ async def extract_data (pipeline_response ):
7476
+ deserialized = pipeline_response .http_response .json ()
7477
+ list_of_elem = _deserialize (List [_models .VirtualMachineScaleSet ], deserialized ["value" ])
7478
+ if cls :
7479
+ list_of_elem = cls (list_of_elem ) # type: ignore
7480
+ return deserialized .get ("nextLink" ) or None , AsyncList (list_of_elem )
7466
7481
7467
- if response .status_code not in [200 ]:
7468
- if _stream :
7469
- try :
7470
- await response .read () # Load the body in memory and close the socket
7471
- except (StreamConsumedError , StreamClosedError ):
7472
- pass
7473
- map_error (status_code = response .status_code , response = response , error_map = error_map )
7474
- error = _deserialize (_models .ErrorResponse , response .json ())
7475
- raise HttpResponseError (response = response , model = error , error_format = ARMErrorFormat )
7482
+ async def get_next (next_link = None ):
7483
+ _request = prepare_request (next_link )
7476
7484
7477
- if _stream :
7478
- deserialized = response .iter_bytes ()
7479
- else :
7480
- deserialized = _deserialize (_models .VirtualMachineScaleSetListResult , response .json ())
7485
+ _stream = False
7486
+ pipeline_response : PipelineResponse = await self ._client ._pipeline .run ( # pylint: disable=protected-access
7487
+ _request , stream = _stream , ** kwargs
7488
+ )
7489
+ response = pipeline_response .http_response
7481
7490
7482
- if cls :
7483
- return cls (pipeline_response , deserialized , {}) # type: ignore
7491
+ if response .status_code not in [200 ]:
7492
+ map_error (status_code = response .status_code , response = response , error_map = error_map )
7493
+ error = _deserialize (_models .ErrorResponse , response .json ())
7494
+ raise HttpResponseError (response = response , model = error , error_format = ARMErrorFormat )
7484
7495
7485
- return deserialized # type: ignore
7496
+ return pipeline_response
7497
+
7498
+ return AsyncItemPaged (get_next , extract_data )
0 commit comments