Skip to content

Commit ad78350

Browse files
[AutoRelease] t2-computefleet-2024-07-23-16018(can only be merged by SDK owner) (#36577)
* code and test * Update CHANGELOG.md --------- Co-authored-by: azure-sdk <PythonSdkPipelines> Co-authored-by: ChenxiJiang333 <[email protected]>
1 parent b8386f8 commit ad78350

12 files changed

+149
-170
lines changed

sdk/computefleet/azure-mgmt-computefleet/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"commit": "c2dff09296593a12cadba0f9d3352212c78a3baa",
2+
"commit": "c1cea38fb7e5cec9afe223a2ed15cbe2fbeecbdb",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"typespec_src": "specification/azurefleet/AzureFleet.Management",
55
"@azure-tools/typespec-python": "0.26.0"

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/aio/operations/_operations.py

Lines changed: 73 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7387,53 +7387,53 @@ async def get_next(next_link=None):
73877387

73887388
return AsyncItemPaged(get_next, extract_data)
73897389

7390-
@distributed_trace_async
7391-
async def list_virtual_machine_scale_sets(
7390+
@distributed_trace
7391+
def list_virtual_machine_scale_sets(
73927392
self, resource_group_name: str, name: str, **kwargs: Any
7393-
) -> _models.VirtualMachineScaleSetListResult:
7393+
) -> AsyncIterable["_models.VirtualMachineScaleSet"]:
73947394
"""List VirtualMachineScaleSet resources by Fleet.
73957395
73967396
:param resource_group_name: The name of the resource group. The name is case insensitive.
73977397
Required.
73987398
:type resource_group_name: str
73997399
:param name: The name of the Fleet. Required.
74007400
: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]
74047404
:raises ~azure.core.exceptions.HttpResponseError:
74057405
74067406
Example:
74077407
.. code-block:: python
74087408
74097409
# response body for status code(s): 200
74107410
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+
{
74167417
"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-
},
74287418
"message": "str",
74297419
"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"
74357430
}
74367431
"""
7432+
_headers = kwargs.pop("headers", {}) or {}
7433+
_params = kwargs.pop("params", {}) or {}
7434+
7435+
cls: ClsType[List[_models.VirtualMachineScaleSet]] = kwargs.pop("cls", None)
7436+
74377437
error_map: MutableMapping[int, Type[HttpResponseError]] = {
74387438
401: ClientAuthenticationError,
74397439
404: ResourceNotFoundError,
@@ -7442,44 +7442,57 @@ async def list_virtual_machine_scale_sets(
74427442
}
74437443
error_map.update(kwargs.pop("error_map", {}) or {})
74447444

7445-
_headers = kwargs.pop("headers", {}) or {}
7446-
_params = kwargs.pop("params", {}) or {}
7445+
def prepare_request(next_link=None):
7446+
if not next_link:
74477447

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)
74497457

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)
74597472

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
74647474

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)
74667481

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)
74767484

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
74817490

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)
74847495

7485-
return deserialized # type: ignore
7496+
return pipeline_response
7497+
7498+
return AsyncItemPaged(get_next, extract_data)

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/models/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
from ._models import VirtualMachineScaleSetIPConfiguration
7272
from ._models import VirtualMachineScaleSetIPConfigurationProperties
7373
from ._models import VirtualMachineScaleSetIpTag
74-
from ._models import VirtualMachineScaleSetListResult
7574
from ._models import VirtualMachineScaleSetManagedDiskParameters
7675
from ._models import VirtualMachineScaleSetNetworkConfiguration
7776
from ._models import VirtualMachineScaleSetNetworkConfigurationDnsSettings
@@ -194,7 +193,6 @@
194193
"VirtualMachineScaleSetIPConfiguration",
195194
"VirtualMachineScaleSetIPConfigurationProperties",
196195
"VirtualMachineScaleSetIpTag",
197-
"VirtualMachineScaleSetListResult",
198196
"VirtualMachineScaleSetManagedDiskParameters",
199197
"VirtualMachineScaleSetNetworkConfiguration",
200198
"VirtualMachineScaleSetNetworkConfigurationDnsSettings",

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/models/_models.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,41 +3096,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
30963096
super().__init__(*args, **kwargs)
30973097

30983098

3099-
class VirtualMachineScaleSetListResult(_model_base.Model):
3100-
"""The response of a VirtualMachineScaleSet list operation.
3101-
3102-
All required parameters must be populated in order to send to server.
3103-
3104-
:ivar value: The VirtualMachineScaleSet items on this page. Required.
3105-
:vartype value: list[~azure.mgmt.computefleet.models.VirtualMachineScaleSet]
3106-
:ivar next_link: The link to the next page of items.
3107-
:vartype next_link: str
3108-
"""
3109-
3110-
value: List["_models.VirtualMachineScaleSet"] = rest_field()
3111-
"""The VirtualMachineScaleSet items on this page. Required."""
3112-
next_link: Optional[str] = rest_field(name="nextLink")
3113-
"""The link to the next page of items."""
3114-
3115-
@overload
3116-
def __init__(
3117-
self,
3118-
*,
3119-
value: List["_models.VirtualMachineScaleSet"],
3120-
next_link: Optional[str] = None,
3121-
): ...
3122-
3123-
@overload
3124-
def __init__(self, mapping: Mapping[str, Any]):
3125-
"""
3126-
:param mapping: raw JSON to initialize the model.
3127-
:type mapping: Mapping[str, Any]
3128-
"""
3129-
3130-
def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation
3131-
super().__init__(*args, **kwargs)
3132-
3133-
31343099
class VirtualMachineScaleSetManagedDiskParameters(_model_base.Model): # pylint: disable=name-too-long
31353100
"""Describes the parameters of a ScaleSet managed disk.
31363101

0 commit comments

Comments
 (0)